org.iids.aos.agentserver.binary
Class BinaryAgentRunner

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

public class BinaryAgentRunner
extends AgentRunner

Implementation of an AgentRunner for binary agents.

Binary agents are supported through this agent runner. Each binary agent runs as a separate processes outside the JVM, with the regular user priviliges.

To allow the agent to interact with AgentScape, the agent must have some client-side stub which it can use for communication. For each binary agent a separate SunRPC dispatcher instance is created, exclusively for the respective agent. The dispatcher implementation for this binary agent runner is in AgentScapeApiSunrpcDispatcher.

Running as a separate process means an agent has full access to the parts of the system that the user has. The system cannot be protected from Non-Java agents with Java security managers. Therefore, it is possible to run an agent inside a Jail to prevent it from unprivileged access.

Monitoring the state and interaction with a running agent (such as sending messages) is done by means of an AgentWrapper, more specifically by BinaryAgentWrapper.

Author:
rjtimmer

Field Summary
 
Fields inherited from class org.iids.aos.agentserver.AgentRunner
agents, communicator, config, handles, hostManagerWrapper, lookupService, neglib, running, servletModule, wsGatewayModule
 
Constructor Summary
BinaryAgentRunner(AsCommunicator communicator, AgentScapeConfig config, AsLookupService lookupService, AgentServer2WSGatewayModule wsGatewayModule)
           
 
Method Summary
static java.lang.String getBinaryLanguage()
           
 java.lang.String getLanguage()
          Return a string with the language type of agents that can be run by this agent server.
 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, getAgentCPUtime, getAgentId, getAgents, getAgentServerAddress, getAgentServerId, getCommunicator, getEntry, 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
 

Constructor Detail

BinaryAgentRunner

public BinaryAgentRunner(AsCommunicator communicator,
                         AgentScapeConfig config,
                         AsLookupService lookupService,
                         AgentServer2WSGatewayModule wsGatewayModule)
Method Detail

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

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

getBinaryLanguage

public static java.lang.String getBinaryLanguage()

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

shutdown

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


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