org.iids.aos.hostmanager
Class AgentContainerManager

java.lang.Object
  extended by org.iids.aos.systemservices.module.AbstractModule
      extended by org.iids.aos.hostmanager.AgentContainerManager
All Implemented Interfaces:
Module

public class AgentContainerManager
extends AbstractModule

AgentContainer manager.

There is one manager object for each agent/container. It mediates all access to the agent stores. Offers functionality like adding/removing stores and modifying store data. Data in the container of an agent is immediately stored in the agent container and carried along upon migration.

The AgentScape notion of an AgentContainer is more or less the same as the kernel notion of it, except for the fact that all meta information of an agent is also stored in the agent container. The AOS kernel does not interpret the container in any way, but AgentScape does. So each manager object also maintains some extra information on the agent container. Extracting this information from the AC takes time, so this information is cached by the container manager. It is therefore important that this cache is flushed to the AC before attempting to finalize the agent container.

Note: objects such as the LifeCycleModule now manipulate the agent container directly (for reading and writing meta segments as well as finalizing and shipping the agent container). All AC manipulation should be made part of the AC manager, so that we do not run into cache inconsistencies.

Author:
rjtimmer

Field Summary
protected  Cookie cookie
           
protected  Address incomingAddress
           
protected  KernelClient kernel
           
 
Method Summary
 boolean checkAgent(AgentID id)
          Check whether agent container exists.
 AgentHandle createAgentHandle(AgentID id)
           
 AgentCodeSegment createCodeSegment(AgentID id, java.lang.String desc, Language lang)
          Deprecated. 
 AgentDataSegment createDataSegment(AgentID id, java.lang.String desc, java.lang.String subt)
          Deprecated. 
 void deleteCode(AgentID id, AgentCodeSegment code)
           
 void deleteData(AgentID id, AgentDataSegment data)
           
 AgentCodeSegment[] getCodeSegments(AgentID id)
           
 AgentDataSegment[] getDataSegments(AgentID id)
           
 AgentCodeSegment getDefaultCodeSegment(AgentID id)
           
 boolean isStarted()
           
 boolean mustCollect(AgentID id)
           
 byte[] readCode(AgentID id, AgentCodeSegment code)
           
 byte[] readData(AgentID id, AgentDataSegment data)
           
 void removeAgentHandle(AgentID id, AgentHandle ah)
           
 void setCollect(AgentID id)
           
 void setDefaultCodeSegment(AgentID id, AgentCodeSegment code)
          Sets the default code segment.
 void start()
           
 void stop()
           
 void writeCode(AgentID id, AgentCodeSegment code, byte[] bytes)
           
 void writeData(AgentID id, AgentDataSegment data, byte[] bytes)
           
 
Methods inherited from class org.iids.aos.systemservices.module.AbstractModule
getCommunicator, getModuleName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

kernel

protected KernelClient kernel

cookie

protected Cookie cookie

incomingAddress

protected Address incomingAddress
Method Detail

checkAgent

public boolean checkAgent(AgentID id)
Check whether agent container exists.


createCodeSegment

@Deprecated
public AgentCodeSegment createCodeSegment(AgentID id,
                                                     java.lang.String desc,
                                                     Language lang)
                                   throws AgentIDUnknownException
Deprecated. 

Throws:
AgentIDUnknownException

createDataSegment

@Deprecated
public AgentDataSegment createDataSegment(AgentID id,
                                                     java.lang.String desc,
                                                     java.lang.String subt)
                                   throws AgentIDUnknownException
Deprecated. 

Throws:
AgentIDUnknownException

writeCode

public void writeCode(AgentID id,
                      AgentCodeSegment code,
                      byte[] bytes)
               throws AgentContainerException,
                      AgentIDUnknownException
Throws:
AgentContainerException
AgentIDUnknownException

writeData

public void writeData(AgentID id,
                      AgentDataSegment data,
                      byte[] bytes)
               throws AgentIDUnknownException,
                      AgentContainerException
Throws:
AgentIDUnknownException
AgentContainerException

readCode

public byte[] readCode(AgentID id,
                       AgentCodeSegment code)
                throws AgentIDUnknownException,
                       AgentContainerException
Throws:
AgentIDUnknownException
AgentContainerException

readData

public byte[] readData(AgentID id,
                       AgentDataSegment data)
                throws AgentIDUnknownException,
                       AgentContainerException
Throws:
AgentIDUnknownException
AgentContainerException

deleteCode

public void deleteCode(AgentID id,
                       AgentCodeSegment code)
                throws AgentIDUnknownException,
                       AgentContainerException
Throws:
AgentIDUnknownException
AgentContainerException

deleteData

public void deleteData(AgentID id,
                       AgentDataSegment data)
                throws AgentIDUnknownException,
                       AgentContainerException
Throws:
AgentIDUnknownException
AgentContainerException

getCodeSegments

public AgentCodeSegment[] getCodeSegments(AgentID id)
                                   throws AgentIDUnknownException
Throws:
AgentIDUnknownException

getDataSegments

public AgentDataSegment[] getDataSegments(AgentID id)
                                   throws AgentIDUnknownException
Throws:
AgentIDUnknownException

getDefaultCodeSegment

public AgentCodeSegment getDefaultCodeSegment(AgentID id)
                                       throws AgentIDUnknownException,
                                              AgentContainerException
Throws:
AgentIDUnknownException
AgentContainerException

setDefaultCodeSegment

public void setDefaultCodeSegment(AgentID id,
                                  AgentCodeSegment code)
                           throws AgentIDUnknownException,
                                  AgentContainerException
Sets the default code segment. This is not required when an agent has only one code segment, as the default only code segment is then the default.

Even if more code segments are available, the first one that was written to the agent is the default code segment. Use this only if you want to be sure.

Parameters:
id - AgentID of the AgentContainer to write to.
code - The code to write.
Throws:
AgentIDUnknownException - If the agent is not known by the AgentContainerManager
AgentContainerException - If there was an error updating the AgentContainer

createAgentHandle

public AgentHandle createAgentHandle(AgentID id)
                              throws AgentIDUnknownException
Throws:
AgentIDUnknownException

removeAgentHandle

public void removeAgentHandle(AgentID id,
                              AgentHandle ah)
                       throws AgentIDUnknownException
Throws:
AgentIDUnknownException

setCollect

public void setCollect(AgentID id)
                throws AgentIDUnknownException,
                       AgentContainerException
Throws:
AgentIDUnknownException
AgentContainerException

mustCollect

public boolean mustCollect(AgentID id)
                    throws AgentIDUnknownException
Throws:
AgentIDUnknownException

start

public void start()

stop

public void stop()

isStarted

public boolean isStarted()


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