org.iids.aos.hostmanager
Class LocalHostManager

java.lang.Object
  extended by org.iids.aos.systemservices.LocalSystemService
      extended by org.iids.aos.hostmanager.LocalHostManager
All Implemented Interfaces:
HostManager, SystemService

public class LocalHostManager
extends LocalSystemService
implements HostManager


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.iids.aos.systemservices.HostManager
HostManager.AgentStatus
 
Field Summary
 
Fields inherited from interface org.iids.aos.systemservices.HostManager
LOOKUP_REGISTRATION_NAME
 
Constructor Summary
LocalHostManager(HostManager parent, LifeCycleModule lm, AgentContainerManager acm, AgentRegistrationModule arm, SystemServiceModule ssm, AgentScapeHMNegotiationModule neg, MessageCenter mc)
           
 
Method Summary
 AgreementOffer acceptLease(java.lang.String leaseIdentifier)
           
 AgentHandle create_agent_handle(AgentID id)
          Create a new handle for an agent.
 void create_agent(AgentID agentID, java.lang.String leaseIdentifier)
          Create a new agent on this host.
 AgentCodeSegment create_code_segment(AgentID id, java.lang.String desc, Language l)
          Deprecated. 
 AgentDataSegment create_data_segment(AgentID id, java.lang.String desc, java.lang.String type)
          Deprecated. 
 void delete_code(AgentID id, AgentCodeSegment code)
          Remove code segment from agent container.
 void delete_data(AgentID id, AgentDataSegment data)
          Remove data segment from agent container.
 int deregister_systemservice(AgentScapeID serviceId)
          Deregister a system service from the host manager.
 AgentArchive export_agent(AgentID id)
          Export agent container.
 java.util.List<AgentHandle> get_agent_handles(AgentID id)
          Obtain a list of all handles registered to an id.
 Address get_agent_server(AgentID id)
          Obtain AgentServer address belonging to agent

 AgentCodeSegment[] get_code_segments(AgentID id)
          Obtain a list of all code segments of this agent.
 AgentDataSegment[] get_data_segments(AgentID id)
          Obtain a list of all data segments of this agent.
 AgentCodeSegment get_default_code_segment(AgentID id)
          Obtain description of the default code segment for this agent.
 Envelope get_message(AgentID fromID, java.util.Collection<AgentHandle> handles, boolean block)
          Get a single pending message for an agent.
 java.util.List<Envelope> get_messages(AgentID fromID, java.util.Collection<AgentHandle> handles, boolean block)
          Gat all pending messages for an agent.
 java.util.Map<AgentScapeID,SystemServiceInfo> get_service_id_list()
           
static LocalHostManager get(Address address)
           
static LocalHostManager get(AgentScapeID id)
          Returns the local location manager with name id if it exists in this JVM.
static java.util.Map<AgentScapeID,LocalHostManager> getAll()
           
 MigrationEndpoint handle_migration(AgentID agentId, java.lang.String leaseIdentifier, Address requestingAddress)
          Instruct this host manager to create an endpoint for an agent, and expect to receive an agent on this endpoint.
 boolean hosts_agent(AgentID agentId)
          Query host manager to see if a certain agent is located there.
 void kill_agent(AgentID agentId)
          Instructs host manager to kill an agent.
 java.util.List<AgentID> list_agents()
          List AgentIDs of all agents running on this particular host.
 void migration_request(AgentID agentId, java.lang.String leaseIdentifier, AgentScapeID destination)
          Request and perform migration of an agent to a remote location.
 void migration_status(MigrationID mid, boolean status)
          Report back migration status to the source host manager of an agent.
 void pingService()
           
 java.lang.String pingString()
           
 void pingVoid()
           
 void put_message(Envelope message, boolean canForward)
          Put a message in the message queue for an agent.
 void put_messages(java.util.List<Envelope> messages, boolean canForward)
           
 byte[] read_code(AgentID id, AgentCodeSegment code)
          Read bytes from code segment.
 byte[] read_data(AgentID id, AgentDataSegment data)
          Read bytes from data segment.
 int register_systemservice(AgentScapeID serviceId, java.lang.String serviceType, Address address, Specifications specs)
          Register a system service (eg an agent server) with this host manager.
 void rejectLease(java.lang.String leaseIdentifier)
           
 java.util.List<Envelope> remove_agent_handle(AgentID id, AgentHandle ah, boolean pickup)
          Remove handle from an agent.
 AgreementOffer requestLease(AgreementOffer leaseRequest)
           
 AgreementOffer requestLeaseStatus(java.lang.String leaseIdentifier)
           
 TemplateList requestTemplates()
           
 void set_default_code_segment(AgentID id, AgentCodeSegment code)
          Set description of the default code segment for an agent.
 void shutdown()
           
 void start_agent(AgentID agentId, boolean collect, java.lang.String[] args)
          Start running an agent on this host.
 void start_agent(AgentID agentId, java.lang.String[] args)
           
 int start_agentscape_api()
          Deprecated. 
 int start_agentserver(AgentScapeID agentserverID, Specifications serverSpecifications)
          Start an agentserver of the type specified in the Specifications.
 void start_service(Specifications spec)
          XXX NEW XXX Start a service in the host manager.
 void suspend_agent(AgentID agentId)
          Suspend agent state to agent container.
 void unbind()
           
 AgentArchive wait_for_agent(AgentID id, boolean pickup)
          Method to collect agent contents after an agent is done on this host.
 void write_code(AgentID id, AgentCodeSegment code, byte[] bytes)
          Write code segment with descritption and type information code.
 void write_data(AgentID id, AgentDataSegment data, byte[] bytes)
          Write data segment with descritption and type information data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocalHostManager

public LocalHostManager(HostManager parent,
                        LifeCycleModule lm,
                        AgentContainerManager acm,
                        AgentRegistrationModule arm,
                        SystemServiceModule ssm,
                        AgentScapeHMNegotiationModule neg,
                        MessageCenter mc)
Method Detail

create_agent

public void create_agent(AgentID agentID,
                         java.lang.String leaseIdentifier)
                  throws AgentCreationException
Description copied from interface: HostManager
Create a new agent on this host. The AgentServer is assumed to be already registered (the lease is already established).

This call creates a new agent container on this host, this container is associated with the AgentID used for this call, which is supposed to be assigned by the LocationManager.

Specified by:
create_agent in interface HostManager
Parameters:
agentID - AgentID of the newly created agent, this ID is created by the location manager before creating the agent container on the host manager.
leaseIdentifier - Lease identifier indicating which resources (agent server) is to be running the agent once it is started.
Throws:
AgentCreationException - If the agent cannot be created on this host.

start_agent

public void start_agent(AgentID agentId,
                        java.lang.String[] args)
                 throws AgentIDUnknownException,
                        AgentStartupException
Throws:
AgentIDUnknownException
AgentStartupException

start_agent

public void start_agent(AgentID agentId,
                        boolean collect,
                        java.lang.String[] args)
                 throws AgentIDUnknownException,
                        AgentStartupException
Description copied from interface: HostManager
Start running an agent on this host.

The agent should already be created on this host before calling this method. Once the agent is created, and the respective code segments are added to the agent container, the agent can be started with this method.

Specified by:
start_agent in interface HostManager
Parameters:
agentId - ID of the agent to start on this host.
collect - Indicate whether the result data (data and code segments) should be returned to the owner (true) or be discarded (false) once the agent finishes. If the data should be returend, this should be done using HostManager.wait_for_agent(org.iids.aos.systemservices.communicator.structs.AgentID, boolean).
Throws:
AgentIDUnknownException - If agentID is unknown to this host.
AgentStartupException - If there is a problem executing the agent code.

suspend_agent

public void suspend_agent(AgentID agentId)
                   throws AgentIDUnknownException,
                          AgentSuspendException
Description copied from interface: HostManager
Suspend agent state to agent container.

This function suspends the agent, which means that the agent state is automatically stored in the agent container, if this is supported by the agent server that runs the agent. The state of java agents can be automatically suspended to the agent container (using Serialization). Other types of agents (non-Java) will have to save their state manually to the agent container using the HostManager.write_data(org.iids.aos.systemservices.communicator.structs.AgentID, org.iids.aos.agent.AgentDataSegment, byte[]) functions.

Once an agent is succssfully suspended, it can be migrated.

Specified by:
suspend_agent in interface HostManager
Parameters:
agentId - AgentID of the agent to be suspended.
Throws:
AgentIDUnknownException - If agentID is unknown to this host manager.
AgentSuspendException - If the agent cannot be suspended.

