org.iids.aos.agentserver.binary
Class BinaryAgentWrapper

java.lang.Object
  extended by org.iids.aos.agentserver.AgentWrapper
      extended by org.iids.aos.agentserver.binary.BinaryAgentWrapper

public class BinaryAgentWrapper
extends AgentWrapper

Agent wrapper for binary agents. Exists until the agent is done. If the agent process exits itself the resources (SunRPC dispatcher etc) are cleaned up automatically.

If a binary agent should be killed, it is also possible to manually terminate the agent using stop().

Author:
hidde

Field Summary
 
Fields inherited from class org.iids.aos.agentserver.AgentWrapper
agentHandle, locationId
 
Constructor Summary
BinaryAgentWrapper(AgentRunner parent, AgentHandle agentHandle)
           
 
Method Summary
protected  void finalize()
           
 boolean running()
           
 void setArgs(java.lang.String[] args)
           
 void setCode(byte[] code)
          Set the code to be executed by the agent process.
 void setPort(int port)
           
 void start()
          Start running the agent.
 void stop()
          Suspend running binary agent.
 void waitFor()
          Wait (blocking) for agent process to terminate.
 
Methods inherited from class org.iids.aos.agentserver.AgentWrapper
addMessage, getAgentHandle, getAgentStartTime, getContainerId, getLocationId, getMessage, isSuspended, setContainerId, setLocationId, setSuspended
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BinaryAgentWrapper

public BinaryAgentWrapper(AgentRunner parent,
                          AgentHandle agentHandle)
Method Detail

finalize

protected void finalize()
Overrides:
finalize in class java.lang.Object

setCode

public void setCode(byte[] code)
Set the code to be executed by the agent process.

Parameters:
code - The code to run. Assumed to be directly executable by a single call to Runtime.exec(java.lang.String).

setPort

public void setPort(int port)

setArgs

public void setArgs(java.lang.String[] args)

start

public void start()
Start running the agent. If possible, the agent is executed inside a jailed environment by means of the Jail class.

Specified by:
start in class AgentWrapper

running

public boolean running()

waitFor

public void waitFor()
Wait (blocking) for agent process to terminate. This function returns once the agent process stopped, either by exiting normally, or by calling stop() from another thread.


stop

public void stop()
Suspend running binary agent.

Note that this function should only be called by the agent server that started this agent, because the agent deregistration also needs to be done.

Only destroys the running process. State is still saved in the agent container (so recovery is possible)

When an agent needs to be completely removed and killed, refer to AgentRunner.removeAgent(org.iids.aos.systemservices.communicator.structs.AgentID).

Specified by:
stop in class AgentWrapper


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