org.iids.aos.agentserver.java
Class JavaAgentRunner

java.lang.Object
  extended by org.iids.aos.systemservices.module.AbstractModule
      extended by org.iids.aos.agentserver.AgentRunner
          extended by org.iids.aos.agentserver.java.JavaAgentRunner
All Implemented Interfaces:
Module

public class JavaAgentRunner
extends AgentRunner

Author:
hidde

Nested Class Summary
static class JavaAgentRunner.MyURLClassLoader
          Deprecated. 
 
Field Summary
static java.lang.String AGENT_LANGUAGE_JAVA
           
 
Fields inherited from class org.iids.aos.agentserver.AgentRunner
agents, communicator, config, handles, hostManagerWrapper, lookupService, neglib, running, servletModule, wsGatewayModule
 
Constructor Summary
JavaAgentRunner(AsCommunicator communicator, AgentScapeConfig config, AsLookupService lookupService, AgentServer2WSGatewayModule wsGatewayModule, AgentRunnerServletModule servletModule)
           
 
Method Summary
 void backupLog(AgentID id)
           
 int getAgentCPUtime(AgentID agentID)
          Obtains the agentwrapper for the agent, and returns the value of the thread time_on_cpu for this agent.
 JavaAgentWrapper getEntry(AgentID id)
          Obtain agent wrapper for a given agent.
 AgentLog getFinishedAgentLog(AgentID id)
           
 java.util.Set<AgentID> getFinishedAgents()
           
static java.lang.String getJavaLanguage()
           
 java.lang.String getLanguage()
          Return a string with the language type of agents that can be run by this agent server.
 JavaAgentSecurityManager getSecurityManager()
           
 void removeAgent(AgentID agentId)
          Remove agent from the agent runner.
 void shutdown()
           
 void startAgent(AgentID agentId, java.lang.String[] args)
          Start agent from agent container.
 void suspendAgent(AgentID agentId)
          Suspend and, if supported, serialize state of a running agent.
 
Methods inherited from class org.iids.aos.agentserver.AgentRunner
createDefaultAgentLease, createDefaultAgentLease, doHttpRequest, finalize, getAgentCPUtime, getAgentId, getAgents, getAgentServerAddress, getAgentServerId, getCommunicator, getNegotiationLib, isStarted, killAgent, killAgent, removeAgent, setHostManagerWrapper, start, stop
 
Methods inherited from class org.iids.aos.systemservices.module.AbstractModule
getModuleName
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AGENT_LANGUAGE_JAVA

public static final java.lang.String AGENT_LANGUAGE_JAVA
See Also:
Constant Field Values
Constructor Detail

JavaAgentRunner

public JavaAgentRunner(AsCommunicator communicator,
                       AgentScapeConfig config,
                       AsLookupService lookupService,
                       AgentServer2WSGatewayModule wsGatewayModule,
                       AgentRunnerServletModule servletModule)
Method Detail

getFinishedAgentLog

public AgentLog getFinishedAgentLog(AgentID id)

getFinishedAgents

public java.util.Set<AgentID> getFinishedAgents()

getSecurityManager

public JavaAgentSecurityManager getSecurityManager()

startAgent

public void startAgent(AgentID agentId,
                       java.lang.String[] args)
                throws AgentIDUnknownException,
                       AgentStartupException
Description copied from class: AgentRunner
Start agent from agent container.

The agent is supposed to be already registered with the registration service. The runner takes care of reading the code segment(s) from the container and doing agent startup.

Specified by:
startAgent in class AgentRunner
Parameters:
agentId - ID of the agent the will be associated with the running agent.
args - Optional (may be null or empty) initialization arguments for the agent.
Throws:
AgentIDUnknownException
AgentStartupException

suspendAgent

public void suspendAgent(AgentID agentId)
                  throws AgentIDUnknownException,
                         AgentSuspendException
Description copied from class: AgentRunner
Suspend and, if supported, serialize state of a running agent.

After an agent is suspended, it can be (re) moved. The most recent state of the agent is now supposed to be stored in the agent container, so the agent can be safely migrated.

Specified by:
suspendAgent in class AgentRunner
Throws:
AgentIDUnknownException
AgentSuspendException

backupLog

public void backupLog(AgentID id)
               throws AgentIDUnknownException
Throws:
AgentIDUnknownException

getEntry

public JavaAgentWrapper getEntry(AgentID id)
                          throws AgentIDUnknownException
Description copied from class: AgentRunner
Obtain agent wrapper for a given agent.

Overrides:
getEntry in class AgentRunner
Throws:
AgentIDUnknownException

removeAgent

public void removeAgent(AgentID agentId)
                 throws AgentIDUnknownException
Description copied from class: AgentRunner
Remove agent from the agent runner.

If the agent (process) is still running, it is to be terminated, if this is supported by the language.

Note that this function does not (need to) remove the agent from the location (deregistration), which is done via the host manager. When you want to completely remove an agent, you can use the AgentRunner.killAgent(org.iids.aos.systemservices.communicator.structs.AgentID) function, which implicitly calls this removeAgent function.

TODO: think about exceptions.

Specified by:
removeAgent in class AgentRunner
Parameters:
agentId - ID of the agent to be removed.
Throws:
AgentIDUnknownException

getJavaLanguage

public static java.lang.String getJavaLanguage()

getLanguage

public java.lang.String getLanguage()
Description copied from class: AgentRunner
Return a string with the language type of agents that can be run by this agent server. This is useful so that any part of the system can ask any agent server which agent language it is capable of running.

Specified by:
getLanguage in class AgentRunner

getAgentCPUtime

public int getAgentCPUtime(AgentID agentID)
Obtains the agentwrapper for the agent, and returns the value of the thread time_on_cpu for this agent. The value is measured in nanoseconds, but as not all OS-es can deliver that resolution, the value is returned in millisecond resolution by this method. NOTE: the value could be 0 and unchanging if the JVM does not support the profiling calls required to obtain this information. This cannot be detected at this level.

Overrides:
getAgentCPUtime in class AgentRunner
Parameters:
agentID -
Returns:
int milliseconds on cpu for this thread, -1 in case of failure.

shutdown

public void shutdown()
Specified by:
shutdown in class AgentRunner


Copyright © 2003, 2004 IIDS Group. All Rights Reserved.