kill_agent

public void kill_agent(AgentID agentId)
                throws AgentIDUnknownException
Description copied from interface: HostManager
Instructs host manager to kill an agent.

After this call, the AgentID for this agent is no longer valid. If the agent server that runs this agent supports this, the agent is also no longer running. Any handles and tokens beloning to this AgentID are no longer valid, and cannot be used anymore to access the API.

Specified by:
kill_agent in interface HostManager
Parameters:
agentId - The AgentID of the agent to be killed.
Throws:
AgentIDUnknownException - If agentId was not running on this host.

migration_request

public void migration_request(AgentID agentId,
                              java.lang.String leaseIdentifier,
                              AgentScapeID destination)
                       throws MigrationFailedException
Description copied from interface: HostManager
Request and perform migration of an agent to a remote location.

The complete migration process, requests the local host manager to contact its location manager to perform the migration. The remote location manager then selects a target host manager, which creates an endpoint for the agent to arrive. The agent is then sent to this remote endpoint.

Specified by:
migration_request in interface HostManager
Parameters:
agentId - The AgentID of the agent to migrate.
leaseIdentifier - Pre-established lease, containing host and agentserver information of target.
destination - The AgentScapeID of the target location.
Throws:
MigrationFailedException - If for some reason (local or remote) the migration request could not be completed, contains all different kinds of exceptions like target unknown, unable to start on remote site, etc.

handle_migration

public MigrationEndpoint handle_migration(AgentID agentId,
                                          java.lang.String leaseIdentifier,
                                          Address requestingAddress)
                                   throws MigrationFailedException
Description copied from interface: HostManager
Instruct this host manager to create an endpoint for an agent, and expect to receive an agent on this endpoint.

This is called by the target location manager of the migration process, to instruct one of its host managers that it can expect to receive an agent.

Specified by:
handle_migration in interface HostManager
Parameters:
agentId - The AgentID of the agent to be expected.
leaseIdentifier - Lease identifier indicating placement of agent on an agentserver on this host.
requestingAddress - Address of the host manager that will send the agent, this address is used to notify the sending host manager of completion of the transfer (either successful or not) once the agent container is transported.
Returns:
A MigrationEndpoint containing address information where the source host manager can migrate the agent to.
Throws:
MigrationFailedException - If for some reason the host manager cannot grant the request.

migration_status

public void migration_status(MigrationID mid,
                             boolean status)
                      throws MigrationFailedException
Description copied from interface: HostManager
Report back migration status to the source host manager of an agent.

This method is called by the receiving host manager on the sending host manager, to notify it that the migration procedure is finished. It can either notify the sending host of success or failure.

Specified by:
migration_status in interface HostManager
Parameters:
mid - The unique MigrationID associated with this migration.
status - Indicates either a failure of the migration (false) or success (true)
Throws:
MigrationFailedException - If MigrationID or agent is unknown on this host manager.

create_agent_handle

public AgentHandle create_agent_handle(AgentID id)
                                throws AgentIDUnknownException
Description copied from interface: HostManager
Create a new handle for an agent.

An AgentHandle is an alias for an agent. It can be used as a communication endpoint to and from that agent: other parties can send messages to a handle, and the agent itself can receive messages from the handle.

A handle cannot be resolved to an AgentID by any other party than the middleware, which allows for anonymous communication by agents. An agent can create an infinite amount of handles.

Specified by:
create_agent_handle in interface HostManager
Parameters:
id - AgentID of the agent to create a new handle for.
Returns:
New AgentHandle to be used for communication.
Throws:
AgentIDUnknownException - If the agent is not known on this host.

remove_agent_handle

public java.util.List<Envelope> remove_agent_handle(AgentID id,
                                                    AgentHandle ah,
                                                    boolean pickup)
                                             throws AgentIDUnknownException
Description copied from interface: HostManager
Remove handle from an agent.

Specified by:
remove_agent_handle in interface HostManager
Parameters:
id - ID of the agent
ah - The AgentHandle to remove
pickup - If true then all pending undelivered messages are returned. Otherwise they are discarded.
Returns:
A list with all unclaimed messages (if desired).
Throws:
AgentIDUnknownException

