|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--springs.context.Context
A context. An implementation should follow the singleton pattern: only a context is allowed in a given JVM.
Field Summary | |
protected springs.access.AccessService |
_accessService
A reference to the access service. |
protected springs.context.AgentInfos |
_agentInfos
Information kept for the agents that execute in the context. |
protected static springs.context.Context |
_context
Singleton pattern. |
protected springs.context.ContextAddress |
_contextAddress
The address of the context. |
private java.util.Hashtable |
_contexts
Table with the contexts in the system, consisting of pairs |
private java.io.BufferedWriter |
_logFile
The log file. |
private static int |
_PORT_FOR_CLASS_SERVER
|
static springs.context.ContextAddress |
CONTEXT_ADDRESS_REGION_NAME_SERVER
The address of the Region Name Server. |
static java.lang.String |
CONTEXT_LOG_FILENAME
For logs. |
static java.lang.String |
LOCALHOST
|
static java.lang.String |
LOCALHOST_IP
|
static boolean |
START_CLASS_SERVER
Set it to true to enable the remote loading of classes. |
Constructor Summary | |
Context()
|
Method Summary | |
void |
addAgentInfo(springs.agent.SpringsAgent agent)
Adds information about the given agent. |
void |
addContext(springs.context.ContextAddress context)
Adds a context to the list of contexts in the system. |
void |
createAgent(java.lang.String targetContext,
springs.agent.SpringsAgent agent,
java.lang.String agentName)
Creates an agent. |
private springs.access.AgentReference |
createAgentReference(springs.agent.SpringsAgent agent)
Creates an agent reference. |
protected void |
ensureMinimumStayTime(java.lang.String agentName)
Ensures that the agent will stay in the context at least the minimum amount of time required, delaying the call otherwise. |
springs.access.AccessService |
getAccessService()
Gets a reference to the access service. |
springs.agent.SpringsAgent |
getAgent(java.lang.String agentName)
Obtains the local agent. |
springs.context.ContextAddress |
getContextAddress()
Gets the context address. |
springs.context.ContextAddress |
getContextAddress(java.lang.String contextName)
Obtains the address of the given context. |
abstract springs.context.ContextManager |
getContextManager(springs.context.ContextAddress contextAddress)
Obtains the context manager at a certain address. |
java.util.Collection |
getContexts()
Returns the information about the contexts in the system. |
java.lang.String |
getContextStatus()
Gets a string with information about the context. |
java.util.Vector |
getLocationServers(java.lang.String agentName)
|
protected long |
getMillisStay(java.lang.String agentName)
Gets the number of milliseconds that the given agent has stayed so far in the current context. |
java.lang.String |
getName()
Obtains the name of the context. |
int |
getNumAgents()
Gets the number of agents executing in the context. |
int |
getNumContexts()
Returns the number of contexts in the system. |
int |
getNumLocationServers(java.lang.String agentName)
|
int |
getNumObservers(java.lang.String agentName)
|
int |
getNumTrackedAndObservedAgents()
Obtains the number of tracked agents. |
java.util.Vector |
getObservers(java.lang.String agentName)
|
static int |
getPortClassServer()
Gets the port for the class server. |
springs.access.AgentReference |
getReferenceToLocalAgent(java.lang.String agentName,
boolean addAsObserver)
Gets a reference to an agent that it is executing locally. |
protected java.lang.String |
getStringForReferenceUpdates(java.util.Vector referenceUpdates)
Obtains a string with the reference updates. |
static void |
initializeLocalIP()
Initializes the local IP address. |
protected static boolean |
isLocalContext(springs.context.ContextAddress addr)
Checks if the given address refers to the local context. |
void |
logContextInfo()
Logs information about contexts. |
void |
recordStartStay(java.lang.String agentName)
Records the current as the time instant when the agent starts its stay in the current context. |
void |
referenceUsed(java.lang.String agentName)
Notifies the context that a reference to the given agent has been used. |
abstract void |
releaseReference(java.lang.String agentName)
Releases a reference to the given agent, so that it must not be automatically updated anymore |
abstract void |
removeAgent(springs.agent.SpringsAgent agent,
boolean isMoving)
Removes an agent. |
void |
removeAgentInfo(java.lang.String agentName,
int seqNumber)
Removes the information for the given agent. |
void |
removeContext(java.lang.String cn)
Removes a context from the list of contexts in the system. |
void |
setContexts(java.util.Hashtable contexts)
Records the information about the contexts in the system. |
static void |
setPortClassServer(int port)
Sets the port for the class server. |
protected abstract void |
start(java.lang.String addressRNS)
Starts a context. |
protected abstract void |
start(java.lang.String addressRNS,
int portClassServer)
Starts a context. |
void |
stop()
Stops the context. |
abstract void |
updateRemoteReferences(java.util.Hashtable contextsToReferences)
Updates the remote references to local agents. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface springs.context.ContextInterfaceForAgents |
callAgentMethod, callAgentMethod, callAgentMethod, callAgentMethod, callAgentMethodAsynchronously, callAgentMethodAsynchronously, callAgentMethodAsynchronously, callAgentMethodAsynchronously, checkpoint, createAgent, deleteAgent, isSuspended, moveAgent, sendAgent, sendAsynchronousMessage, sendMessage, sendMessage, suspend |
Field Detail |
public static java.lang.String CONTEXT_LOG_FILENAME
public static boolean START_CLASS_SERVER
private static int _PORT_FOR_CLASS_SERVER
public static java.lang.String LOCALHOST
public static java.lang.String LOCALHOST_IP
public static springs.context.ContextAddress CONTEXT_ADDRESS_REGION_NAME_SERVER
protected static springs.context.Context _context
Context
protected springs.context.AgentInfos _agentInfos
AgentInfos
protected springs.access.AccessService _accessService
AccessService
protected springs.context.ContextAddress _contextAddress
ContextAddress
private java.util.Hashtable _contexts
Hashtable
private java.io.BufferedWriter _logFile
BufferedWriter
Constructor Detail |
public Context()
Method Detail |
public static void setPortClassServer(int port)
port
- the port.public static int getPortClassServer()
public static void initializeLocalIP()
public java.util.Vector getObservers(java.lang.String agentName)
public int getNumObservers(java.lang.String agentName)
public java.util.Vector getLocationServers(java.lang.String agentName)
public int getNumLocationServers(java.lang.String agentName)
public void logContextInfo()
public java.lang.String getContextStatus()
String
public void addAgentInfo(springs.agent.SpringsAgent agent)
agent
- the agent name.SpringsAgent
public void recordStartStay(java.lang.String agentName)
agentName
- the agent name.String
protected long getMillisStay(java.lang.String agentName)
agentName
- the agent name.
String
protected void ensureMinimumStayTime(java.lang.String agentName)
agentName
- the agent name.String
public void removeAgentInfo(java.lang.String agentName, int seqNumber)
agentName
- the name of the agent.seqNumber
- the sequence number for this delete.String
public springs.agent.SpringsAgent getAgent(java.lang.String agentName)
agentName
- the name of the agent.
SpringsAgent
public int getNumTrackedAndObservedAgents()
public int getNumAgents()
public springs.access.AgentReference getReferenceToLocalAgent(java.lang.String agentName, boolean addAsObserver)
agentName
- the name of the agent.addAsObserver
- a boolean indicating whether the requester should add itself as an
observer.
AgentReferenceException
- if error.AgentReference
,
String
,
AgentReferenceException
private springs.access.AgentReference createAgentReference(springs.agent.SpringsAgent agent)
agent
- the agent.
AgentReference
,
SpringsAgent
public int getNumContexts()
public void setContexts(java.util.Hashtable contexts)
contexts
- a table consisting of pairs Hashtable
public java.util.Collection getContexts()
Collection
public void addContext(springs.context.ContextAddress context)
context
- the context.ContextAddress
public void removeContext(java.lang.String cn)
cn
- the name of the context.String
,
RemoteException
public springs.context.ContextAddress getContextAddress(java.lang.String contextName)
ContextAddress
,
String
public java.lang.String getName()
String
public springs.context.ContextAddress getContextAddress()
getContextAddress
in interface ContextInterfaceForAgents
ContextAddress
public springs.access.AccessService getAccessService()
AccessService
protected static boolean isLocalContext(springs.context.ContextAddress addr)
addr
- the address.
ContextAddress
public void referenceUsed(java.lang.String agentName)
agentName
- the name of the agent.String
public void stop() throws ContextStoppingException
ContextStoppingException
- if the context cannot be stopped.ContextStoppingException
public void createAgent(java.lang.String targetContext, springs.agent.SpringsAgent agent, java.lang.String agentName) throws CreationException
targetContext
- the name of the target context.agent
- the agent.agentName
- the name of the agent.
CreationException
- if error.CreationException
public abstract springs.context.ContextManager getContextManager(springs.context.ContextAddress contextAddress) throws CommunicationException
contextAddress
- the context address.
CommunicationException
- if error.ContextAddress
,
ContextManager
,
CommunicationException
protected abstract void start(java.lang.String addressRNS) throws ContextStartingException
addressRNS
- the address of the Region Name Server. If any, pass null.
ContextStartingException
- if the context cannot be started.String
,
ContextStartingException
protected abstract void start(java.lang.String addressRNS, int portClassServer) throws ContextStartingException
addressRNS
- the address of the Region Name Server. If any, pass null.portClassServer
- the port where to launch the class server.
ContextStartingException
- if the context cannot be started.String
,
ContextStartingException
public abstract void updateRemoteReferences(java.util.Hashtable contextsToReferences) throws CommunicationException
contextsToReferences
- a table that maps from contexts to information about how
to update the references.
CommunicationException
- if error.Hashtable
,
CommunicationException
public abstract void releaseReference(java.lang.String agentName) throws ContextException
agentName
- the name of the agent.
ContextException
- if error.AgentReference
,
String
,
ContextException
public abstract void removeAgent(springs.agent.SpringsAgent agent, boolean isMoving) throws RemovalException
agent
- the agent.isMoving
- a boolean indicating if the agent is sent because of a movement from another
context.
throws
- RemovalException if error.
RemovalException
SpringsAgent
,
RemovalException
protected java.lang.String getStringForReferenceUpdates(java.util.Vector referenceUpdates)
referenceUpdates
- the updates.
String
,
Vector
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |