edu.uwf.kaos.coabsgrid
Class KAoSAgentRegistrationHelper

java.lang.Object
  extended by AgentRegistrationHelper
      extended by edu.uwf.kaos.coabsgrid.KAoSAgentRegistrationHelper

public final class KAoSAgentRegistrationHelper
extends AgentRegistrationHelper

Extends functionality of AgentRegistrationHelper by adding registration in a KAOS domain. $Revision: 1.12 $


Constructor Summary
KAoSAgentRegistrationHelper(net.jini.discovery.LookupDiscoveryManager lookupDiscoveryManager, java.lang.String agentName)
          Constructor.
KAoSAgentRegistrationHelper(java.lang.String agentName)
          Constructor.
KAoSAgentRegistrationHelper(java.lang.String agentName, java.lang.String storePass, java.lang.String keyPass)
          Constructor.
 
Method Summary
 void deregisterAgent()
          Deregisters the service without sending a message.
 void deregisterAgent(AgentRep msgRecipient, java.lang.String replyWith)
          Deregisters the service and sends a status message.
 void deregisterAgent(java.lang.String replyWith)
          Deregisters the GridAgent's AgentRep and sends it the status message.
 KAoSAgentDescription getAgentDescription()
           
 Directory getDirectory()
          Convenience method to return Directory from KAoSGridAgentHelper.
 boolean isRegistered()
          This method should be called by the Grid agent requesting Grid/Domain registration.
protected  void printDebugString(java.lang.String msg)
          Print debug messages - a utility method.
 void registerAgent()
          Register agent in the LUS and then in the domain, whose name is specified in the KAoSAgentRegistrationHelper's property file.
 void registerAgent(AgentRep msgRecipient, java.lang.String replyWith)
          Registers the GridService service with its advertisedCapabilities.
 void registerAgent(java.lang.String replyWith)
          Domain registration not implemented yet! ******* Agent version of registration method, where the result message is sent to the GridAgent's AgentRep.
 void registerAgentInDomains()
          Register agent in a KAoS domain.
protected  void setRegistered(boolean aValue)
          Set the 'registeredInDomain_' variable to true or false.
 void setTestMode(boolean testMode)
           
 void updateRegistration()
          Added to support mobility.
 void updateRegistration(AgentRep msgRecipient, java.lang.String replyWith)
          Added to support mobility.
 void updateRegistration(java.lang.String replyWith)
          Added to support mobility.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KAoSAgentRegistrationHelper

public KAoSAgentRegistrationHelper(java.lang.String agentName)
                            throws java.io.IOException,
                                   java.lang.ClassNotFoundException
Constructor. Instantiate the KAoSAgentRegistrationHelper using name agentName. Instantiate a KAoSAgentRep. Obtain KAoSGridHelper for this agent. Establish association between the KAoSAgentRegistrationHelper and KAoSGridHelper .

Parameters:
agentName - the name of the GridAgentHelper to instantiate
Throws:
java.io.IOException - if there is a problem instantiating the LookupDiscoveryManager
java.lang.ClassNotFoundException

KAoSAgentRegistrationHelper

public KAoSAgentRegistrationHelper(java.lang.String agentName,
                                   java.lang.String storePass,
                                   java.lang.String keyPass)
                            throws java.io.IOException
Constructor. Instantiate the KAoSAgentRegistrationHelper using name agentName, key store password and key password. Instantiate a KAoSGridHelper. Establish association between the KAoSGridHelper and KAoSAgentRegistrationHelper.

Parameters:
agentName - - the name of the agent to be registered with Grid and a KAoS domain storePass - key store password keyPass - key password
Throws:
java.io.IOException - if there is a problem instantiating the LookupDiscoveryManager

KAoSAgentRegistrationHelper

public KAoSAgentRegistrationHelper(net.jini.discovery.LookupDiscoveryManager lookupDiscoveryManager,
                                   java.lang.String agentName)
                            throws java.io.IOException
Constructor. Instantiate the KAoSAgentRegistrationHelper using name agentName. Instantiate a KAoSAgentRep. Obtain KAoSGridHelper for this agent. Establish association between the KAoSAgentRegistrationHelper and KAoSGridHelper .

Parameters:
lookupDiscoveryManager - - the LookupDiscoveryManager to find lookup services to register with
agentName - - the name of the agent to be registered with Grid and a KAoS domain
Throws:
java.io.IOException - if there is a problem instantiating the LookupDiscoveryManager
Method Detail

registerAgent

public void registerAgent()
                   throws java.io.IOException
Register agent in the LUS and then in the domain, whose name is specified in the KAoSAgentRegistrationHelper's property file. Grid registration is not blocking, domain registration is.

Throws:
java.io.IOException

registerAgent

public void registerAgent(AgentRep msgRecipient,
                          java.lang.String replyWith)
                   throws java.io.IOException
Registers the GridService service with its advertisedCapabilities. Uses a Jini JoinManager. If the GridService doesn't already have a ServiceID, then this method will block until one is returned, and then modifyAgent() will be called so that the CoABSAgentDescription is updated with the new ServiceID. This is the agent version of the method, in that a FIPA-like reply method will be sent to the msgRecipient. If the service is already registered when this method is called, this method will not reregister it with Jini, and will generate a failure reply method.