get_agent_handles

public java.util.List<AgentHandle> get_agent_handles(AgentID id)
                                              throws AgentIDUnknownException
Description copied from interface: HostManager
Obtain a list of all handles registered to an id.

Administrative call, should not be possible to be called from parties other than the agent, its owner, or perhaps the the location administrator.

Specified by:
get_agent_handles in interface HostManager
Parameters:
id - AgentID of the agent to list handles for.
Returns:
A list of all handles of the agent (including owner/primary handle).
Throws:
AgentIDUnknownException - If the agent is not known on this host.

create_code_segment

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

Description copied from interface: HostManager
Create a code segment for an agent present on this host.

Specified by:
create_code_segment in interface HostManager
Throws:
AgentIDUnknownException

create_data_segment

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

Description copied from interface: HostManager
Create a code segment for an agent present on this host.

Specified by:
create_data_segment in interface HostManager
Throws:
AgentIDUnknownException

write_code

public void write_code(AgentID id,
                       AgentCodeSegment code,
                       byte[] bytes)
                throws AgentContainerException,
                       AgentIDUnknownException
Description copied from interface: HostManager
Write code segment with descritption and type information code.

Each code segment has a unique AgentCodeSegment description. After a call to HostManager.write_code(org.iids.aos.systemservices.communicator.structs.AgentID, org.iids.aos.agent.AgentCodeSegment, byte[]) the code segment with description code now contains the data in bytes

A code segment that does not exist will not have to be created before calling this HostManager.write_code(org.iids.aos.systemservices.communicator.structs.AgentID, org.iids.aos.agent.AgentCodeSegment, byte[]) function: it will be created if it does not exist.

Specified by:
write_code in interface HostManager
Parameters:
id - The AgentID of the agent to write code for.
code - AgentCodeSegment containing description of the code segment to write.
bytes - Data to store in the code segment.
Throws:
AgentContainerException - Problem writing code to the agent container.
AgentIDUnknownException - If the AgentID id is not located on this host.

write_data

public void write_data(AgentID id,
                       AgentDataSegment data,
                       byte[] bytes)
                throws AgentIDUnknownException,
                       AgentContainerException
Description copied from interface: HostManager
Write data segment with descritption and type information data.

Each data segment has a unique AgentDataSegment description. After a call to HostManager.write_data(org.iids.aos.systemservices.communicator.structs.AgentID, org.iids.aos.agent.AgentDataSegment, byte[]) the data segment with description data now contains the data in bytes

A data segment that does not exist will not have to be created before calling this HostManager.write_data(org.iids.aos.systemservices.communicator.structs.AgentID, org.iids.aos.agent.AgentDataSegment, byte[]) function: it will be created if it does not exist.

Specified by:
write_data in interface HostManager
Parameters:
id - The AgentID of the agent to write data for.
data - AgentDataSegment containing description of the data segment to write.
bytes - Data to store in the data segment.
Throws:
AgentIDUnknownException - If the AgentID id is not located on this host.
AgentContainerException - Problem writing data to the agent container.

read_code

public byte[] read_code(AgentID id,
                        AgentCodeSegment code)
                 throws AgentIDUnknownException,
                        AgentContainerException
Description copied from interface: HostManager
Read bytes from code segment.

Specified by:
read_code in interface HostManager
Parameters:
id - The AgentID to read the segment from.
code - Description of the code segment to read.
Throws:
AgentIDUnknownException - If the agent is not known on this host.
AgentContainerException - If the segment cannot be read from the agent container.

read_data

public byte[] read_data(AgentID id,
                        AgentDataSegment data)
                 throws AgentIDUnknownException,
                        AgentContainerException
Description copied from interface: HostManager
Read bytes from data segment.

Specified by:
read_data in interface HostManager
Parameters:
id - The AgentID to read the segment from.
data - Description of the data segment to read.
Throws:
AgentIDUnknownException - If the agent is not known on this host.
AgentContainerException - If the segment cannot be read from the agent container.

delete_code

public void delete_code(AgentID id,
                        AgentCodeSegment code)
                 throws AgentIDUnknownException,
                        AgentContainerException
Description copied from interface: HostManager
Remove code segment from agent container.

After this call, the code segment will not be available in the agent container for this agent.

