org.iids.aos.agentserver
Class AgentScapeImpl

java.lang.Object
  extended by org.iids.aos.agentserver.AgentScapeImpl
All Implemented Interfaces:
AgentNegotiationLibInterface, AgentScape

public class AgentScapeImpl
extends java.lang.Object
implements AgentScape

Author:
hidde

Constructor Summary
AgentScapeImpl(AgentWrapper _agent, AgentScapeConfig _config, AsCommunicator _communicator, MessageCenter _messageCenter, AsLookupService _lookupService, HostManagerWrapper _hostManagerWrapper, AgentServer2WSGatewayModule _wsGatewayModule, AgentNegotiationLib neglib, AgentRunner agentRunner)
           
 
Method Summary
 AgreementOffer acceptLease(AgentScapeID locationID, java.lang.String leaseIdentifier)
           
 AgentHandle cloneAgent()
           
 int createAgent(byte[] code)
           
 int createAgent(byte[] code, java.lang.String leaseIdentifier)
           
 AgentHandle createAgentHandle()
           
 AgentStore createStore(java.lang.String description, byte[] data)
          Create Agent store
protected  void finalize()
           
 java.util.Hashtable find(java.lang.String key, java.lang.String value)
           
 AgentHandle getAgentHandle()
           
 AgentHandle getAgentHandle(java.net.URL locationService)
           
 java.net.URL getAgentServer()
           
 AgentScapeID getLocationId()
           
 int getMyCPUtime()
           
 AgentStore getStore(int segmentID)
          Get agent store from segment (if possible).
 AgentStore[] getStores()
          Get all the stores of an agent.
 AgentStore[] getStores(java.lang.String description)
          Get all the stores of an agent with matching description.
 boolean isActive(AgentHandle agentHandle)
           
 boolean isLifeCycleState(AgentHandle agentHandle, int type)
           
 void kill()
           
 java.util.Hashtable list(java.lang.String key)
           
 java.util.Hashtable lookup(java.lang.String identifier)
           
 int move(AgentScapeID locationId)
          Lets the agent issue a request to get migrated to another location.
 int move(AgentScapeID locationId, java.lang.String leaseIdentifier)
          Lets the agent issue a request to get migrated to another location.
 byte[] receiveMessage(boolean block)
           
 byte[][] receiveMessages(boolean block)
           
 long register(java.lang.String identifier, java.lang.String key, java.lang.String value, float duration)
           
 AgreementOffer requestLease(AgentScapeID locationID, AgreementOffer leaseRequest)
           
 AgreementOffer requestLeaseStatus(java.lang.String leaseIdentifier)
           
 TemplateList requestTemplates(AgentScapeID locationID)
           
 int requestWSDLAccess(java.lang.String wsdl, java.lang.String serviceName, java.lang.String serviceNameSpace, boolean exclTransport)
          Deprecated. 
 void sendMessage(AgentHandle agentHandle, byte[] message)
           
 void sendMessages(java.util.List<AgentHandle> ahs, java.util.List<byte[]> messages)
           
 java.lang.String sendSOAPRequest(java.lang.String request, java.lang.String portName, int leaseID)
          Deprecated. 
 int suspend(long timeout)
          Called by the agent if it wants to suspend
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AgentScapeImpl

public AgentScapeImpl(AgentWrapper _agent,
                      AgentScapeConfig _config,
                      AsCommunicator _communicator,
                      MessageCenter _messageCenter,
                      AsLookupService _lookupService,
                      HostManagerWrapper _hostManagerWrapper,
                      AgentServer2WSGatewayModule _wsGatewayModule,
                      AgentNegotiationLib neglib,
                      AgentRunner agentRunner)
Method Detail

finalize

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

register

public long register(java.lang.String identifier,
                     java.lang.String key,
                     java.lang.String value,
                     float duration)
Specified by:
register in interface AgentScape

lookup

public java.util.Hashtable lookup(java.lang.String identifier)
Specified by:
lookup in interface AgentScape

find

public java.util.Hashtable find(java.lang.String key,
                                java.lang.String value)
Specified by:
find in interface AgentScape

list

public java.util.Hashtable list(java.lang.String key)
Specified by:
list in interface AgentScape

createAgent

public int createAgent(byte[] code)
                throws java.lang.Exception
Specified by:
createAgent in interface AgentScape
Throws:
java.lang.Exception

createAgent

public int createAgent(byte[] code,
                       java.lang.String leaseIdentifier)
                throws java.lang.Exception
Specified by:
createAgent in interface AgentScape
Throws:
java.lang.Exception

cloneAgent

public AgentHandle cloneAgent()
Specified by:
cloneAgent in interface AgentScape

suspend

public int suspend(long timeout)
Called by the agent if it wants to suspend

Specified by:
suspend in interface AgentScape
Parameters:
timeout -
Returns:
errorcode

kill

public void kill()
Specified by:
kill in interface AgentScape

move

public int move(AgentScapeID locationId,
                java.lang.String leaseIdentifier)
Lets the agent issue a request to get migrated to another location. First step in move is to suspend agent. if suspend does not work, move is not processed further, but failure is reported to agent.

Specified by:
move in interface AgentScape
Parameters:
locationId -
leaseIdentifier -
Returns:
0 if wrapper returns 0, -1 if wrapper returns -1

