All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class JavaGroups.JavaStack.RouterStub

java.lang.Object
   |
   +----JavaGroups.JavaStack.RouterStub

public class RouterStub
extends Object

Constructor Index

 o RouterStub(String, int)
Creates a stub for a remote Router object.

Method Index

 o Connect()
Establishes a connection to the router.
 o Disconnect()
Closes the socket and the input and output streams associated with it
 o Get(String)
Retrieves the membership (list of Addresses) for a given group.
 o main(String[])
 o Receive()
Receives a message from the router (blocking mode).
 o Reconnect()
Tries to establish connection to router.
 o Register(String)
Register this process with the routerb under groupname.
 o Send(Message)
Sends a message to the router.

Constructors

 o RouterStub
 public RouterStub(String router_host,
                   int router_port)
Creates a stub for a remote Router object.

Parameters:
router_host - The name of the router's host
router_port - The router's port

Methods

 o Connect
 public Address Connect()
Establishes a connection to the router. The router will send my address (its peer address) back as an Address, which is subsequently returned to the caller. The reason for not using InetAddress.getLocalHost() or sock.getLocalAddress() is that this may not be permitted with certain security managers in case this code runs in an applet.

 o Disconnect
 public void Disconnect()
Closes the socket and the input and output streams associated with it

 o Register
 public boolean Register(String groupname)
Register this process with the routerb under groupname.

Parameters:
groupname - The name of the group under which to register
Returns:
boolean False if connection down, true if registration successful.
 o Get
 public List Get(String groupname)
Retrieves the membership (list of Addresses) for a given group. This is mainly used by the PING protocol to obtain its initial membership. This is used infrequently, so don't maintain socket for the entire time, but create/delete it on demand.

 o Send
 public boolean Send(Message msg)
Sends a message to the router. Returns false if message cannot be sent (e.g. no connection to router, true otherwise.

 o Receive
 public Message Receive()
Receives a message from the router (blocking mode). If the connection is down, false is returned, otherwise true

 o Reconnect
 public synchronized boolean Reconnect()
Tries to establish connection to router. Tries until router is up again.

 o main
 public static void main(String args[])

All Packages  Class Hierarchy  This Package  Previous  Next  Index