org.almendra.janet.cas.agents
Class AgentProxy

java.lang.Object
  extended by org.almendra.janet.cas.agents.AbstractAgentProxy
      extended by org.almendra.janet.cas.agents.AgentProxy
All Implemented Interfaces:
ILoggable, IAgentProxy

public class AgentProxy
extends AbstractAgentProxy
implements IAgentProxy, ILoggable


Field Summary
protected  IAgentDispatcher agentDispatcher
           
protected  AgentPath agentPath
           
protected  AbstractApplication application
           
static java.lang.String LOG_EVENT_NO_ALTERNATIVE_AGENT_FOR_WORKLOAD_SHARING
           
static java.lang.String LOG_EVENT_NO_OBSERVER_ON_SAME_WORKSTATION
           
static java.lang.String LOG_EVENT_NO_WORKLOAD_BALANCING_POSSIBLE
           
static java.lang.String LOG_EVENT_NO_WORLOAD_SHARING_AVAILABLE
           
static java.lang.String LOG_EVENT_SENT_COMMAND
           
 
Fields inherited from class org.almendra.janet.cas.agents.AbstractAgentProxy
logger, originNodeName
 
Constructor Summary
  AgentProxy(AbstractApplication application, IAgentDispatcher agentDispatcher, AgentPath agentPath, Logger logger)
          Creates a new AgentProxy object.
protected AgentProxy(Logger logger)
          Creates a new AgentProxy object.
 
Method Summary
 void accept(CommandEnvelope env)
           
 void accept(ICommand command)
           
 void accept(ICommand command, Acknowledge ack)
           
 void accept(ICommand command, FutureResult futureResult)
          Send commmand to an agent expecting a result to be sent back.
 void accept(ICommand command, IHistorizableCallbackHandler handler)
           
 void accept(ICommand command, int kind)
           
 void accept(IWorkLoadBalancingCommand command)
           
 void accept(IWorkLoadBalancingCommand command, Acknowledge ack)
           
 void accept(IWorkLoadBalancingCommand command, FutureResult futureResult)
          Send commmand to an agent expecting a result to be sent back.
 void accept(IWorkLoadBalancingCommand command, IHistorizableCallbackHandler handler)
           
 void accept(IWorkLoadSharingCommand sharingCommand)
           
 void accept(IWorkLoadSharingCommand command, Acknowledge ack)
           
 void accept(IWorkLoadSharingCommand command, FutureResult futureResult)
          Send commmand to an agent expecting a result to be sent back.
 void accept(IWorkLoadSharingCommand command, IHistorizableCallbackHandler handler)
           
protected  boolean existsAlternativeAgents()
           
protected  java.util.Set getAgentsNodeNamesWithCapability(java.lang.String capabilityName)
           
 java.lang.String getCapabilityPath()
           
protected  CommandAckEnvelope getCommandAckEnvelope(AgentPath sourceDestinationAgentPath, java.lang.String originNodeName, ICommand command, java.lang.String futureId)
           
protected  CommandCallbackEnvelope getCommandCallbackHandlerEnvelope(AgentPath sourceDestinationAgentPath, java.lang.String originNodeName, ICommand command, java.lang.String futureId)
           
protected  CommandEnvelope getCommandEnvelope(AgentPath sourceDestinationAgentPath, java.lang.String originNodeName, ICommand command)
           
protected  CommandReplyEnvelope getCommandReplyEnvelope(AgentPath sourceDestinationAgentPath, java.lang.String originNodeName, ICommand command, java.lang.String futureId)
           
protected  IAgentProxy getLoadSharingAgent()
           
 LocalCapabilityPath getLocalCapabilityPath()
           
protected  IObjectSpace getNodeObjectSpace()
           
protected  int getNumberOfAgentsWithCapability()
           
 boolean isIdle()
           
 boolean isLocal()
           
protected  void logNoAlternativeForWorkloadSharingCommand(IWorkLoadSharingCommand sharingCommand)
           
protected  void logNoLoadBalancingAvailable(IWorkLoadBalancingCommand command)
           
protected  void logNoLoadSharingAvailable(IWorkLoadCommand command)
           
protected  void logNoObserverOnSameWorkstation(IWorkLoadSharingCommand sharingCommand)
           
protected  void logSentCommand(CommandEnvelope commandEnvelope)
           
static void LogSentCommand(CommandEnvelope commandEnvelope, Logger logger)
           
 java.util.List registeredLogEvents()
          Return list of events that may occur for an object.
protected  AgentPath replyPathSameAgent()
           
protected  void sendNoWorkLoadCommand(IWorkLoadBalancingCommand balancingCommand)
           
protected  void sendNoWorkLoadCommand(IWorkLoadSharingCommand sharingCommand)
           
 void setLogger(Logger logger)
           
protected  void setReplyAgentPath(Acknowledge ack, CommandAckEnvelope env)
           
 int size()
           
 
Methods inherited from class org.almendra.janet.cas.agents.AbstractAgentProxy
checkValidity, getLogger, getOriginNodeName, setOriginNodeName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG_EVENT_SENT_COMMAND

