fr.dyade.aaa.agent
Class AgentId

java.lang.Object
  extended by fr.dyade.aaa.agent.AgentId
All Implemented Interfaces:
java.io.Serializable

public final class AgentId
extends java.lang.Object
implements java.io.Serializable

An AgentId allows for uniquely identifying and localizing an agent throughout the distributed system. It defines variable members describing the identifier and all needed function members to manipulate the structure (creation, serialization, etc).


However before describing the structure of an AgentId we must take into account a second requirement: an agent may be created onto a remote agent server, and the creating entity needs to know the new identifier created for that agent. As agents live in an asynchronous world it is not so easy to get back the identifier from the remote server. We decided instead to make the creating entity responsible for creating the identifier.

The two requirements are then:


The AgentId is then built of three parts: The three fields form the unique global identifier of the agent, that is two agents may share a common stamp, as long as their from or to fields differ. The to field identifies the agent server hosting the agent, so it is used by the channel to forward notifications to the agent.

See Also:
AgentIdStamp, Serialized Form

Field Summary
static int AMQPAgentStamp
          Reserved stamp for AMQPAgent.
static int ControlTopicStamp
          Reserved stamp for JMS topic AgentId in charge of sending control events.
(package private) static AgentId factoryId
          AgentId for local factory agent.
static int FactoryIdStamp
          Reserved stamp for factory AgentId.
static int FileTransfertStamp
          Reserved stamp for fileTransfert service AgentId.
(package private)  short from
          The identification of the agent server hosting the creating agent.
static int JndiServiceStamp
          Reserved stamp for JNDI service AgentId.
static int JoramAdminPxStamp
          Reserved stamp for JORAM administration proxy AgentId.
static int JoramAdminStamp
          Reserved stamp for JORAM administration topic AgentId.
(package private) static AgentId localId
          Used by channel to send messages without source agent (from proxy or engine).
static int LocalJndiServiceStamp
          Reserved stamp for local JNDI service AgentId.
static int MaxIdStamp
          Maximum reserved stamp.
static int MaxSystemIdStamp
          Maximum reserved stamp for system services.
static int MaxWKSIdStamp
          Maximum reserved stamp for well known services.
static int MinWKSIdStamp
          Minimum reserved stamp for well known services.
static int NameServiceStamp
          Reserved stamp for name service AgentId.
static AgentId nullId
          null AgentId.
static int NullIdStamp
          Reserved stamp for NullId.
static int ResourceAgentStamp
          Reserved stamp for ResourceAgent.
static int SCAdminProxyStamp
          Reserved stamp for SCAdmin proxy AgentId.
static int SchedulerServiceStamp
          Reserved stamp for scheduler service AgentId.
(package private) static long serialVersionUID
          Define serialVersionUID for interoperability.
static int ServerConfigStamp
          Reserved stamp for the server reconfiguration agent AgentId .
(package private)  int stamp
          The stamp, local to the agent server hosting the creating agent.
(package private)  java.lang.String str
          A temporary string representation of object in order to improve performances.
(package private)  short to
          The identification of the agent server hosting the created agent.
 
Constructor Summary
AgentId()
          Allocates an AgentId object for a new agent hosted by this agent server.
AgentId(short to)
          Allocates an AgentId object for a new agent hosted by specified agent server.
AgentId(short from, short to, int stamp)
          Allocates a new AgentId object.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Indicates whether some other agent id. is "equal to" this one.
static AgentId factoryId(short sid)
          Returns the AgentId for a remote factory agent.
static AgentId fromString(java.lang.String str)
          Parses the string argument as an AgentId.
 short getFrom()
           
 int getStamp()
           
 short getTo()
           
 int hashCode()
          Returns a hashcode for this AgentId object.
(package private) static void init()
          Statically initializes AgentId class.
 boolean isNullId()
           
static AgentId localId(short sid)
           
static int parseInt(java.lang.String str, int idx, int end)
          Parses the string argument as a non signed integer.
private  void readObject(java.io.ObjectInputStream in)
          The readObject is responsible for reading from the stream and restoring the classes fields.
 java.lang.String toString()
          Returns a string representation of this AgentId object.
private  void writeObject(java.io.ObjectOutputStream out)
          The writeObject method is responsible for writing the state of the object for its particular class so that the corresponding readObject method can restore it.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID
Define serialVersionUID for interoperability.

See Also:
Constant Field Values

from

transient short from
The identification of the agent server hosting the creating agent.


to

transient short to
The identification of the agent server hosting the created agent.


stamp

transient int stamp
The stamp, local to the agent server hosting the creating agent.


str

transient java.lang.String str
A temporary string representation of object in order to improve performances.


NullIdStamp

public static final int NullIdStamp
Reserved stamp for NullId.

See Also:
Constant Field Values

FactoryIdStamp

public static final int FactoryIdStamp
Reserved stamp for factory AgentId.

See Also:
Constant Field Values

MaxSystemIdStamp

public static final int MaxSystemIdStamp
Maximum reserved stamp for system services.

See Also:
Constant Field Values

MinWKSIdStamp

public static int MinWKSIdStamp
Minimum reserved stamp for well known services.