Specified by:
delete_code in interface HostManager
Parameters:
id - The AgentID of the agent to delete the segment from.
code - Description of the code segment to delete.
Throws:
AgentIDUnknownException - If the agent is not known on this host.
AgentContainerException - If the segment cannot be removed from the agent container.

delete_data

public void delete_data(AgentID id,
                        AgentDataSegment data)
                 throws AgentIDUnknownException,
                        AgentContainerException
Description copied from interface: HostManager
Remove data segment from agent container.

After this call, the data segment will not be available in the agent container for this agent.

Specified by:
delete_data in interface HostManager
Parameters:
id - The AgentID of the agent to delete the segment from.
data - Description of the data segment to delete.
Throws:
AgentIDUnknownException - If the agent is not known on this host.
AgentContainerException - If the segment cannot be removed from the agent container.

get_code_segments

public AgentCodeSegment[] get_code_segments(AgentID id)
                                     throws AgentIDUnknownException
Description copied from interface: HostManager
Obtain a list of all code segments of this agent.

Specified by:
get_code_segments in interface HostManager
Parameters:
id - The AgentID of the agent to obtain the code segment list.
Returns:
An array of all AgentCodeSegment objects that can be used for reading code segments of this agent. If the agent has no data segments, then this list will have 0 elements.
Throws:
AgentIDUnknownException - If the agent is not known on this host.

get_data_segments

public AgentDataSegment[] get_data_segments(AgentID id)
                                     throws AgentIDUnknownException
Description copied from interface: HostManager
Obtain a list of all data segments of this agent.

Specified by:
get_data_segments in interface HostManager
Parameters:
id - The AgentID of the agent to obtain the dat segment list.
Returns:
An array of all AgentDataSegment objects that can be used for reading data segments of this agent. If the agent has no data segments, then this list will have 0 elements.
Throws:
AgentIDUnknownException - If the agent is not known on this host.

get_default_code_segment

public AgentCodeSegment get_default_code_segment(AgentID id)
                                          throws AgentIDUnknownException,
                                                 AgentContainerException
Description copied from interface: HostManager
Obtain description of the default code segment for this agent.

Each agent has at most one default code segment, which is the code segment that will be executed once an agent is (re)started on a host. An agent can have possibly more than one code segment, though there can be at most one that is the default code segment.

Specified by:
get_default_code_segment in interface HostManager
Parameters:
id - The AgentID of the agent to obtain the default code segment from.
Returns:
The description of the code segment, which can be used to read the code segment if desired, using HostManager.read_code(org.iids.aos.systemservices.communicator.structs.AgentID, org.iids.aos.agent.AgentCodeSegment).
Throws:
AgentIDUnknownException - If the agent is not known on this host.
AgentContainerException - If the description of the default code segment cannot be obtained, or if there is no default code segment for this agent.

set_default_code_segment

public void set_default_code_segment(AgentID id,
                                     AgentCodeSegment code)
                              throws AgentIDUnknownException,
                                     AgentContainerException
Description copied from interface: HostManager
Set description of the default code segment for an agent.

During its lifetime, an agent can change its default code segment. This code segment will be used once the agent is started (HostManager.start_agent(org.iids.aos.systemservices.communicator.structs.AgentID, boolean, java.lang.String[])) or after migration (HostManager.migration_request(org.iids.aos.systemservices.communicator.structs.AgentID, java.lang.String, org.iids.aos.systemservices.communicator.structs.AgentScapeID)). Even though the default code segment can be changed many times over the course of the agent process/thread lifetime, its default code segment is only read when creating this process.

Specified by:
set_default_code_segment in interface HostManager
Parameters:
id - The AgentID of the agent to set the default code segment.
code - The description of the default code segment to set.
Throws:
AgentIDUnknownException - If the agent is not known on this host.
AgentContainerException - If the default code segment cannot be set (e.g. when such a segment does not yet exist in the agent container for this agent).

list_agents

public java.util.List<AgentID> list_agents()
Description copied from interface: HostManager
List AgentIDs of all agents running on this particular host.

Specified by:
list_agents in interface HostManager
Returns:
A list of agent IDs of all agents residing on this host.

hosts_agent

public boolean hosts_agent(AgentID agentId)
Description copied from interface: HostManager
Query host manager to see if a certain agent is located there.