public static final java.lang.String LOG_EVENT_SENT_COMMAND
See Also:
Constant Field Values

LOG_EVENT_NO_ALTERNATIVE_AGENT_FOR_WORKLOAD_SHARING

public static final java.lang.String LOG_EVENT_NO_ALTERNATIVE_AGENT_FOR_WORKLOAD_SHARING
See Also:
Constant Field Values

LOG_EVENT_NO_WORKLOAD_BALANCING_POSSIBLE

public static final java.lang.String LOG_EVENT_NO_WORKLOAD_BALANCING_POSSIBLE
See Also:
Constant Field Values

LOG_EVENT_NO_WORLOAD_SHARING_AVAILABLE

public static final java.lang.String LOG_EVENT_NO_WORLOAD_SHARING_AVAILABLE
See Also:
Constant Field Values

LOG_EVENT_NO_OBSERVER_ON_SAME_WORKSTATION

public static final java.lang.String LOG_EVENT_NO_OBSERVER_ON_SAME_WORKSTATION
See Also:
Constant Field Values

application

protected AbstractApplication application

agentPath

protected AgentPath agentPath

agentDispatcher

protected IAgentDispatcher agentDispatcher
Constructor Detail

AgentProxy

protected AgentProxy(Logger logger)
Creates a new AgentProxy object.


AgentProxy

public AgentProxy(AbstractApplication application,
                  IAgentDispatcher agentDispatcher,
                  AgentPath agentPath,
                  Logger logger)
Creates a new AgentProxy object.

Method Detail

accept

public void accept(ICommand command)
            throws java.rmi.RemoteException,
                   InvalidCommandException
Specified by:
accept in interface IAgentProxy
Specified by:
accept in class AbstractAgentProxy
Throws:
java.rmi.RemoteException
InvalidCommandException

accept

public void accept(ICommand command,
                   int kind)
            throws java.rmi.RemoteException,
                   InvalidCommandException
Specified by:
accept in interface IAgentProxy
Throws:
java.rmi.RemoteException
InvalidCommandException

logSentCommand

protected void logSentCommand(CommandEnvelope commandEnvelope)
Parameters:
command -

LogSentCommand

public static void LogSentCommand(CommandEnvelope commandEnvelope,
                                  Logger logger)

accept

public void accept(ICommand command,
                   FutureResult futureResult)
            throws java.lang.IllegalArgumentException,
                   java.rmi.RemoteException,
                   InvalidCommandException
Send commmand to an agent expecting a result to be sent back.

Specified by:
accept in interface IAgentProxy
Specified by:
accept in class AbstractAgentProxy
Parameters:
command - to be sent to another agent
replyToAgentPath - path to agent that should receive result
Throws:
java.lang.IllegalArgumentException
java.rmi.RemoteException
InvalidCommandException

setReplyAgentPath

protected void setReplyAgentPath(Acknowledge ack,
                                 CommandAckEnvelope env)
                          throws java.lang.IllegalArgumentException
Parameters:
ack -
env -
Throws:
java.lang.IllegalArgumentException

getCommandAckEnvelope

protected CommandAckEnvelope getCommandAckEnvelope(AgentPath sourceDestinationAgentPath,
                                                   java.lang.String originNodeName,
                                                   ICommand command,
                                                   java.lang.String futureId)
Parameters:
sourceDestinationAgentPath -
originNodeName -
command -
Returns:

getCommandEnvelope

protected CommandEnvelope getCommandEnvelope(AgentPath sourceDestinationAgentPath,
                                             java.lang.String originNodeName,
                                             ICommand command)

getCommandReplyEnvelope

protected CommandReplyEnvelope getCommandReplyEnvelope(AgentPath sourceDestinationAgentPath,
                                                       java.lang.String originNodeName,
                                                       ICommand command,
                                                       java.lang.String futureId)

getCommandCallbackHandlerEnvelope

protected CommandCallbackEnvelope getCommandCallbackHandlerEnvelope(AgentPath sourceDestinationAgentPath,
                                                                    java.lang.String originNodeName,
                                                                    ICommand command,
                                                                    java.lang.String futureId)

accept

public void accept(ICommand command,
                   IHistorizableCallbackHandler handler)
            throws java.rmi.RemoteException,
                   InvalidCommandException
Specified by:
accept in interface IAgentProxy
Specified by:
accept in class AbstractAgentProxy
Parameters:
command -
handler -
Throws:
java.rmi.RemoteException
InvalidCommandException

replyPathSameAgent

protected AgentPath replyPathSameAgent()
Specified by:
replyPathSameAgent in class AbstractAgentProxy
Returns:

registeredLogEvents

public java.util.List registeredLogEvents()
Description copied from interface: ILoggable
Return list of events that may occur for an object.

Specified by:
registeredLogEvents in interface ILoggable
Returns:

setLogger

public void setLogger(Logger logger)
Overrides:
setLogger in class AbstractAgentProxy
Parameters:
logger - The logger to set.

accept

public void accept(CommandEnvelope env)
            throws java.rmi.RemoteException,
                   InvalidCommandException
Specified by:
accept in interface IAgentProxy
Throws:
java.rmi.RemoteException
InvalidCommandException