NameServiceStamp

public static int NameServiceStamp
Reserved stamp for name service AgentId.


SchedulerServiceStamp

public static int SchedulerServiceStamp
Reserved stamp for scheduler service AgentId.


FileTransfertStamp

public static int FileTransfertStamp
Reserved stamp for fileTransfert service AgentId.


JndiServiceStamp

public static int JndiServiceStamp
Reserved stamp for JNDI service AgentId.


LocalJndiServiceStamp

public static int LocalJndiServiceStamp
Reserved stamp for local JNDI service AgentId.


SCAdminProxyStamp

public static int SCAdminProxyStamp
Reserved stamp for SCAdmin proxy AgentId.


JoramAdminStamp

public static int JoramAdminStamp
Reserved stamp for JORAM administration topic AgentId.


JoramAdminPxStamp

public static int JoramAdminPxStamp
Reserved stamp for JORAM administration proxy AgentId.


ControlTopicStamp

public static int ControlTopicStamp
Reserved stamp for JMS topic AgentId in charge of sending control events.


ServerConfigStamp

public static int ServerConfigStamp
Reserved stamp for the server reconfiguration agent AgentId .


ResourceAgentStamp

public static int ResourceAgentStamp
Reserved stamp for ResourceAgent.


AMQPAgentStamp

public static int AMQPAgentStamp
Reserved stamp for AMQPAgent.


MaxWKSIdStamp

public static int MaxWKSIdStamp
Maximum reserved stamp for well known services.


MaxIdStamp

public static int MaxIdStamp
Maximum reserved stamp.


nullId

public static final AgentId nullId
null AgentId.


localId

static AgentId localId
Used by channel to send messages without source agent (from proxy or engine). The from field does not be nullId because the destination node use the from.to field to get the from node id.

See Also:
Engine, Channel.sendTo(AgentId, Notification)

factoryId

static AgentId factoryId
AgentId for local factory agent.

See Also:
AgentFactory
Constructor Detail

AgentId

AgentId()
  throws java.io.IOException
Allocates an AgentId object for a new agent hosted by this agent server.

Throws:
java.io.IOException

AgentId

AgentId(short to)
  throws java.io.IOException
Allocates an AgentId object for a new agent hosted by specified agent server.

Parameters:
to - The identification of the agent server hosting the agent.
Throws:
java.io.IOException

AgentId

public AgentId(short from,
               short to,
               int stamp)
Allocates a new AgentId object.

Parameters:
from - The identification of the agent server hosting the creating agent.
to - The identification of the agent server hosting the agent.
stamp - The stamp of agent.
Method Detail

writeObject

private void writeObject(java.io.ObjectOutputStream out)
                  throws java.io.IOException
The writeObject method is responsible for writing the state of the object for its particular class so that the corresponding readObject method can restore it.

Parameters:
out - the underlying output stream.
Throws:
java.io.IOException

readObject

private void readObject(java.io.ObjectInputStream in)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException
The readObject is responsible for reading from the stream and restoring the classes fields.

Parameters:
in - the underlying input stream.
Throws:
java.lang.ClassNotFoundException
java.io.IOException

factoryId

public static final AgentId factoryId(short sid)
Returns the AgentId for a remote factory agent.

Parameters:
sid - remote server id.
Returns:
the AgentId for a remote factory agent.

localId

public static final AgentId localId(short sid)

init

static void init()
          throws java.io.IOException,
                 java.lang.ClassNotFoundException
Statically initializes AgentId class.

Throws:
java.io.IOException
java.lang.ClassNotFoundException

getFrom

public final short getFrom()

getTo

public final short getTo()

getStamp

public final int getStamp()

parseInt

public static final int parseInt(java.lang.String str,
                                 int idx,
                                 int end)
                          throws java.lang.NumberFormatException
Parses the string argument as a non signed integer. The characters in the substring must all be digits.

Parameters:
str - the String containing the integer representation to be parsed.
idx - the beginning index, inclusive.
end - the ending index, exclusive.
Returns:
the integer represented by the string argument.
Throws:
java.lang.NumberFormatException - if the String does not contain a parsable int.

fromString

public static final AgentId fromString(java.lang.String str)
Parses the string argument as an AgentId.

Returns:
The AgentId object represented by the argument.

toString

public final java.lang.String toString()
Returns a string representation of this AgentId object.

Overrides:
toString in class java.lang.Object
Returns:
A string representation of this object.

hashCode

public int hashCode()
Returns a hashcode for this AgentId object.

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code value for this object, equal to the primitive int value represented by the stamp field.

isNullId

public final boolean isNullId()
Returns:
true if this id is equals to NullId; false otherwise.

equals

public boolean equals(java.lang.Object obj)
Indicates whether some other agent id. is "equal to" this one. This method returns true if and only if obj is an AgentId and refer to the same agent (from, to and stamp fields are equals).

Overrides:
equals in class java.lang.Object
Parameters:
obj - the reference object with which to compare.
Returns:
true if this object is the same as the obj argument; false otherwise.


Copyright © 2010 ScalAgent D.T.. All Rights Reserved.