Specified by:
hosts_agent in interface HostManager
Parameters:
agentId - The AgentID of the agent to check.
Returns:
A boolean indicating whether the agent is located on this host (true) or not (false).

register_systemservice

public int register_systemservice(AgentScapeID serviceId,
                                  java.lang.String serviceType,
                                  Address address,
                                  Specifications specs)
Description copied from interface: HostManager
Register a system service (eg an agent server) with this host manager.

After a system service is registered with the host manager, the host manager can order it to start agents (if it is an agent server) or what not. XXX The system service must have the host manager token in order to call this method. TODO this function has no exceptions, must be added.

Specified by:
register_systemservice in interface HostManager
Parameters:
serviceId - AgentScape system service ID of the service to register.
serviceType - Name/type of the service (e.g. "agentserver"). XXX same as specification value specs.SYSTEMSERVICE_TYPE methinks FIXME this parameter can be removed? -- rjtimmer
address - Communication endpoint to contact the system service.
specs - System service specifications.

deregister_systemservice

public int deregister_systemservice(AgentScapeID serviceId)
Description copied from interface: HostManager
Deregister a system service from the host manager.

TODO: make sure that the system service is not currently active (e.g. running any active agents) otherwise we will run into trouble!

TODO This method has no exceptions TODO add!

Specified by:
deregister_systemservice in interface HostManager
Parameters:
serviceId - AgentScapeID of the service to remove.

start_agentserver

public int start_agentserver(AgentScapeID agentserverID,
                             Specifications serverSpecifications)
Description copied from interface: HostManager
Start an agentserver of the type specified in the Specifications.

Called by LocationConfigurationModule.configureHost(org.iids.aos.systemservices.communicator.structs.AgentScapeID).

Specified by:
start_agentserver in interface HostManager
Parameters:
agentserverID - New ID of the agent server to start, this ID is assigned by the LocationConfigurationModule (in the location manager).
serverSpecifications - Specifications of the agent server to start.

start_service

public void start_service(Specifications spec)
                   throws StartupException
Description copied from interface: HostManager
XXX NEW XXX Start a service in the host manager. XXX Experimental XXX

Specified by:
start_service in interface HostManager
Throws:
StartupException

start_agentscape_api

@Deprecated
public int start_agentscape_api()
Deprecated. 

Description copied from interface: HostManager
Start running an API on this host manager.

Specified by:
start_agentscape_api in interface HostManager

requestTemplates

public TemplateList requestTemplates()
Specified by:
requestTemplates in interface HostManager

requestLease

public AgreementOffer requestLease(AgreementOffer leaseRequest)
Specified by:
requestLease in interface HostManager

acceptLease

public AgreementOffer acceptLease(java.lang.String leaseIdentifier)
Specified by:
acceptLease in interface HostManager

rejectLease

public void rejectLease(java.lang.String leaseIdentifier)
Specified by:
rejectLease in interface HostManager

requestLeaseStatus

public AgreementOffer requestLeaseStatus(java.lang.String leaseIdentifier)
Specified by:
requestLeaseStatus in interface HostManager

wait_for_agent

public AgentArchive wait_for_agent(AgentID id,
                                   boolean pickup)
                            throws AgentIDUnknownException,
                                   AgentContainerException
Description copied from interface: HostManager
Method to collect agent contents after an agent is done on this host.

The contents of the agent can be returned by this method once an agent stopped running on this host. This is only possible if the host where the agent was residing on did not migrate the agent to another host. Otherwise, this method will have to be called on the host manager where the agent migrated to.

Specified by:
wait_for_agent in interface HostManager
Parameters:
id - The AgentID of the agent to collect.
pickup - If true then returns the exported Agent once it is done, otherwise it will just return null once the agent finished.
Returns:
An AgentArchive containing segments that were in the agent container of the agent at the moment it was killed.
Throws:
AgentIDUnknownException - The agent is not known on this host. This can also mean that the agent migrated to another host. In this case, a lookup of the host address of the new agent location will have to be done, and this method will have to be called again on this new host.
AgentContainerException - Problem reading data from the agent container.

export_agent

public AgentArchive export_agent(AgentID id)
                          throws AgentIDUnknownException,
                                 AgentContainerException
Description copied from interface: HostManager
Export agent container.

