|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.iids.aos.systemservices.LocalSystemService
org.iids.aos.hostmanager.LocalHostManager
public class LocalHostManager
| 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 |
|---|
public LocalHostManager(HostManager parent,
LifeCycleModule lm,
AgentContainerManager acm,
AgentRegistrationModule arm,
SystemServiceModule ssm,
AgentScapeHMNegotiationModule neg,
MessageCenter mc)
| Method Detail |
|---|
public void create_agent(AgentID agentID,
java.lang.String leaseIdentifier)
throws AgentCreationException
HostManagerThis 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.
create_agent in interface HostManageragentID - 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.
public void start_agent(AgentID agentId,
java.lang.String[] args)
throws AgentIDUnknownException,
AgentStartupException
AgentIDUnknownException
AgentStartupException
public void start_agent(AgentID agentId,
boolean collect,
java.lang.String[] args)
throws AgentIDUnknownException,
AgentStartupException
HostManagerThe 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.
start_agent in interface HostManageragentId - 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).
AgentIDUnknownException - If agentID is unknown to this host.
AgentStartupException - If there is a problem executing the agent code.
public void suspend_agent(AgentID agentId)
throws AgentIDUnknownException,
AgentSuspendException
HostManager
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.
suspend_agent in interface HostManageragentId - AgentID of the agent to be suspended.
AgentIDUnknownException - If agentID is unknown to this host manager.
AgentSuspendException - If the agent cannot be suspended.
public void kill_agent(AgentID agentId)
throws AgentIDUnknownException
HostManagerAfter 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.
kill_agent in interface HostManageragentId - The AgentID of the agent to be killed.
AgentIDUnknownException - If agentId was not running on this host.
public void migration_request(AgentID agentId,
java.lang.String leaseIdentifier,
AgentScapeID destination)
throws MigrationFailedException
HostManagerThe 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.
migration_request in interface HostManageragentId - 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.
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.
public MigrationEndpoint handle_migration(AgentID agentId,
java.lang.String leaseIdentifier,
Address requestingAddress)
throws MigrationFailedException
HostManagerThis 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.
handle_migration in interface HostManageragentId - 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.
public void migration_status(MigrationID mid,
boolean status)
throws MigrationFailedException
HostManagerThis 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.
migration_status in interface HostManagermid - 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.
public AgentHandle create_agent_handle(AgentID id)
throws AgentIDUnknownException
HostManager
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.
create_agent_handle in interface HostManagerid - 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.
public java.util.List<Envelope> remove_agent_handle(AgentID id,
AgentHandle ah,
boolean pickup)
throws AgentIDUnknownException
HostManager
remove_agent_handle in interface HostManagerid - ID of the agentah - The AgentHandle to removepickup - If true then all pending undelivered messages
are returned. Otherwise they are discarded.
AgentIDUnknownException
public java.util.List<AgentHandle> get_agent_handles(AgentID id)
throws AgentIDUnknownException
HostManagerAdministrative call, should not be possible to be called from parties other than the agent, its owner, or perhaps the the location administrator.
get_agent_handles in interface HostManagerid - AgentID of the agent to list handles for.
AgentIDUnknownException - If the agent is not known on this host.
@Deprecated
public AgentCodeSegment create_code_segment(AgentID id,
java.lang.String desc,
Language l)
throws AgentIDUnknownException
HostManager
create_code_segment in interface HostManagerAgentIDUnknownException
@Deprecated
public AgentDataSegment create_data_segment(AgentID id,
java.lang.String desc,
java.lang.String type)
throws AgentIDUnknownException
HostManager
create_data_segment in interface HostManagerAgentIDUnknownException
public void write_code(AgentID id,
AgentCodeSegment code,
byte[] bytes)
throws AgentContainerException,
AgentIDUnknownException
HostManagercode.
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.
write_code in interface HostManagerid - 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.
public void write_data(AgentID id,
AgentDataSegment data,
byte[] bytes)
throws AgentIDUnknownException,
AgentContainerException
HostManagerdata.
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.
write_data in interface HostManagerid - 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.
AgentIDUnknownException - If the AgentID id is not located on this host.
AgentContainerException - Problem writing data to the agent container.
public byte[] read_code(AgentID id,
AgentCodeSegment code)
throws AgentIDUnknownException,
AgentContainerException
HostManager
read_code in interface HostManagerid - 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.
public byte[] read_data(AgentID id,
AgentDataSegment data)
throws AgentIDUnknownException,
AgentContainerException
HostManager
read_data in interface HostManagerid - 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.
public void delete_code(AgentID id,
AgentCodeSegment code)
throws AgentIDUnknownException,
AgentContainerException
HostManagerAfter this call, the code segment will not be available in the agent container for this agent.
delete_code in interface HostManagerid - 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.
public void delete_data(AgentID id,
AgentDataSegment data)
throws AgentIDUnknownException,
AgentContainerException
HostManagerAfter this call, the data segment will not be available in the agent container for this agent.
delete_data in interface HostManagerid - 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.
public AgentCodeSegment[] get_code_segments(AgentID id)
throws AgentIDUnknownException
HostManager
get_code_segments in interface HostManagerid - 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.
public AgentDataSegment[] get_data_segments(AgentID id)
throws AgentIDUnknownException
HostManager
get_data_segments in interface HostManagerid - 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.
public AgentCodeSegment get_default_code_segment(AgentID id)
throws AgentIDUnknownException,
AgentContainerException
HostManagerEach 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.
get_default_code_segment in interface HostManagerid - The AgentID of the agent to obtain the default code segment
from.
HostManager.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.
public void set_default_code_segment(AgentID id,
AgentCodeSegment code)
throws AgentIDUnknownException,
AgentContainerException
HostManager
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.
set_default_code_segment in interface HostManagerid - 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).public java.util.List<AgentID> list_agents()
HostManager
list_agents in interface HostManagerpublic boolean hosts_agent(AgentID agentId)
HostManager
hosts_agent in interface HostManageragentId - The AgentID of the agent to check.
public int register_systemservice(AgentScapeID serviceId,
java.lang.String serviceType,
Address address,
Specifications specs)
HostManagerAfter 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.
register_systemservice in interface HostManagerserviceId - 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.public int deregister_systemservice(AgentScapeID serviceId)
HostManagerTODO: 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!
deregister_systemservice in interface HostManagerserviceId - AgentScapeID of the service to remove.
public int start_agentserver(AgentScapeID agentserverID,
Specifications serverSpecifications)
HostManager
start_agentserver in interface HostManageragentserverID - 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.
public void start_service(Specifications spec)
throws StartupException
HostManager
start_service in interface HostManagerStartupException@Deprecated public int start_agentscape_api()
HostManager
start_agentscape_api in interface HostManagerpublic TemplateList requestTemplates()
requestTemplates in interface HostManagerpublic AgreementOffer requestLease(AgreementOffer leaseRequest)
requestLease in interface HostManagerpublic AgreementOffer acceptLease(java.lang.String leaseIdentifier)
acceptLease in interface HostManagerpublic void rejectLease(java.lang.String leaseIdentifier)
rejectLease in interface HostManagerpublic AgreementOffer requestLeaseStatus(java.lang.String leaseIdentifier)
requestLeaseStatus in interface HostManager
public AgentArchive wait_for_agent(AgentID id,
boolean pickup)
throws AgentIDUnknownException,
AgentContainerException
HostManagerThe 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.
wait_for_agent in interface HostManagerid - 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.
public AgentArchive export_agent(AgentID id)
throws AgentIDUnknownException,
AgentContainerException
HostManager
export_agent in interface HostManagerAgentIDUnknownException
AgentContainerExceptionAgentScapeApi.exportAgent(org.iids.aos.systemservices.communicator.structs.AgentHandle)
public void put_message(Envelope message,
boolean canForward)
throws MessageException
HostManagerIf 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.
put_message in interface HostManagermessage - 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.
public void put_messages(java.util.List<Envelope> messages,
boolean canForward)
throws MessageException
put_messages in interface HostManagerMessageException
public Envelope get_message(AgentID fromID,
java.util.Collection<AgentHandle> handles,
boolean block)
throws AgentUnknownException,
AgentIDUnknownException
HostManagerPickup 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)
get_message in interface HostManagerfromID - The agent to pickup messages for.block - If there are no messages, wait until one arrives if the value of this
parameter is true.
AgentUnknownException - If any of the handles is unknown
AgentIDUnknownException - If the agent is not known on this host.
public java.util.List<Envelope> get_messages(AgentID fromID,
java.util.Collection<AgentHandle> handles,
boolean block)
throws AgentUnknownException,
AgentIDUnknownException
HostManager
Same as HostManager.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)
get_messages in interface HostManagerfromID - The agent to pickup messages for.block - If there are no messages, wait until one arrives if the value of this
parameter is true.
AgentUnknownException - If any of the handles is unknown.
AgentIDUnknownException - If the agent is not known on this host.public java.util.Map<AgentScapeID,SystemServiceInfo> get_service_id_list()
get_service_id_list in interface HostManagerpublic void unbind()
unbind in interface SystemServicepublic void shutdown()
shutdown in interface SystemServicepublic static LocalHostManager get(AgentScapeID id)
id if it
exists in this JVM.
id - The location ID of the LocationManager interface.
null, which also indicates that
the LocationManager for this location runs somewhere else.public static LocalHostManager get(Address address)
public static java.util.Map<AgentScapeID,LocalHostManager> getAll()
public void pingService()
pingService in interface SystemServicepublic java.lang.String pingString()
pingString in interface HostManagerpublic void pingVoid()
pingVoid in interface HostManager
public Address get_agent_server(AgentID id)
throws AgentIDUnknownException
HostManager
get_agent_server in interface HostManagerid - The AgentID of the agent to look up.
AgentIDUnknownException - If the AgentID is not hosted here.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||