move

public int move(AgentScapeID locationId)
Lets the agent issue a request to get migrated to another location. This move is unconditional. No requirements are made on the specifications of the remote location. In other words, an empty resource-lease is used.

Specified by:
move in interface AgentScape
Parameters:
locationId -
Returns:
0 if wrapper returns 0, -1 if wrapper returns -1

sendMessage

public void sendMessage(AgentHandle agentHandle,
                        byte[] message)
                 throws MessageBufferOverflowException
Specified by:
sendMessage in interface AgentScape
Throws:
MessageBufferOverflowException

sendMessages

public void sendMessages(java.util.List<AgentHandle> ahs,
                         java.util.List<byte[]> messages)
                  throws MessageBufferOverflowException
Specified by:
sendMessages in interface AgentScape
Throws:
MessageBufferOverflowException

receiveMessage

public byte[] receiveMessage(boolean block)
Specified by:
receiveMessage in interface AgentScape

receiveMessages

public byte[][] receiveMessages(boolean block)
Specified by:
receiveMessages in interface AgentScape

getAgentHandle

public AgentHandle getAgentHandle()
Specified by:
getAgentHandle in interface AgentScape

createAgentHandle

public AgentHandle createAgentHandle()
Specified by:
createAgentHandle in interface AgentScape

getAgentHandle

public AgentHandle getAgentHandle(java.net.URL locationService)
Specified by:
getAgentHandle in interface AgentScape

isActive

public boolean isActive(AgentHandle agentHandle)
Specified by:
isActive in interface AgentScape

isLifeCycleState

public boolean isLifeCycleState(AgentHandle agentHandle,
                                int type)
Specified by:
isLifeCycleState in interface AgentScape

getLocationId

public AgentScapeID getLocationId()
Specified by:
getLocationId in interface AgentScape

getAgentServer

public java.net.URL getAgentServer()
Specified by:
getAgentServer in interface AgentScape

requestWSDLAccess

@Deprecated
public int requestWSDLAccess(java.lang.String wsdl,
                                        java.lang.String serviceName,
                                        java.lang.String serviceNameSpace,
                                        boolean exclTransport)
                      throws java.net.MalformedURLException,
                             CouldNotParseWSDL,
                             NoExclusiveTransport
Deprecated. 

Specified by:
requestWSDLAccess in interface AgentScape
Throws:
java.net.MalformedURLException
CouldNotParseWSDL
NoExclusiveTransport
See Also:
WSGateway

sendSOAPRequest

@Deprecated
public java.lang.String sendSOAPRequest(java.lang.String request,
                                                   java.lang.String portName,
                                                   int leaseID)
                                 throws LeaseExpired,
                                        UnknownPort,
                                        MalformedSOAPRequest,
                                        java.rmi.RemoteException
Deprecated. 

Specified by:
sendSOAPRequest in interface AgentScape
Throws:
LeaseExpired
UnknownPort
MalformedSOAPRequest
java.rmi.RemoteException
See Also:
WSGateway

getMyCPUtime

public int getMyCPUtime()
Specified by:
getMyCPUtime in interface AgentScape

requestTemplates

public TemplateList requestTemplates(AgentScapeID locationID)
                              throws NegotiationLibException
Specified by:
requestTemplates in interface AgentNegotiationLibInterface
Throws:
NegotiationLibException

requestLease

public AgreementOffer requestLease(AgentScapeID locationID,
                                   AgreementOffer leaseRequest)
                            throws NegotiationLibException
Specified by:
requestLease in interface AgentNegotiationLibInterface
Throws:
NegotiationLibException

acceptLease

public AgreementOffer acceptLease(AgentScapeID locationID,
                                  java.lang.String leaseIdentifier)
                           throws NegotiationLibException
Specified by:
acceptLease in interface AgentNegotiationLibInterface
Throws:
NegotiationLibException

requestLeaseStatus

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

createStore

public AgentStore createStore(java.lang.String description,
                              byte[] data)
                       throws KernelException
Description copied from interface: AgentScape
Create Agent store

Specified by:
createStore in interface AgentScape
Parameters:
description - Meta-data (description) of store.
data - Data that will go in the store.
Returns:
AgentStore handle that can be used for reading later.
Throws:
KernelException - if the AgentScape kernel cannot create a storage segment for this agent.

getStores

public AgentStore[] getStores(java.lang.String description)
Description copied from interface: AgentScape
Get all the stores of an agent with matching description.

Specified by:
getStores in interface AgentScape
Parameters:
description - The store description to look for.
Returns:
an array with matching store handles.

getStores

public AgentStore[] getStores()
Description copied from interface: AgentScape
Get all the stores of an agent.

Specified by:
getStores in interface AgentScape
Returns:
an array with all available store handles.

getStore

public AgentStore getStore(int segmentID)
                    throws UnknownStoreIDException
Description copied from interface: AgentScape
Get agent store from segment (if possible).

Specified by:
getStore in interface AgentScape
Parameters:
segmentID - The kernel segment ID of this store.
Returns:
AgentStore handle to be used for reading etc.
Throws:
UnknownStoreIDException - If there is no agent store in the segment segmentID.


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