|
Peer locator v1.0 | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object | +--com.unet.warmachine.peerlocator.Agent
This class is the agent that locates other members of the group on behalf of
its client. An agent does not provide a messaging service - clients are
expected to establish their own connection and protocols once a member is
located. An agent is created with suitable configuration and a list of known members. The agent
must appear as a member of the list, although the list can be otherwise empty.
The agent is created in a shutdown state and must be started using startup.
Once started, it attempts to locate other (known) members of the group. For
performance reasons, only a limited number of members will be searched at any
one time, starting with members that use static IP addresses. Agents will
inform each other of other members that have been located. Once a connection
is established to the remote agent representing a member, the member is
considered online. The client is notified whenever another member of becomes
online or offline.
Clients can set their status value which is then broadcast
to all other (online) members. This status value has no meaning to agents,
only to their clients.
The agent also handles registration, which requires the IP
address or range and TCP port no of a known member of the group.
Registration is successful if the agent name does not clash with any other
member. The location of new members is broadcast to other members. Note
that as agents aren't in constant communication, a successfully registered
name can be later rejected by another agent as it clashes with a another,
known member.
This class is the overall system controller. It receives messages, decides how to respond to them. For example, it decides whether to accept connection requests, which member locators should run, exchanges membership lists with other agents and broadcasts changes in status value.
| Field Summary | |
static int |
REGISTER_NAME_CLASH
Returned by register functions - member name of self
is already owned by other member. |
static int |
REGISTER_NOT_FOUND
Returned by register functions - no other member of
group found within IP address range. |
static int |
REGISTER_OK
Returned by register functions - registration
successful. |
| Constructor Summary | |
Agent(Configuration configuration,
MembershipList membershipList)
Constructor. |
|
| Method Summary | |
void |
addMemberChangeListener(MemberChangeListener memberChangeListener)
Adds listener to receive notification of member online and status value. |
Configuration |
getConfiguration()
Returns configuration used by this agent. |
java.lang.String |
getGroupName()
Returns group name of agent. |
MembershipList |
getMembershipList()
Returns membership list used by this agent. |
java.lang.String |
getName()
Returns name of agent, which is unique within group. |
Member |
getSelfMember()
Returns member that represents this agent. |
java.lang.String |
getStatus()
Returns status value of agent. |
boolean |
isGroupOnline()
Whether at least one other member of the group is online. |
boolean |
isGroupRejected()
Whether agent was rejected because of name clash with an existing member. |
boolean |
isMemberLocated(Member member)
Whether member is online. |
boolean |
isRunning()
Whether startup sequence is complete, not shutdown nor in the shutting down. |
void |
notifyGroupOnlineChanged()
Notifies all listeners that this agent is connected or is no longer connected to at one other member of the group. |
int |
register(java.net.InetAddress startIPAddress,
java.net.InetAddress endIPAddress,
int portNo)
Attempts to find an agent (of the same group) using the supplied address range and TCP port. |
int |
register(java.net.InetAddress iPAddress,
int portNo)
Attempts to find an agent (of the same group) using the supplied IP address and TCP port. |
void |
removeMemberChangeListener(MemberChangeListener memberChangeListener)
Removes listener. |
void |
setStatus(java.lang.String status)
Sets status value of agent and broadcasts to all other, online agents. |
void |
shutdown()
Makes agent offline and closes all connections. |
void |
startup()
Makes agent online, starts communications and attempts to locate other agents. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int REGISTER_OK
register functions - registration
successful.public static final int REGISTER_NOT_FOUND
register functions - no other member of
group found within IP address range.public static final int REGISTER_NAME_CLASH
register functions - member name of self
is already owned by other member.| Constructor Detail |
public Agent(Configuration configuration,
MembershipList membershipList)
throws ConfigurationException,
java.io.IOException
configuration - Configuration containing agent name, search
limits and timeouts.membershipList - List of known members.ConfigurationException - Fault with configuration object. See
ConfigurationException.java.io.IOException - Network access denied.| Method Detail |
public void notifyGroupOnlineChanged()
public java.lang.String getGroupName()
public java.lang.String getName()
public java.lang.String getStatus()
public void setStatus(java.lang.String status)
status - Status value - cannot be null.java.lang.IllegalArgumentException - Status value was null.public Configuration getConfiguration()
public MembershipList getMembershipList()
public Member getSelfMember()
public void addMemberChangeListener(MemberChangeListener memberChangeListener)
memberChangeListener - Listener to add.public void removeMemberChangeListener(MemberChangeListener memberChangeListener)
memberChangeListener - Listener to remove.public void startup()
public void shutdown()
public boolean isRunning()
public int register(java.net.InetAddress iPAddress,
int portNo)
throws java.lang.IllegalStateException
iPAddress - IP address to search.iPAddress - TCP port no to search.java.lang.IllegalStateException - Agent is not running.
public int register(java.net.InetAddress startIPAddress,
java.net.InetAddress endIPAddress,
int portNo)
throws java.lang.IllegalStateException
iPAddress - IP address to search.iPAddress - TCP port no to search.java.lang.IllegalStateException - Agent is not running.public boolean isMemberLocated(Member member)
public boolean isGroupOnline()
public boolean isGroupRejected()
|
Peer locator v1.0 | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||