|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
lime.TransactionMgr
Handles outgoing communication destined for all remote hosts.
Field Summary | |
private LimeServerID[] |
actualChangingHosts
Keeps track of the hosts that are actually disengageing during a host disengagemnet. |
static java.lang.String |
AGENT
|
static short |
AGENT_BYE
|
static java.lang.String |
AGENT_GONE
|
static short |
AGENT_HELLO
|
static int |
AGENT_ID_TAG
|
static short |
AGENT_LOCALHOST
|
static short |
AGENT_NOTINSYS
|
static short |
AGENT_REMOTE
|
static short |
AGENT_UNSPECIFIED
|
private LimeServerID[] |
changingHosts
A reference to the changing hosts. |
private ConnectionMgr |
cmgr
The connection manager. |
private InitiatorTransDescriptor |
currentInitiatedTrans
Holds the transaction initiated by this host. |
static short |
DATA
|
static short |
DECLARE_LEADER
|
static short |
DISENGAGE_AGENT
|
static short |
DISENGAGE_HOST
|
static short |
ENGAGE_AGENT
|
static short |
ENGAGE_HOST
|
static short |
GO
|
static java.lang.String |
HOST
|
static int |
HOST_ADDR_TAG
|
static short |
HOST_BYE
|
static java.lang.String |
HOST_GONE
|
static short |
HOST_HELLO
|
static short |
HOST_LOCALHOST
|
static short |
HOST_NOTINSYS
|
static short |
HOST_REMOTE
|
static int |
HOST_TUPLE_HOST_TAG
|
static short |
HOST_UNSPECIFIED
|
private Queue |
incomingTransactions
A queue that contains the TransactionOpDescriptors that were received from other hosts. |
static short |
ING
|
static short |
INITIATOR_REQ
|
private Queue |
initiatorTransactionQueue
Holds the transactions that this host wants to start. |
private java.util.Hashtable |
initiatorTransactions
Maps TransactionIDs to the InitiatorTransDescriptor. |
static short |
INST_REACTS_TO
|
static short |
INST_REM_UPON_LISTENER
|
static short |
INST_UPON_LISTENER
|
static short |
LOCAL_SYS_TAKE
|
(package private) java.util.Hashtable |
localLockedTS
If the tuple space name is in the table, then it has been locked. |
private LimeServer |
lServer
A reference to the LimeServer. |
static int |
MAX_ROUNDS
|
private static long |
maxTransID
Used to create TransactionID objects |
static short |
OUTG
|
private java.util.Vector |
pendingData
Tracks data messages that arrive while another transaction is in progress. |
private java.util.Hashtable |
pendingInitatedTransactions
Holds the agent level transactions's InitiatorTransDescriptor that this host initiated but is still waiting for the leader to acutally start it. |
private java.util.Hashtable |
pendingReady
Maps the transactionID with the TransactionOpDescritor. |
private java.util.Vector |
pendingSetup
Holds SETUP messages that were received while a transaction was in progress. |
private Queue |
pendingStart
Holds start messages that are received while in the middle of processing another transaction. |
static short |
PRIVATE
private tuple space indicator |
static short |
PUBLIC
public tuple space indicator |
static short |
RDG
|
static short |
REACTS_TO
|
static short |
READ
|
static short |
READY
|
static short |
READY_SPECIAL
|
private java.util.Hashtable |
readyReceived
Maps the TransactionID with a vector of LimeServerIDs. |
static short |
REM_ING
|
static short |
REM_OUTG
|
static short |
REM_OUTG_ACK
|
static short |
REM_RDG
|
static short |
REM_SYS_READ
|
static short |
REM_SYS_TAKE
|
static short |
REMOVE_REACTS_TO
|
static short |
REMOVE_REM_UPON_LISTENER
|
static short |
REMOVE_UPON
|
static short |
REQUEST_TRANSACTION
|
static short |
SET_HOST
|
static short |
SET_SHARED
|
static short |
SETUP
|
static short |
SETUP_SPECIAL
|
private java.util.Hashtable |
setupReceived
Maps a transID to the transactionOpDescriptor. |
private java.util.Hashtable |
setupSent
Indicates that a setup has been sent for this TransactionID. |
(package private) static java.util.Hashtable |
setupSpecialReceived
A hashtable, keyed by TransactionID that holds the TransactionOpDescriptors for which SETUP_SPECIAL messages have been sent but READY_SPECIAL messags have not been received yet. |
static short |
START
|
private java.util.Hashtable |
startSent
This contains a list of TransactionID's for which a START message has already been sent |
static short |
SYS_READ
|
static short |
SYS_REPLY
|
static short |
SYS_TAKE
|
static short |
TAKE
|
static short |
TRANSACTION_GRANTED
|
private static TransactionMgr |
transactionMgr
The transaction manager. |
private TransDescriptor |
transInProgress
Tracks the current transaction that is running. |
static java.lang.String |
TS
|
static java.lang.String |
TS_GONE
|
static int |
TS_ID_TAG
|
static int |
TYPE_TAG
|
static short |
UPON
|
static short |
UPON_EVENT
|
static java.lang.String |
VERSION
|
static short |
WAIT_TO_READ
|
static short |
WAIT_TO_TAKE
|
static short |
WRITE
|
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
private |
TransactionMgr()
A private defualt constructor used to create the singleton. |
Method Summary | |
private void |
addAgentsToLSTS(java.util.Hashtable agents,
LimeServerID host)
|
void |
addToIncomingTransactions(TransactionOpDescriptor desc)
Adds a TransactionOpDescriptor to the incomingTransactions queue. |
private void |
addToPendingUpon(java.util.Hashtable u,
short type,
java.util.Hashtable namedTS)
take the upons and take them out of non-installable and put them into pendingUpon |
private boolean |
allTSUniform(LimeTupleSpace[] lts,
boolean isShared)
returns whether all the tuple spaces all have th same shared value as the boolean passed as a parameter |
private void |
appendUpons(java.util.Vector u,
java.util.Vector uMode,
RegisteredReaction[][] rr)
|
private void |
cleanUpLSTS(TransactionOpDescriptor desc)
Cleans up the LSTS after an agent or host engagement or disengagement. |
(package private) static boolean |
containsAgent(AgentID[] agents,
AgentID agent)
Determine whether a given agent is in the array. |
private void |
determineReady()
When called by the leader, this method determines whether all hosts have sent READY messages, and if so, it initiates the data phase of the transaction by sending a START message. |
private void |
determineReadySpecial()
if called by the leader, it determines whether or not all of the ready messages expected have been received. |
private void |
disengage(TransactionOpDescriptor desc)
|
private void |
doData(TransactionOpDescriptor desc)
Processes a data message from another host. |
private void |
doReady(TransactionOpDescriptor desc)
An operation done by a leader upon receipt of a READY message to process which hosts are ready for which transactions. |
private void |
doReadySpecial(TransactionOpDescriptor desc)
This method processes messages of type READY_SPECIAL. |
private void |
doSetup(TransactionOpDescriptor desc)
Method doSetup |
private void |
doSetupSpecial(TransactionOpDescriptor desc)
Process a setup_special message. |
private void |
doStart(TransactionOpDescriptor desc)
This method is called when a START message is received from the leader. |
private void |
endOfTransaction(TransactionOpDescriptor desc)
This method is called to terminate the current transaction. |
private void |
engagementUpdateLSTS(TransactionOpDescriptor desc)
Updates the LSTS during an engagement or disengagement. |
private void |
engageStart(TransactionOpDescriptor desc)
process a start message which indicates the beginning of an engagement |
private java.util.Hashtable |
getAgentsAndTS(LimeServerID host)
Find the agents and tuple spaces that are local to the passed host |
private AgentID[] |
getHostDepartingAgents()
Returns a list of AgentIDs of all of the agents on the hosts that are changing. |
private java.util.Hashtable |
getHostsAgents()
|
Queue |
getIncomingTransactions()
Accessor for the incomingTransactions queue. |
private java.util.Hashtable |
getMisplacedTuples(short type,
java.util.Hashtable agents,
java.util.Hashtable namedTS)
remove the misplaced tuples for the agents and tuplespaces identified. |
private java.util.Hashtable |
getMisplacedUpons(short type,
java.util.Hashtable tSpaces,
java.util.Hashtable namedTS,
LimeServerID host,
short transType,
boolean isInstalled)
|
(package private) static TransactionMgr |
getTransactionMgr()
Provides access to the TransactionMgr singleton. |
private java.lang.String[] |
getTSNames(java.util.Hashtable agents)
Return the set of tuple space names of the all of the agents |
private java.lang.String[] |
getTSNamesNested(java.util.Hashtable hostsAgents)
|
private java.util.Hashtable |
getTuplespacesToAgents(java.util.Hashtable agents)
reverse the hash table that goes from agents to tuple spaces to go from tuple spaces to agents |
private java.util.Hashtable |
getUponProbeDescriptor(java.util.Hashtable u1,
java.util.Hashtable u2)
Convert a hashatable from tsname to RegisteredReaction[][] into a hashtable from tsname to UponProbeDescriptor[]. |
private void |
hostEngageStart(TransactionOpDescriptor desc)
|
private boolean |
iAmLeader()
Returns true if this host is the leader, false otherwise. |
private void |
initiatorAgentEngage(TransactionOpDescriptor desc)
|
private boolean |
isAgentLevel(short type)
Returns true if the type is an agent level transaction (AGENT_HELLO or AGENT_BYE). |
private boolean |
isBye(short type)
|
private boolean |
isHostLevel(short type)
Returns true if the type is a host level transaction (HOST_HELLO or HOST_BYE). |
private boolean |
isSourceOf(TransactionOpDescriptor desc)
Returns true if this host is the source of the specified transaction. |
(package private) boolean |
isStillLeader()
Returns true if this LimeServer is still the leader within the new group. |
private void |
makeInitiatorRequest(short transType,
AgentID agent,
LimeTupleSpace[] lts,
Result lock)
generates the request that will start the transaction, AND blocks the agent that made the request. |
private void |
processIncoming(TransactionOpDescriptor desc)
process the incoming queue to process REM_OUTG and SYS_REPLY and purge any other messages that will be unimportant after the disengage |
private void |
processNextInitiatorTrans()
If this host has transactions waiting, and is not currently waiting for one of its transactions to complete, then start one. |
private void |
processOutgoing(TransactionOpDescriptor desc,
java.lang.String[] involvedTS,
java.util.Hashtable agents)
This method *might* flush the outgoing queues for every agent and tuple space on every changing host. |
private void |
processPendingData(TransactionID tid)
Goes through the pendingData vector, removes any transactions with the specified transactionID and placed them into incommingTransactions. |
private void |
putMisplacedTuples(java.util.Hashtable tuples)
|
private void |
putMisplacedUpons(java.util.Hashtable upons)
|
private void |
removeAgentsAndTS(java.util.Hashtable agents,
LimeServerID host)
Removes agents, tuple spaces, and hosts from the LSTS. |
private void |
removeUpons(TransactionOpDescriptor desc)
Remove the upons from the reactors of the local tuple space with respect to the disengaging host or agent. |
private void |
reverse(RemoteTupleOpDescriptor op)
Removes the specified RemoteTupleOpDescriptor from the normal outgoing queue and runs the reactive program. |
void |
run()
Continuously loops, each time processing a transaction in the incomming transactions queue. |
private void |
send(RemoteOpDescriptor op)
Passes a RemoteOpDescriptor to the OutgoingMgr. |
private void |
sendDisengageSetup(TransactionOpDescriptor desc)
|
private void |
sendReady(TransactionOpDescriptor desc)
Sends a ready message to the leader. |
private void |
sendReadySpecial(TransactionOpDescriptor desc)
Sends a READY_SPECIAL message back to the sender of the specified TransactionOpDescriptor. |
private void |
sendSetup(TransactionOpDescriptor desc)
This method sends the setup message to the new group members. |
private void |
sendSetupSpecial(TransactionOpDescriptor desc)
Sends a specail setup message to this host. |
private void |
sendStart(TransactionOpDescriptor desc)
Sends a START message to everyone in the LSTS. |
private void |
sendTuplesAndUpons(TransactionOpDescriptor desc)
|
private void |
separateTupleSpaces(TransactionOpDescriptor desc)
|
(package private) void |
setShared(AgentID agent,
LimeTupleSpace[] lts,
boolean isShared,
Result lock)
Start the engagement or disengagement of an agent. |
(package private) void |
setSharedHost(boolean isShared,
Result lock)
Engage or disengage the host. |
private void |
startTS(java.util.Enumeration ltsms)
restart an enumeration of shared lime tuple spaces. |
private void |
stopTS(java.lang.String[] ts)
Locks the tuple spaces. |
private boolean |
transactionInProgress()
Returns true if a transaction is in progress. |
private void |
updateLSTS(TransactionOpDescriptor desc)
|
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final short PUBLIC
public static final short PRIVATE
private static long maxTransID
private LimeServer lServer
private ConnectionMgr cmgr
private static final TransactionMgr transactionMgr
private java.util.Hashtable initiatorTransactions
private InitiatorTransDescriptor currentInitiatedTrans
private java.util.Hashtable pendingInitatedTransactions
private Queue initiatorTransactionQueue
private java.util.Hashtable readyReceived
private java.util.Hashtable pendingReady
private java.util.Hashtable startSent
private Queue pendingStart
private TransDescriptor transInProgress
private java.util.Hashtable setupReceived
private java.util.Vector pendingSetup
private java.util.Vector pendingData
private java.util.Hashtable setupSent
static java.util.Hashtable setupSpecialReceived
java.util.Hashtable localLockedTS
private Queue incomingTransactions
private LimeServerID[] changingHosts
private LimeServerID[] actualChangingHosts
public static final java.lang.String VERSION
public static final short WRITE
public static final short OUTG
public static final short REM_OUTG_ACK
public static final short TAKE
public static final short WAIT_TO_TAKE
public static final short ING
public static final short READ
public static final short WAIT_TO_READ
public static final short RDG
public static final short REACTS_TO
public static final short UPON
public static final short REMOVE_REACTS_TO
public static final short REMOVE_UPON
public static final short INST_REACTS_TO
public static final short INST_UPON_LISTENER
public static final short INST_REM_UPON_LISTENER
public static final short REMOVE_REM_UPON_LISTENER
public static final short REM_SYS_TAKE
public static final short REM_SYS_READ
public static final short REM_ING
public static final short REM_RDG
public static final short SYS_TAKE
public static final short SYS_READ
public static final short REM_OUTG
public static final short UPON_EVENT
public static final short SYS_REPLY
public static final short LOCAL_SYS_TAKE
public static final short SET_SHARED
public static final short SET_HOST
public static final short DECLARE_LEADER
public static final short ENGAGE_AGENT
public static final short ENGAGE_HOST
public static final short DISENGAGE_AGENT
public static final short DISENGAGE_HOST
public static final short GO
public static final short INITIATOR_REQ
public static final short SETUP
public static final short READY
public static final short START
public static final short DATA
public static final short SETUP_SPECIAL
public static final short READY_SPECIAL
public static final short REQUEST_TRANSACTION
public static final short TRANSACTION_GRANTED
public static final short HOST_BYE
public static final short HOST_HELLO
public static final short AGENT_BYE
public static final short AGENT_HELLO
public static final short HOST_LOCALHOST
public static final short HOST_REMOTE
public static final short HOST_NOTINSYS
public static final short HOST_UNSPECIFIED
public static final short AGENT_LOCALHOST
public static final short AGENT_REMOTE
public static final short AGENT_NOTINSYS
public static final short AGENT_UNSPECIFIED
public static final int TYPE_TAG
public static final int HOST_TUPLE_HOST_TAG
public static final int HOST_ADDR_TAG
public static final int AGENT_ID_TAG
public static final int TS_ID_TAG
public static final java.lang.String HOST
public static final java.lang.String AGENT
public static final java.lang.String TS
public static final java.lang.String HOST_GONE
public static final java.lang.String AGENT_GONE
public static final java.lang.String TS_GONE
public static final int MAX_ROUNDS
Constructor Detail |
private TransactionMgr()
Method Detail |
public void run()
run
in interface java.lang.Runnable
static TransactionMgr getTransactionMgr()
static boolean containsAgent(AgentID[] agents, AgentID agent)
agents
- an array of agentsagent
- a single agent
boolean isStillLeader()
public Queue getIncomingTransactions()
public void addToIncomingTransactions(TransactionOpDescriptor desc)
desc
- the TransactionOpDescriptor to add to the
incomingTransactions queue.private void doSetupSpecial(TransactionOpDescriptor desc)
private void doReadySpecial(TransactionOpDescriptor desc)
private void doSetup(TransactionOpDescriptor desc)
desc
- a TransactionOpDescriptorprivate void doReady(TransactionOpDescriptor desc)
desc
- a value of type 'TransactionOpDescriptor'private void doStart(TransactionOpDescriptor desc)
desc
- a value of type 'TransactionOpDescriptor'private void doData(TransactionOpDescriptor desc)
desc
- a value of type 'TransactionOpDescriptor'private void processPendingData(TransactionID tid)
tid
- the transaction ID.private void engagementUpdateLSTS(TransactionOpDescriptor desc)
private void initiatorAgentEngage(TransactionOpDescriptor desc)
private boolean isSourceOf(TransactionOpDescriptor desc)
This method is called by doData,
desc
- The descriptor of the transaction.
private void updateLSTS(TransactionOpDescriptor desc)
private void sendTuplesAndUpons(TransactionOpDescriptor desc)
private void addToPendingUpon(java.util.Hashtable u, short type, java.util.Hashtable namedTS)
u
- the upons to be moved (HT from tsname to RegisteredReaction[][]type
- either PUBLIC or PRIVATEnamedTS
- a value of type 'Hashtable'private boolean isAgentLevel(short type)
private boolean isHostLevel(short type)
private boolean isBye(short type)
private void sendReadySpecial(TransactionOpDescriptor desc)
private void sendReady(TransactionOpDescriptor desc)
desc
- the TransactionOpDescriptor that describes the transaction
being processed.private void stopTS(java.lang.String[] ts)
ts
- the tuple spaces to lock.private void processOutgoing(TransactionOpDescriptor desc, java.lang.String[] involvedTS, java.util.Hashtable agents)
private AgentID[] getHostDepartingAgents()
private void processIncoming(TransactionOpDescriptor desc)
desc
- a value of type 'TransactionOpDescriptor'private void removeUpons(TransactionOpDescriptor desc)
desc
- a value of type 'TransactionOpDescriptor'private void appendUpons(java.util.Vector u, java.util.Vector uMode, RegisteredReaction[][] rr)
private void cleanUpLSTS(TransactionOpDescriptor desc)
private void removeAgentsAndTS(java.util.Hashtable agents, LimeServerID host)
agents
- the agents on the host to remove.host
- the host from which to remove the agents.private void separateTupleSpaces(TransactionOpDescriptor desc)
private void send(RemoteOpDescriptor op)
op
- the RemoteOpDescriptor to be sent to the OutgoingMgr.private void reverse(RemoteTupleOpDescriptor op)
private void startTS(java.util.Enumeration ltsms)
ltsms
- an enumeration of handles to LimeTSMgr to be restartedprivate java.util.Hashtable getAgentsAndTS(LimeServerID host)
private void addAgentsToLSTS(java.util.Hashtable agents, LimeServerID host)
private java.lang.String[] getTSNames(java.util.Hashtable agents)
agents
- a hashtable from agents to array of tsnames
private java.lang.String[] getTSNamesNested(java.util.Hashtable hostsAgents)
private java.util.Hashtable getMisplacedTuples(short type, java.util.Hashtable agents, java.util.Hashtable namedTS)
type
- PRIVATE or PUBLIC. indicates whether the tuples should be
removed from the publically shared tuple space or the private, not yet
shared tuple spaceagents
- a Hashtable from agents to a vector of tuples spacesnamedTS
- if PRIVATE: namedTS is hashtable from name of tuple space
->TupleSpace. if PUBLIC: namedTS is hashtable from name of tuple
space ->LimeTSMgr
private java.util.Hashtable getMisplacedUpons(short type, java.util.Hashtable tSpaces, java.util.Hashtable namedTS, LimeServerID host, short transType, boolean isInstalled)
type
- either PUBLIC or PRIVATEtSpaces
- a hashtable that maps from tuple spaces to agents.
It is created by getTuplespacesToAgents(...).namedTS
- a hashtable that maps the name of the tuple space to the
ITupleSpace.host
- that host to which the misplaced upons should be sent.transType
- The type of the transactionisInstalled
- true if the upon is pending.private java.util.Hashtable getUponProbeDescriptor(java.util.Hashtable u1, java.util.Hashtable u2)
private java.util.Hashtable getTuplespacesToAgents(java.util.Hashtable agents)
agents
- a value of type 'Hashtable' from agents-> array of tuple
space names (String[])
private void putMisplacedTuples(java.util.Hashtable tuples)
private void putMisplacedUpons(java.util.Hashtable upons)
void setShared(AgentID agent, LimeTupleSpace[] lts, boolean isShared, Result lock)
agent
- the agent starting the transactionlts
- an array of the LimeTupleSpaces involved in the transactionisShared
- true indicates engagement, false indicates disengagementvoid setSharedHost(boolean isShared, Result lock)
If this is a host engagement and this host is no longer the leader, this method does not do anything. The host with the highest IP address is the leader.
isShared
- true for engage. false for disengage.lock
- the lock used to block the calling thread until the operation
completes.private void makeInitiatorRequest(short transType, AgentID agent, LimeTupleSpace[] lts, Result lock)
transType
- transaction typeagent
- the agent that requested the operation, or NULL if this is a
host transaction (because the agent doesn't matter in a host level
transactionlts
- the array of tuple spaces thatare involved in an agent
transaction. NULL if this is a host transaction (because it is not
needed---all local tuple spaces are involvedprivate void processNextInitiatorTrans()
private void sendDisengageSetup(TransactionOpDescriptor desc)
private void sendSetupSpecial(TransactionOpDescriptor desc)
private boolean allTSUniform(LimeTupleSpace[] lts, boolean isShared)
private void disengage(TransactionOpDescriptor desc)
private void hostEngageStart(TransactionOpDescriptor desc)
private void engageStart(TransactionOpDescriptor desc)
desc
- a value of type 'TransactionOpDescriptor'private void determineReadySpecial()
private void sendSetup(TransactionOpDescriptor desc)
private java.util.Hashtable getHostsAgents()
private void determineReady()
If the host that calls this method is not the leader, this this method does not do anything.
private void sendStart(TransactionOpDescriptor desc)
private void endOfTransaction(TransactionOpDescriptor desc)
private boolean transactionInProgress()
private boolean iAmLeader()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |