lime
Class TransactionMgr

java.lang.Object
  extended byjava.lang.Thread
      extended bylime.TransactionMgr
All Implemented Interfaces:
LimeConstants, java.lang.Runnable

class TransactionMgr
extends java.lang.Thread
implements LimeConstants

Handles outgoing communication destined for all remote hosts.

Author:
Amy L. Murphy, Gian Pietro Picco, Christine Julien, Chien-Liang Fok, Tom Elgin

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

public static final short PUBLIC
public tuple space indicator

See Also:
Constant Field Values

PRIVATE

public static final short PRIVATE
private tuple space indicator

See Also:
Constant Field Values

maxTransID

private static long maxTransID
Used to create TransactionID objects


lServer

private LimeServer lServer
A reference to the LimeServer.


cmgr

private ConnectionMgr cmgr
The connection manager.


transactionMgr

private static final TransactionMgr transactionMgr
The transaction manager.


initiatorTransactions

private java.util.Hashtable initiatorTransactions
Maps TransactionIDs to the InitiatorTransDescriptor. These are all locally initiated transactions.


currentInitiatedTrans

private InitiatorTransDescriptor currentInitiatedTrans
Holds the transaction initiated by this host. Constains an InitiatorTransDescriptor.


pendingInitatedTransactions

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. It contains InitiatorTransDescriptor objects, keyed by TransactionID.


initiatorTransactionQueue

private Queue initiatorTransactionQueue
Holds the transactions that this host wants to start.


readyReceived

private java.util.Hashtable readyReceived
Maps the TransactionID with a vector of LimeServerIDs. The vector of LimeServerIDs is a list that indicates from which hosts READY messages have been received from.


pendingReady

private java.util.Hashtable pendingReady
Maps the transactionID with the TransactionOpDescritor.


startSent

private java.util.Hashtable startSent
This contains a list of TransactionID's for which a START message has already been sent


pendingStart

private Queue pendingStart
Holds start messages that are received while in the middle of processing another transaction.


transInProgress

private TransDescriptor transInProgress
Tracks the current transaction that is running. This variable is set after all READY messages have been received. It is set to null in endOfTransactions().


setupReceived

private java.util.Hashtable setupReceived
Maps a transID to the transactionOpDescriptor. An item is added to this table when the SETUP message is received and is processed.


pendingSetup

private java.util.Vector pendingSetup
Holds SETUP messages that were received while a transaction was in progress. This allows the current transaction to complete before responding to the SETUP message.


pendingData

private java.util.Vector pendingData
Tracks data messages that arrive while another transaction is in progress.


setupSent

private java.util.Hashtable setupSent
Indicates that a setup has been sent for this TransactionID.


setupSpecialReceived

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. TransactionOpDescriptors are placed into this hashtable in method doSetupSpecial.


localLockedTS

java.util.Hashtable localLockedTS
If the tuple space name is in the table, then it has been locked. The LimeTSMgr for that tuple space will put itself into this entry when LimeTSMgr.inTransaction is set to true by this TransactionMgr


incomingTransactions

private Queue incomingTransactions
A queue that contains the TransactionOpDescriptors that were received from other hosts.


changingHosts

private LimeServerID[] changingHosts
A reference to the changing hosts.


actualChangingHosts

private LimeServerID[] actualChangingHosts
Keeps track of the hosts that are actually disengageing during a host disengagemnet.


VERSION

public static final java.lang.String VERSION
See Also:
Constant Field Values

WRITE

public static final short WRITE
See Also:
Constant Field Values

OUTG

public static final short OUTG
See Also:
Constant Field Values

REM_OUTG_ACK

public static final short REM_OUTG_ACK
See Also:
Constant Field Values

TAKE

public static final short TAKE
See Also:
Constant Field Values

WAIT_TO_TAKE

public static final short WAIT_TO_TAKE
See Also:
Constant Field Values

ING

public static final short ING
See Also:
Constant Field Values

READ

public static final short READ
See Also:
Constant Field Values

WAIT_TO_READ

public static final short WAIT_TO_READ
See Also:
Constant Field Values

RDG

public static final short RDG
See Also:
Constant Field Values

REACTS_TO

public static final short REACTS_TO
See Also:
Constant Field Values

UPON

public static final short UPON
See Also:
Constant Field Values

REMOVE_REACTS_TO

public static final short REMOVE_REACTS_TO
See Also:
Constant Field Values

REMOVE_UPON

public static final short REMOVE_UPON
See Also:
Constant Field Values

INST_REACTS_TO

public static final short INST_REACTS_TO
See Also:
Constant Field Values

INST_UPON_LISTENER

public static final short INST_UPON_LISTENER
See Also:
Constant Field Values

INST_REM_UPON_LISTENER

public static final short INST_REM_UPON_LISTENER
See Also:
Constant Field Values

REMOVE_REM_UPON_LISTENER

public static final short REMOVE_REM_UPON_LISTENER
See Also:
Constant Field Values

REM_SYS_TAKE

public static final short REM_SYS_TAKE
See Also:
Constant Field Values

REM_SYS_READ

public static final short REM_SYS_READ
See Also:
Constant Field Values

REM_ING

public static final short REM_ING
See Also:
Constant Field Values

REM_RDG

public static final short REM_RDG
See Also:
Constant Field Values

SYS_TAKE

public static final short SYS_TAKE
See Also:
Constant Field Values

SYS_READ

public static final short SYS_READ
See Also:
Constant Field Values

REM_OUTG

public static final short REM_OUTG
See Also:
Constant Field Values

UPON_EVENT

public static final short UPON_EVENT
See Also:
Constant Field Values

SYS_REPLY

public static final short SYS_REPLY
See Also:
Constant Field Values

LOCAL_SYS_TAKE

public static final short LOCAL_SYS_TAKE
See Also:
Constant Field Values

SET_SHARED

public static final short SET_SHARED
See Also:
Constant Field Values

SET_HOST

public static final short SET_HOST
See Also:
Constant Field Values

DECLARE_LEADER

public static final short DECLARE_LEADER
See Also:
Constant Field Values

ENGAGE_AGENT

public static final short ENGAGE_AGENT
See Also:
Constant Field Values

ENGAGE_HOST

public static final short ENGAGE_HOST
See Also:
Constant Field Values

DISENGAGE_AGENT

public static final short DISENGAGE_AGENT
See Also:
Constant Field Values

DISENGAGE_HOST

public static final short DISENGAGE_HOST
See Also:
Constant Field Values

GO

public static final short GO
See Also:
Constant Field Values

INITIATOR_REQ

public static final short INITIATOR_REQ
See Also:
Constant Field Values

SETUP

public static final short SETUP
See Also:
Constant Field Values

READY

public static final short READY
See Also:
Constant Field Values

START

public static final short START
See Also:
Constant Field Values

DATA

public static final short DATA
See Also:
Constant Field Values

SETUP_SPECIAL

public static final short SETUP_SPECIAL
See Also:
Constant Field Values

READY_SPECIAL

public static final short READY_SPECIAL
See Also:
Constant Field Values

REQUEST_TRANSACTION

public static final short REQUEST_TRANSACTION
See Also:
Constant Field Values

TRANSACTION_GRANTED

public static final short TRANSACTION_GRANTED
See Also:
Constant Field Values

HOST_BYE

public static final short HOST_BYE
See Also:
Constant Field Values

HOST_HELLO

public static final short HOST_HELLO
See Also:
Constant Field Values

AGENT_BYE

public static final short AGENT_BYE
See Also:
Constant Field Values

AGENT_HELLO

public static final short AGENT_HELLO
See Also:
Constant Field Values

HOST_LOCALHOST

public static final short HOST_LOCALHOST
See Also:
Constant Field Values

HOST_REMOTE

public static final short HOST_REMOTE
See Also:
Constant Field Values

HOST_NOTINSYS

public static final short HOST_NOTINSYS
See Also:
Constant Field Values

HOST_UNSPECIFIED

public static final short HOST_UNSPECIFIED
See Also:
Constant Field Values

AGENT_LOCALHOST

public static final short AGENT_LOCALHOST
See Also:
Constant Field Values

AGENT_REMOTE

public static final short AGENT_REMOTE
See Also:
Constant Field Values

AGENT_NOTINSYS

public static final short AGENT_NOTINSYS
See Also:
Constant Field Values

AGENT_UNSPECIFIED