size

public int size()
Specified by:
size in interface IAgentProxy
Returns:

getLocalCapabilityPath

public LocalCapabilityPath getLocalCapabilityPath()

getCapabilityPath

public java.lang.String getCapabilityPath()

accept

public void accept(IWorkLoadSharingCommand sharingCommand)
            throws java.rmi.RemoteException,
                   InvalidCommandException
Specified by:
accept in interface IAgentProxy
Throws:
java.rmi.RemoteException
InvalidCommandException

logNoObserverOnSameWorkstation

protected void logNoObserverOnSameWorkstation(IWorkLoadSharingCommand sharingCommand)
Parameters:
sharingCommand -

logNoLoadSharingAvailable

protected void logNoLoadSharingAvailable(IWorkLoadCommand command)
Parameters:
sharingCommand -

logNoAlternativeForWorkloadSharingCommand

protected void logNoAlternativeForWorkloadSharingCommand(IWorkLoadSharingCommand sharingCommand)
Parameters:
sharingCommand -

getLoadSharingAgent

protected IAgentProxy getLoadSharingAgent()
Returns:

sendNoWorkLoadCommand

protected void sendNoWorkLoadCommand(IWorkLoadSharingCommand sharingCommand)
                              throws java.rmi.RemoteException,
                                     InvalidCommandException
Parameters:
sharingCommand -
Throws:
java.rmi.RemoteException
InvalidCommandException

sendNoWorkLoadCommand

protected void sendNoWorkLoadCommand(IWorkLoadBalancingCommand balancingCommand)
                              throws java.rmi.RemoteException,
                                     InvalidCommandException
Parameters:
sharingCommand -
Throws:
java.rmi.RemoteException
InvalidCommandException

existsAlternativeAgents

protected boolean existsAlternativeAgents()

getNumberOfAgentsWithCapability

protected int getNumberOfAgentsWithCapability()

getAgentsNodeNamesWithCapability

protected java.util.Set getAgentsNodeNamesWithCapability(java.lang.String capabilityName)

isIdle

public boolean isIdle()
Returns:

accept

public void accept(IWorkLoadBalancingCommand command)
            throws java.rmi.RemoteException,
                   InvalidCommandException
Specified by:
accept in interface IAgentProxy
Throws:
java.rmi.RemoteException
InvalidCommandException

logNoLoadBalancingAvailable

protected void logNoLoadBalancingAvailable(IWorkLoadBalancingCommand command)
Parameters:
command -

isLocal

public boolean isLocal()

getNodeObjectSpace

protected IObjectSpace getNodeObjectSpace()

accept

public void accept(ICommand command,
                   Acknowledge ack)
            throws java.rmi.RemoteException,
                   InvalidCommandException,
                   java.lang.IllegalArgumentException
Specified by:
accept in interface IAgentProxy
Specified by:
accept in class AbstractAgentProxy
Throws:
java.rmi.RemoteException
InvalidCommandException
java.lang.IllegalArgumentException

accept

public void accept(IWorkLoadSharingCommand command,
                   Acknowledge ack)
            throws java.rmi.RemoteException,
                   InvalidCommandException
Specified by:
accept in interface IAgentProxy
Throws:
java.rmi.RemoteException
InvalidCommandException

accept

public void accept(IWorkLoadSharingCommand command,
                   FutureResult futureResult)
            throws java.lang.IllegalArgumentException,
                   java.rmi.RemoteException,
                   InvalidCommandException
Description copied from interface: IAgentProxy
Send commmand to an agent expecting a result to be sent back.

Specified by:
accept in interface IAgentProxy
Parameters:
command - to be sent to another agent
Throws:
java.lang.IllegalArgumentException
java.rmi.RemoteException
InvalidCommandException

accept

public void accept(IWorkLoadBalancingCommand command,
                   IHistorizableCallbackHandler handler)
            throws java.rmi.RemoteException,
                   InvalidCommandException
Specified by:
accept in interface IAgentProxy
Throws:
java.rmi.RemoteException
InvalidCommandException

accept

public void accept(IWorkLoadBalancingCommand command,
                   Acknowledge ack)
            throws java.rmi.RemoteException,
                   InvalidCommandException
Specified by:
accept in interface IAgentProxy
Throws:
java.rmi.RemoteException
InvalidCommandException

accept

public void accept(IWorkLoadBalancingCommand command,
                   FutureResult futureResult)
            throws java.lang.IllegalArgumentException,
                   java.rmi.RemoteException,
                   InvalidCommandException
Description copied from interface: IAgentProxy
Send commmand to an agent expecting a result to be sent back.

Specified by:
accept in interface IAgentProxy
Parameters:
command - to be sent to another agent
Throws:
java.lang.IllegalArgumentException
java.rmi.RemoteException
InvalidCommandException

accept

public void accept(IWorkLoadSharingCommand command,
                   IHistorizableCallbackHandler handler)
            throws java.rmi.RemoteException,
                   InvalidCommandException
Specified by:
accept in interface IAgentProxy
Throws:
java.rmi.RemoteException
InvalidCommandException