springs.access
Class AgentReferencesUpdater

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--springs.access.AgentReferencesUpdater
All Implemented Interfaces:
java.lang.Runnable

public class AgentReferencesUpdater
extends java.lang.Thread

Thread in charge of updating remote references to agents.

Author:
Sergio Ilarri Artigas

Field Summary
private  springs.access.ReferenceUpdateCommands _remoteUpdateCommands
          A vector with the names of agents whose remote references must be updated.
private  springs.access.StatisticsReferenceUpdate _st
          For statistics computation.
private  boolean _terminate
          A boolean indicating whether the thread must end its execution.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
AgentReferencesUpdater()
          Constructor.
 
Method Summary
 int getNToWait()
          Gets the number of tuples to wait for, depending on the estimated tuple rate.
 boolean getTerminate()
          Obtains if the thread must be terminated.
 void recordReferenceUpdateCommand(springs.access.ReferenceUpdateCommand rac)
          Records instructions to update a reference.
 void removeCommand(java.lang.String agentName)
          Removes a command that requests the update for an agent with the given name.
 void run()
          Main method.
 void terminate()
          Terminates the thread.
private  void waitUntil(int numCommands, long timeout)
          Blocks until there are as many commands as specified, with a maximum timeout, as long as there is at least one command waiting.
private  void waitUntilAtLeastOneCommand()
          Blocks until there is at least one command to follow.
 
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

_terminate

private boolean _terminate
A boolean indicating whether the thread must end its execution.


_remoteUpdateCommands

private springs.access.ReferenceUpdateCommands _remoteUpdateCommands
A vector with the names of agents whose remote references must be updated.

See Also:
ReferenceUpdateCommands

_st

private springs.access.StatisticsReferenceUpdate _st
For statistics computation.

See Also:
StatisticsReferenceUpdate
Constructor Detail

AgentReferencesUpdater

public AgentReferencesUpdater()
Constructor.

Method Detail

waitUntilAtLeastOneCommand

private void waitUntilAtLeastOneCommand()
Blocks until there is at least one command to follow.


run

public void run()
Main method. If there is some remote reference to a local agent, update it.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

recordReferenceUpdateCommand

public void recordReferenceUpdateCommand(springs.access.ReferenceUpdateCommand rac)
Records instructions to update a reference.

Parameters:
rac - the instructions.
See Also:
ReferenceUpdateCommand

removeCommand

public void removeCommand(java.lang.String agentName)
Removes a command that requests the update for an agent with the given name.

Parameters:
agentName - the name of the agent.
See Also:
String

terminate

public void terminate()
Terminates the thread.


getTerminate

public boolean getTerminate()
Obtains if the thread must be terminated.

Returns:
a boolean indicating that.

getNToWait

public int getNToWait()
Gets the number of tuples to wait for, depending on the estimated tuple rate.

Returns:
the number of tuples to wait for.

waitUntil

private void waitUntil(int numCommands,
                       long timeout)
Blocks until there are as many commands as specified, with a maximum timeout, as long as there is at least one command waiting.

Parameters:
numCommands - the number of commands to wait for.
timeout - the maximum timeout (in milliseconds).