|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface HostManager
HostManager systemservice interface.
Interface published for all host manager services. Calls to a HostManager
usually go through a dynamic proxy, AgentScape uses the communicator
SystemServiceProxy,
an instance of which is usually created by binding to it using
AsCommunicator.bind(java.lang.Class, org.iids.aos.systemservices.communicator.structs.Address)
or by obtaining the reference from the AgentScape lookup cache, using
LookupCache.
The implementation of the host manager interface is done by various classes
in the org.iids.aos.hostmanager package. Each class that implements
a host manager method, publishes this method using the method
Communicator.publish(org.iids.aos.systemservices.communicator.InterfaceMethod).
Note that the communicator does not suppor overloading, so each method in this interface should have a unique name (I guess).
| Nested Class Summary | |
|---|---|
static class |
HostManager.AgentStatus
|
| Field Summary | |
|---|---|
static java.lang.String |
LOOKUP_REGISTRATION_NAME
|
| 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 lang)
Deprecated. It is no longer needed to create a code segment before writing to it. Once a call to write_code(org.iids.aos.systemservices.communicator.structs.AgentID, org.iids.aos.agent.AgentCodeSegment, byte[]) was successful, a segment with
description and Language exist on this host for this agent. |
AgentDataSegment |
create_data_segment(AgentID id,
java.lang.String desc,
java.lang.String type)
Deprecated. It is no longer needed to create a data segment before writing to it. Once a call to write_data(org.iids.aos.systemservices.communicator.structs.AgentID, org.iids.aos.agent.AgentDataSegment, byte[]) was successful, a segment with
description and subtype exist on this host for this agent. |
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 id,
java.util.Collection<AgentHandle> handles,
boolean block)
Get a single pending message for an agent. |
java.util.List<Envelope> |
get_messages(AgentID id,
java.util.Collection<AgentHandle> handles,
boolean block)
Gat all pending messages for an agent. |
java.util.Map<AgentScapeID,SystemServiceInfo> |
get_service_id_list()
|
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 destinationLocationId)
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. |
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 handle,
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 |
start_agent(AgentID agentId,
boolean collect,
java.lang.String[] args)
Start running an agent on this host. |
int |
start_agentscape_api()
Deprecated. I think this function is never used anymore! The only implementation of this function (in SystemServiceModule.startAgentScapeApi())
does not do anything! --rjtimmer |
int |
start_agentserver(AgentScapeID agentserverID,
Specifications serverSpecifications)
Start an agentserver of the type specified in the Specifications. |
void |
start_service(Specifications specifications)
XXX NEW XXX Start a service in the host manager. |
void |
suspend_agent(AgentID agentId)
Suspend agent state to agent container. |
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 interface org.iids.aos.systemservices.SystemService |
|---|
pingService, shutdown, unbind |
| Field Detail |
|---|
static final java.lang.String LOOKUP_REGISTRATION_NAME
| Method Detail |
|---|
void create_agent(AgentID agentID,
java.lang.String leaseIdentifier)
throws AgentCreationException
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.
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.
AgentCreationException - If the agent cannot be created on this host.
void start_agent(AgentID agentId,
boolean collect,
java.lang.String[] args)
throws AgentIDUnknownException,
AgentStartupException
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.
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 wait_for_agent(org.iids.aos.systemservices.communicator.structs.AgentID, boolean).
AgentIDUnknownException - If agentID is unknown to this host.
AgentStartupException - If there is a problem executing the agent code.
void suspend_agent(AgentID agentId)
throws AgentIDUnknownException,
AgentSuspendException
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 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.
agentId - AgentID of the agent to be suspended.
AgentIDUnknownException - If agentID is unknown to this host manager.
AgentSuspendException - If the agent cannot be suspended.
void kill_agent(AgentID agentId)
throws AgentIDUnknownException
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.
agentId - The AgentID of the agent to be killed.
AgentIDUnknownException - If agentId was not running on this host.java.util.List<AgentID> list_agents()
boolean hosts_agent(AgentID agentId)
agentId - The AgentID of the agent to check.
AgentHandle create_agent_handle(AgentID id)
throws AgentIDUnknownException
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.
id - AgentID of the agent to create a new handle for.
AgentHandle to be used for communication.
AgentIDUnknownException - If the agent is not known on this host.
java.util.List<Envelope> remove_agent_handle(AgentID id,
AgentHandle handle,
boolean pickup)
throws AgentIDUnknownException
id - ID of the agenthandle - The AgentHandle to removepickup - If true then all pending undelivered messages
are returned. Otherwise they are discarded.
AgentIDUnknownException
java.util.List<AgentHandle> get_agent_handles(AgentID id)
throws AgentIDUnknownException
Administrative call, should not be possible to be called from parties other than the agent, its owner, or perhaps the the location administrator.
id - AgentID of the agent to list handles for.
AgentIDUnknownException - If the agent is not known on this host.
int register_systemservice(AgentScapeID serviceId,
java.lang.String serviceType,
Address address,
Specifications specs)
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.
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? -- rjtimmeraddress - Communication endpoint to contact the system service.specs - System service specifications.int deregister_systemservice(AgentScapeID serviceId)
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!
serviceId - AgentScapeID of the service to remove.
int start_agentserver(AgentScapeID agentserverID,
Specifications serverSpecifications)
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.
void start_service(Specifications specifications)
throws StartupException
StartupException@Deprecated int start_agentscape_api()
SystemServiceModule.startAgentScapeApi())
does not do anything! --rjtimmer
void migration_request(AgentID agentId,
java.lang.String leaseIdentifier,
AgentScapeID destinationLocationId)
throws MigrationFailedException
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.
agentId - The AgentID of the agent to migrate.leaseIdentifier - Pre-established lease, containing host and agentserver information
of target.destinationLocationId - The AgentScapeID of the target location.
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.
MigrationEndpoint handle_migration(AgentID agentId,
java.lang.String leaseIdentifier,
Address requestingAddress)
throws MigrationFailedException
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.
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.
MigrationFailedException - If for some reason the host manager cannot grant the request.
void migration_status(MigrationID mid,
boolean status)
throws MigrationFailedException
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.
mid - The unique MigrationID associated with this migration.status - Indicates either a failure of the migration (false) or success (true)
MigrationFailedException - If MigrationID or agent is unknown on this host manager.
Address get_agent_server(AgentID id)
throws AgentIDUnknownException
id - The AgentID of the agent to look up.
AgentIDUnknownException - If the AgentID is not hosted here.TemplateList requestTemplates()
AgreementOffer requestLease(AgreementOffer leaseRequest)
AgreementOffer acceptLease(java.lang.String leaseIdentifier)
void rejectLease(java.lang.String leaseIdentifier)
AgreementOffer requestLeaseStatus(java.lang.String leaseIdentifier)
java.lang.String pingString()
void pingVoid()
@Deprecated
AgentCodeSegment create_code_segment(AgentID id,
java.lang.String desc,
Language lang)
throws AgentIDUnknownException
write_code(org.iids.aos.systemservices.communicator.structs.AgentID, org.iids.aos.agent.AgentCodeSegment, byte[]) was successful, a segment with
description and Language exist on this host for this agent.
AgentIDUnknownException
@Deprecated
AgentDataSegment create_data_segment(AgentID id,
java.lang.String desc,
java.lang.String type)
throws AgentIDUnknownException
write_data(org.iids.aos.systemservices.communicator.structs.AgentID, org.iids.aos.agent.AgentDataSegment, byte[]) was successful, a segment with
description and subtype exist on this host for this agent.
AgentIDUnknownException
void write_code(AgentID id,
AgentCodeSegment code,
byte[] bytes)
throws AgentContainerException,
AgentIDUnknownException
code.
Each code segment has a unique AgentCodeSegment description.
After a call to 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 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.
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.
AgentContainerException - Problem writing code to the agent container.
AgentIDUnknownException - If the AgentID id is not located on this host.
void write_data(AgentID id,
AgentDataSegment data,
byte[] bytes)
throws AgentIDUnknownException,
AgentContainerException
data.
Each data segment has a unique AgentDataSegment description.
After a call to 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 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.
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.
AgentContainerException - Problem writing data to the agent container.
AgentIDUnknownException - If the AgentID id is not located on this host.
byte[] read_code(AgentID id,
AgentCodeSegment code)
throws AgentIDUnknownException,
AgentContainerException
id - The AgentID to read the segment from.code - Description of the code segment to read.
AgentIDUnknownException - If the agent is not known on this host.
AgentContainerException - If the segment cannot be read from the agent container.
byte[] read_data(AgentID id,
AgentDataSegment data)
throws AgentIDUnknownException,
AgentContainerException
id - The AgentID to read the segment from.data - Description of the data segment to read.
AgentIDUnknownException - If the agent is not known on this host.
AgentContainerException - If the segment cannot be read from the agent container.
void delete_code(AgentID id,
AgentCodeSegment code)
throws AgentIDUnknownException,
AgentContainerException
After this call, the code segment will not be available in the agent container for this agent.
id - The AgentID of the agent to delete the segment from.code - Description of the code segment to delete.
AgentIDUnknownException - If the agent is not known on this host.
AgentContainerException - If the segment cannot be removed from the agent container.
void delete_data(AgentID id,
AgentDataSegment data)
throws AgentIDUnknownException,
AgentContainerException
After this call, the data segment will not be available in the agent container for this agent.
id - The AgentID of the agent to delete the segment from.data - Description of the data segment to delete.
AgentIDUnknownException - If the agent is not known on this host.
AgentContainerException - If the segment cannot be removed from the agent container.
AgentCodeSegment[] get_code_segments(AgentID id)
throws AgentIDUnknownException
id - The AgentID of the agent to obtain the code segment list.
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.
AgentIDUnknownException - If the agent is not known on this host.
AgentDataSegment[] get_data_segments(AgentID id)
throws AgentIDUnknownException
id - The AgentID of the agent to obtain the dat segment list.
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.
AgentIDUnknownException - If the agent is not known on this host.
AgentCodeSegment get_default_code_segment(AgentID id)
throws AgentIDUnknownException,
AgentContainerException
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.
id - The AgentID of the agent to obtain the default code segment
from.
read_code(org.iids.aos.systemservices.communicator.structs.AgentID, org.iids.aos.agent.AgentCodeSegment).
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.
void set_default_code_segment(AgentID id,
AgentCodeSegment code)
throws AgentIDUnknownException,
AgentContainerException
During its lifetime, an agent can change its default code segment. This
code segment will be used once the agent is started
(start_agent(org.iids.aos.systemservices.communicator.structs.AgentID, boolean, java.lang.String[])) or after migration (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.
id - The AgentID of the agent to set the default code segment.code - The description of the default code segment to set.
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).
AgentArchive wait_for_agent(AgentID id,
boolean pickup)
throws AgentIDUnknownException,
AgentContainerException
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.
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.
AgentArchive containing segments that were in the agent
container of the agent at the moment it was killed.
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.
AgentArchive export_agent(AgentID id)
throws AgentIDUnknownException,
AgentContainerException
AgentIDUnknownException
AgentContainerExceptionAgentScapeApi.exportAgent(org.iids.aos.systemservices.communicator.structs.AgentHandle)
void put_message(Envelope message,
boolean canForward)
throws MessageException
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.
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.
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.
void put_messages(java.util.List<Envelope> messages,
boolean canForward)
throws MessageException
MessageException
Envelope get_message(AgentID id,
java.util.Collection<AgentHandle> handles,
boolean block)
throws AgentUnknownException,
AgentIDUnknownException
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)
id - The agent to pickup messages for.block - If there are no messages, wait until one arrives if the value of this
parameter is true.
AgentIDUnknownException - If the agent is not known on this host.
AgentUnknownException - If any of the handles is unknown
java.util.List<Envelope> get_messages(AgentID id,
java.util.Collection<AgentHandle> handles,
boolean block)
throws AgentUnknownException,
AgentIDUnknownException
Same as get_message(org.iids.aos.systemservices.communicator.structs.AgentID, java.util.Collection, 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)
id - The agent to pickup messages for.block - If there are no messages, wait until one arrives if the value of this
parameter is true.
AgentIDUnknownException - If the agent is not known on this host.
AgentUnknownException - If any of the handles is unknown.java.util.Map<AgentScapeID,SystemServiceInfo> get_service_id_list()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||