org.jgroups.stack
Class RouterStub

java.lang.Object
  extended by org.jgroups.stack.RouterStub

public class RouterStub
extends java.lang.Object

Client stub that talks to a remote GossipRouter

Version:
$Id: RouterStub.java,v 1.22 2006/10/25 08:23:58 belaban Exp $
Author:
Bela Ban

Nested Class Summary
static interface RouterStub.ConnectionListener
           
 
Field Summary
protected  RouterStub.ConnectionListener conn_listener
           
protected static org.apache.commons.logging.Log log
           
 
Constructor Summary
RouterStub()
           
RouterStub(java.lang.String router_host, int router_port)
          Creates a stub for a remote Router object.
 
Method Summary
 void connect(java.lang.String groupname)
          Register this process with the router under groupname.
 void connect(java.lang.String groupname, java.lang.String router_host, int router_port)
           
 void disconnect()
          Closes the socket and the input and output streams associated with it
 void disconnect(boolean is_reconnect)
           
 java.util.List get(java.lang.String groupname)
          Retrieves the membership (list of Addresses) for a given group.
 java.net.InetAddress getBindAddress()
           
 Address getLocalAddress()
           
 java.lang.String getRouterHost()
           
 int getRouterPort()
           
 boolean isConnected()
           
static void main(java.lang.String[] args)
           
 Message receive()
          Receives a message from the router (blocking mode).
 void reconnect()
           
 void reconnect(int max_attempts)
          Tries to establish connection to router.
 boolean send(Message msg, java.lang.String groupname)
          Sends a message to the router.
 void setBindAddress(java.net.InetAddress bind_addr)
           
 void setConnectionListener(RouterStub.ConnectionListener conn_listener)
           
 void setRouterHost(java.lang.String router_host)
           
 void setRouterPort(int router_port)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final org.apache.commons.logging.Log log

conn_listener

protected RouterStub.ConnectionListener conn_listener
Constructor Detail

RouterStub

public RouterStub()

RouterStub

public RouterStub(java.lang.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
Method Detail

getBindAddress

public java.net.InetAddress getBindAddress()

setBindAddress

public void setBindAddress(java.net.InetAddress bind_addr)

getRouterHost

public java.lang.String getRouterHost()

setRouterHost

public void setRouterHost(java.lang.String router_host)

getRouterPort

public int getRouterPort()

setRouterPort

public void setRouterPort(int router_port)

isConnected

public boolean isConnected()

setConnectionListener

public void setConnectionListener(RouterStub.ConnectionListener conn_listener)

getLocalAddress

public Address getLocalAddress()
                        throws java.net.SocketException
Throws:
java.net.SocketException

connect

public void connect(java.lang.String groupname)
             throws java.lang.Exception
Register this process with the router under groupname.

Parameters:
groupname - The name of the group under which to register
Throws:
java.lang.Exception

connect

public void connect(java.lang.String groupname,
                    java.lang.String router_host,
                    int router_port)
             throws java.lang.Exception
Throws:
java.lang.Exception

disconnect

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


disconnect

public void disconnect(boolean is_reconnect)

get

public java.util.List get(java.lang.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.


send

public boolean send(Message msg,
                    java.lang.String groupname)
Sends a message to the router. Returns false if message cannot be sent (e.g. no connection to router, true otherwise.


receive

public Message receive()
                throws java.lang.Exception
Receives a message from the router (blocking mode). If the connection is down, false is returned, otherwise true

Throws:
java.lang.Exception

reconnect

public void reconnect(int max_attempts)
               throws java.lang.Exception
Tries to establish connection to router. Tries until router is up again.

Throws:
java.lang.Exception

reconnect

public void reconnect()
               throws java.lang.Exception
Throws:
java.lang.Exception

main

public static void main(java.lang.String[] args)


Copyright ? 1998-2006 Bela Ban. All Rights Reserved.