public static final short AGENT_UNSPECIFIED
See Also:
Constant Field Values

TYPE_TAG

public static final int TYPE_TAG
See Also:
Constant Field Values

HOST_TUPLE_HOST_TAG

public static final int HOST_TUPLE_HOST_TAG
See Also:
Constant Field Values

HOST_ADDR_TAG

public static final int HOST_ADDR_TAG
See Also:
Constant Field Values

AGENT_ID_TAG

public static final int AGENT_ID_TAG
See Also:
Constant Field Values

TS_ID_TAG

public static final int TS_ID_TAG
See Also:
Constant Field Values

HOST

public static final java.lang.String HOST
See Also:
Constant Field Values

AGENT

public static final java.lang.String AGENT
See Also:
Constant Field Values

TS

public static final java.lang.String TS
See Also:
Constant Field Values

HOST_GONE

public static final java.lang.String HOST_GONE
See Also:
Constant Field Values

AGENT_GONE

public static final java.lang.String AGENT_GONE
See Also:
Constant Field Values

TS_GONE

public static final java.lang.String TS_GONE
See Also:
Constant Field Values

MAX_ROUNDS

public static final int MAX_ROUNDS
See Also:
Constant Field Values
Constructor Detail

TransactionMgr

private TransactionMgr()
A private defualt constructor used to create the singleton.

Method Detail

run

public void run()
Continuously loops, each time processing a transaction in the incomming transactions queue.

Specified by:
run in interface java.lang.Runnable

getTransactionMgr

static TransactionMgr getTransactionMgr()
Provides access to the TransactionMgr singleton.

Returns:
the TransactionMgr.

containsAgent

static boolean containsAgent(AgentID[] agents,
                             AgentID agent)
Determine whether a given agent is in the array.

Parameters:
agents - an array of agents
agent - a single agent
Returns:
true if agent is in agents

isStillLeader

boolean isStillLeader()
Returns true if this LimeServer is still the leader within the new group.


getIncomingTransactions

public Queue getIncomingTransactions()
Accessor for the incomingTransactions queue. TEMPORARY - Till we figure out why the add method below is not working in IncomingThread Line 53 approx.


addToIncomingTransactions

public void addToIncomingTransactions(TransactionOpDescriptor desc)
Adds a TransactionOpDescriptor to the incomingTransactions queue.

Parameters:
desc - the TransactionOpDescriptor to add to the incomingTransactions queue.

doSetupSpecial

private void doSetupSpecial(TransactionOpDescriptor desc)
Process a setup_special message. This is a message sent from an old leader (and the initiator for a group-group merge) to its old group members to prepare them to receive data from the new group members. This method should prepare this host for the transaction and reply to the leader with a ready special message


doReadySpecial

private void doReadySpecial(TransactionOpDescriptor desc)
This method processes messages of type READY_SPECIAL. It logs the receipt of the ready message, and if this is the leader, it determines whether or not all of the ready messages have been received.


doSetup

private void doSetup(TransactionOpDescriptor desc)
Method doSetup

Parameters:
desc - a TransactionOpDescriptor

doReady

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.

Parameters:
desc - a value of type 'TransactionOpDescriptor'

doStart

private void doStart(TransactionOpDescriptor desc)
This method is called when a START message is received from the leader. It consists of the beginning of the data phase of the transaction.

Parameters:
desc - a value of type 'TransactionOpDescriptor'

doData

private void doData(TransactionOpDescriptor desc)
Processes a data message from another host. A data message will either be the misplaced tuples and upons from a host or the list of hosts to be engaged with in the case of host level engagement.

Parameters:
desc - a value of type 'TransactionOpDescriptor'

processPendingData

private void processPendingData(TransactionID tid)
Goes through the pendingData vector, removes any transactions with the specified transactionID and placed them into incommingTransactions.

Parameters:
tid - the transaction ID.

engagementUpdateLSTS

private void engagementUpdateLSTS(TransactionOpDescriptor desc)
Updates the LSTS during an engagement or disengagement. This method is called by doData.


initiatorAgentEngage

private void initiatorAgentEngage(TransactionOpDescriptor desc)

isSourceOf

private boolean isSourceOf(TransactionOpDescriptor desc)
Returns true if this host is the source of the specified transaction.