Specified by:
export_agent in interface HostManager
Throws:
AgentIDUnknownException
AgentContainerException
See Also:
AgentScapeApi.exportAgent(org.iids.aos.systemservices.communicator.structs.AgentHandle)

put_message

public void put_message(Envelope message,
                        boolean canForward)
                 throws MessageException
Description copied from interface: HostManager
Put a message in the message queue for an agent.

If the destination agent is present on the host manager where this method is called on, it is appended to the message queue of this agent. Otherwise the message is sent to the appropriate message queue of the receiver.

Specified by:
put_message in interface HostManager
Parameters:
message - The contents and address info (from/to handles) of the message.
canForward - If the agent is not running on the host manager this method is called on, then the host manager will try to forward the message to a remote host. In order to prevent endless loops whenever an agent cannot be found (even though it is listed in the lookup service) the host only attempts to forward the message if the value of this parameter is true.
Throws:
MessageException - If sending an array of messages fails. The MessageException contains the index of the message that fails and the real exception as the cause. All messages after the exception has occurred will not have been sent; the ones before have been sent.

put_messages

public void put_messages(java.util.List<Envelope> messages,
                         boolean canForward)
                  throws MessageException
Specified by:
put_messages in interface HostManager
Throws:
MessageException

get_message

public Envelope get_message(AgentID fromID,
                            java.util.Collection<AgentHandle> handles,
                            boolean block)
                     throws AgentUnknownException,
                            AgentIDUnknownException
Description copied from interface: HostManager
Get a single pending message for an agent.

Pickup any message sent to this agent.

TODO: possibly add a select on agent handle, so that a receive on a single handle will not receive messages that are sent to another handle (even though that handle belongs to the same agent)

Specified by:
get_message in interface HostManager
Parameters:
fromID - The agent to pickup messages for.
block - If there are no messages, wait until one arrives if the value of this parameter is true.
Throws:
AgentUnknownException - If any of the handles is unknown
AgentIDUnknownException - If the agent is not known on this host.

get_messages

public java.util.List<Envelope> get_messages(AgentID fromID,
                                             java.util.Collection<AgentHandle> handles,
                                             boolean block)
                                      throws AgentUnknownException,
                                             AgentIDUnknownException
Description copied from interface: HostManager
Gat all pending messages for an agent.

Same as HostManager.get_message(org.iids.aos.systemservices.communicator.structs.AgentID, java.util.Collection, boolean), except that if there are multiple messages available, they are all returned.

TODO: possibly add a select on agent handle, so that a receive on a single handle will not receive messages that are sent to another handle (even though that handle belongs to the same agent)

Specified by:
get_messages in interface HostManager
Parameters:
fromID - The agent to pickup messages for.
block - If there are no messages, wait until one arrives if the value of this parameter is true.
Throws:
AgentUnknownException - If any of the handles is unknown.
AgentIDUnknownException - If the agent is not known on this host.

get_service_id_list

public java.util.Map<AgentScapeID,SystemServiceInfo> get_service_id_list()
Specified by:
get_service_id_list in interface HostManager

unbind

public void unbind()
Specified by:
unbind in interface SystemService

shutdown

public void shutdown()
Specified by:
shutdown in interface SystemService

get

public static LocalHostManager get(AgentScapeID id)
Returns the local location manager with name id if it exists in this JVM.

Parameters:
id - The location ID of the LocationManager interface.
Returns:
The LocalLocationManager of the location, if it exists. Otherwise this function returns null, which also indicates that the LocationManager for this location runs somewhere else.

get

public static LocalHostManager get(Address address)

getAll

public static java.util.Map<AgentScapeID,LocalHostManager> getAll()

pingService

public void pingService()
Specified by:
pingService in interface SystemService

pingString

public java.lang.String pingString()
Specified by:
pingString in interface HostManager

pingVoid

public void pingVoid()
Specified by:
pingVoid in interface HostManager

get_agent_server

public Address get_agent_server(AgentID id)
                         throws AgentIDUnknownException
Description copied from interface: HostManager
Obtain AgentServer address belonging to agent

Specified by:
get_agent_server in interface HostManager
Parameters:
id - The AgentID of the agent to look up.
Returns:
The Address of the server hosting the agent.
Throws:
AgentIDUnknownException - If the AgentID is not hosted here.


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