Parameters:
msgRecipient - An DefaultAgentRep to send a registration status message to.
replyWith - A String to put in the replyWith field of the message.
Throws:
java.io.IOException - if there is a problem instantiating the JoinManger.
java.lang.IllegalStateException - if the object has been terminated

registerAgent

public void registerAgent(java.lang.String replyWith)
                   throws java.io.IOException
Domain registration not implemented yet! ******* Agent version of registration method, where the result message is sent to the GridAgent's AgentRep. Registers the GridAgent's service using its advertisedCapabilities. Uses a Jini JoinManager. If the GridAgent doesn't already have a ServiceID, then this method will block until one is returned, and then modifyAgent() will be called so that the CoABSAgentDescription is updated with the new ServiceID. If the service is already registered when this method is called, this method will not reregister it with Jini, and will generate a failure reply method.

Parameters:
replyWith - A String to put in the replyWith field of the message.
Throws:
java.io.IOException - if there is a problem instantiating the JoinManger.
java.lang.IllegalStateException - if the object has been terminated

registerAgentInDomains

public void registerAgentInDomains()
Register agent in a KAoS domain. The name of the domain is specified in the KAoSAgentRegistrationHelper's property file. Establish agent's GUID and then AgentDestination. Create the domain registration message. Lookup DomainManager for the requested domain and, if found, send the registration message to it. Wait until DomainManager's reply comes back.


setTestMode

public void setTestMode(boolean testMode)

updateRegistration

public void updateRegistration()
                        throws java.io.IOException
Added to support mobility. Resets the JoinManager to update the info in the Jini Registry after the move. Before moving you can now call getJoinManager().getLeaseRenewalManager().renewFor() to increase the lease time before moving. Or you can just call this right before moving to increase the lease to the default value.

Throws:
java.io.IOException - if there is a problem with the JoinManger.
java.lang.IllegalStateException - if the object has been terminated

updateRegistration

public void updateRegistration(AgentRep msgRecipient,
                               java.lang.String replyWith)
                        throws java.io.IOException
Added to support mobility. Resets the JoinManager to update the info in the Jini Registry after the move. Before moving you can now call getJoinManager().getLeaseRenewalManager().renewFor() to increase the lease time before moving. Or you can just call this right before moving to increase the lease to the default value. If the GridService doesn't already have a ServiceID, then this method will block until one is returned, and then modifyAgent() will be called so that the CoABSAgentDescription is updated with the new ServiceID. This is the agent version of the method, in that a FIPA-like reply method will be sent to the msgRecipient.

Parameters:
msgRecipient - An DefaultAgentRep to send a status message to.
replyWith - A String to put in the replyWith field of the message.
Throws:
java.io.IOException - if there is a problem with the JoinManger.
java.lang.IllegalStateException - if the object has been terminated

updateRegistration

public void updateRegistration(java.lang.String replyWith)
                        throws java.io.IOException
Added to support mobility. Resets the JoinManager to update the info in the Jini Registry after the move. Before moving you can now call getJoinManager().getLeaseRenewalManager().renewFor() to increase the lease time before moving. Or you can just call this right before moving to increase the lease to the default value. If the GridService doesn't already have a ServiceID, then this method will block until one is returned, and then modifyAgent() will be called so that the CoABSAgentDescription is updated with the new ServiceID. This is the agent version of the method, in that a FIPA-like reply method will be sent to the msgRecipient.

Parameters:
replyWith - A String to put in the replyWith field of the message.
Throws:
java.io.IOException - if there is a problem with the JoinManger.
java.lang.IllegalStateException - if the object has been terminated

deregisterAgent

public void deregisterAgent(java.lang.String replyWith)
                     throws java.io.IOException
Deregisters the GridAgent's AgentRep and sends it the status message.

Parameters:
replyWith - A String to put in the replyWith field of the message.
Throws:
java.lang.IllegalStateException - if the object has been terminated
java.io.IOException

deregisterAgent

public void deregisterAgent()
Deregisters the service without sending a message.

Throws:
java.lang.IllegalStateException - if the object has been terminated

deregisterAgent

public void deregisterAgent(AgentRep msgRecipient,
                            java.lang.String replyWith)
Deregisters the service and sends a status message.

Parameters:
msgRecipient - An DefaultAgentRep to send a status message to.
replyWith - A String to put in the replyWith field of the message.
Throws:
java.rmi.RemoteException - if there is a problem sending the reply message.

getAgentDescription

public KAoSAgentDescription getAgentDescription()

getDirectory

public Directory getDirectory()
Convenience method to return Directory from KAoSGridAgentHelper.

Throws:
java.lang.ClassCastException - when the GridAgent isn't a GridAgentHelper or when GridAgentHelper's logger isn't a MultiLogger
java.lang.IllegalStateException - if the object has been terminated

setRegistered

protected final void setRegistered(boolean aValue)
Set the 'registeredInDomain_' variable to true or false. registeredInDomain_ indicates the success or failure of registering the agent in the domain.


isRegistered

public boolean isRegistered()
This method should be called by the Grid agent requesting Grid/Domain registration.


printDebugString

protected void printDebugString(java.lang.String msg)
Print debug messages - a utility method.