This method is called by doData,

Parameters:
desc - The descriptor of the transaction.
Returns:
true if this host is the source of the transaction

updateLSTS

private void updateLSTS(TransactionOpDescriptor desc)

sendTuplesAndUpons

private void sendTuplesAndUpons(TransactionOpDescriptor desc)

addToPendingUpon

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

Parameters:
u - the upons to be moved (HT from tsname to RegisteredReaction[][]
type - either PUBLIC or PRIVATE
namedTS - a value of type 'Hashtable'

isAgentLevel

private boolean isAgentLevel(short type)
Returns true if the type is an agent level transaction (AGENT_HELLO or AGENT_BYE).

Returns:
true if the type is an agent level transaction.

isHostLevel

private boolean isHostLevel(short type)
Returns true if the type is a host level transaction (HOST_HELLO or HOST_BYE).

Returns:
true if the type is a host level transaction.

isBye

private boolean isBye(short type)

sendReadySpecial

private void sendReadySpecial(TransactionOpDescriptor desc)
Sends a READY_SPECIAL message back to the sender of the specified TransactionOpDescriptor.


sendReady

private void sendReady(TransactionOpDescriptor desc)
Sends a ready message to the leader. If this host is the leader, then this method simply adds a READY TransactionOpDescriptor into the incomingTransactions queue. If this host is not the leader, then this method places a READY TransactionOpDescriptor into the outgoingTransactions queue, which is then sent to the leader.

Parameters:
desc - the TransactionOpDescriptor that describes the transaction being processed.

stopTS

private void stopTS(java.lang.String[] ts)
Locks the tuple spaces.

Parameters:
ts - the tuple spaces to lock.

processOutgoing

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.


getHostDepartingAgents

private AgentID[] getHostDepartingAgents()
Returns a list of AgentIDs of all of the agents on the hosts that are changing.

Returns:
a list of AgentIDs of all of the agents on the hosts that are changing.

processIncoming

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

Parameters:
desc - a value of type 'TransactionOpDescriptor'

removeUpons

private void removeUpons(TransactionOpDescriptor desc)
Remove the upons from the reactors of the local tuple space with respect to the disengaging host or agent.

Parameters:
desc - a value of type 'TransactionOpDescriptor'

appendUpons

private void appendUpons(java.util.Vector u,
                         java.util.Vector uMode,
                         RegisteredReaction[][] rr)

cleanUpLSTS

private void cleanUpLSTS(TransactionOpDescriptor desc)
Cleans up the LSTS after an agent or host engagement or disengagement.


removeAgentsAndTS

private void removeAgentsAndTS(java.util.Hashtable agents,
                               LimeServerID host)
Removes agents, tuple spaces, and hosts from the LSTS.

Parameters:
agents - the agents on the host to remove.
host - the host from which to remove the agents.

separateTupleSpaces

private void separateTupleSpaces(TransactionOpDescriptor desc)

send

private void send(RemoteOpDescriptor op)
Passes a RemoteOpDescriptor to the OutgoingMgr.

Parameters:
op - the RemoteOpDescriptor to be sent to the OutgoingMgr.

reverse

private void reverse(RemoteTupleOpDescriptor op)
Removes the specified RemoteTupleOpDescriptor from the normal outgoing queue and runs the reactive program.


startTS

private void startTS(java.util.Enumeration ltsms)
restart an enumeration of shared lime tuple spaces.

Parameters:
ltsms - an enumeration of handles to LimeTSMgr to be restarted

getAgentsAndTS

private java.util.Hashtable getAgentsAndTS(LimeServerID host)
Find the agents and tuple spaces that are local to the passed host

Returns:
a Hashtable from mgentID->vector of tupleSpace names

addAgentsToLSTS

private void addAgentsToLSTS(java.util.Hashtable agents,
                             LimeServerID host)

getTSNames

private java.lang.String[] getTSNames(java.util.Hashtable agents)
Return the set of tuple space names of the all of the agents

Parameters:
agents - a hashtable from agents to array of tsnames
Returns:
the set of tuple space names (no duplicates)

getTSNamesNested

private java.lang.String[] getTSNamesNested(java.util.Hashtable hostsAgents)

getMisplacedTuples

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.

Parameters:
type - PRIVATE or PUBLIC. indicates whether the tuples should be removed from the publically shared tuple space or the private, not yet shared tuple space
agents - a Hashtable from agents to a vector of tuples spaces
namedTS - if PRIVATE: namedTS is hashtable from name of tuple space ->TupleSpace. if PUBLIC: namedTS is hashtable from name of tuple space ->LimeTSMgr
Returns:
a Hashtable from tuple space name to ITuple[]

getMisplacedUpons

private java.util.Hashtable getMisplacedUpons(short type,
                                              java.util.Hashtable tSpaces,
                                              java.util.Hashtable namedTS,
                                              LimeServerID host,
                                              short transType,
                                              boolean isInstalled)
Parameters:
type - either PUBLIC or PRIVATE
tSpaces - 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 transaction
isInstalled - true if the upon is pending.

getUponProbeDescriptor

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[]. Basically creating the structure that is to be sent over the wire.


getTuplespacesToAgents

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

Parameters:
agents - a value of type 'Hashtable' from agents-> array of tuple space names (String[])
Returns:
a value of type 'Hashtable' from tuple space names to array of agent id

putMisplacedTuples

private void putMisplacedTuples(java.util.Hashtable tuples)

putMisplacedUpons

private void putMisplacedUpons(java.util.Hashtable upons)

setShared

void setShared(AgentID agent,
               LimeTupleSpace[] lts,
               boolean isShared,
               Result lock)
Start the engagement or disengagement of an agent. AGENT transactions ONLY, not HOST!!!

Parameters:
agent - the agent starting the transaction
lts - an array of the LimeTupleSpaces involved in the transaction
isShared - true indicates engagement, false indicates disengagement

setSharedHost

void setSharedHost(boolean isShared,
                   Result lock)
Engage or disengage the host. If there is already a transaction in progress, then the request is enqueued. The thread that makes the call is blocked until the transaction completes.

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.

Parameters:
isShared - true for engage. false for disengage.
lock - the lock used to block the calling thread until the operation completes.

makeInitiatorRequest

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.

Parameters:
transType - transaction type
agent - the agent that requested the operation, or NULL if this is a host transaction (because the agent doesn't matter in a host level transaction
lts - 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 involved

processNextInitiatorTrans

private void processNextInitiatorTrans()
If this host has transactions waiting, and is not currently waiting for one of its transactions to complete, then start one. This method is called by the run() method when the TransactionOpDescriptor is of type REQUEST_TRANSACTION or INITIATOR_REQ.


sendDisengageSetup

private void sendDisengageSetup(TransactionOpDescriptor desc)

sendSetupSpecial

private void sendSetupSpecial(TransactionOpDescriptor desc)
Sends a specail setup message to this host. When this host processes this message, it will send all of the members of its old group the same setup special message.


allTSUniform

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


disengage

private void disengage(TransactionOpDescriptor desc)

hostEngageStart

private void hostEngageStart(TransactionOpDescriptor desc)

engageStart

private void engageStart(TransactionOpDescriptor desc)
process a start message which indicates the beginning of an engagement

Parameters:
desc - a value of type 'TransactionOpDescriptor'

determineReadySpecial

private void determineReadySpecial()
if called by the leader, it determines whether or not all of the ready messages expected have been received.


sendSetup

private void sendSetup(TransactionOpDescriptor desc)
This method sends the setup message to the new group members. It is called by determineReadySpecial when all of the hosts have responded saying they are ready.


getHostsAgents

private java.util.Hashtable getHostsAgents()

determineReady

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.

If the host that calls this method is not the leader, this this method does not do anything.


sendStart

private void sendStart(TransactionOpDescriptor desc)
Sends a START message to everyone in the LSTS. This is called by the run() method when it recieves a TRANSACTION_GRANTED message from the leader.


endOfTransaction

private void endOfTransaction(TransactionOpDescriptor desc)
This method is called to terminate the current transaction.


transactionInProgress

private boolean transactionInProgress()
Returns true if a transaction is in progress.

Returns:
true if a transaction is in progress.

iAmLeader

private boolean iAmLeader()
Returns true if this host is the leader, false otherwise.

Returns:
true if this host is the leader, false otherwise.