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

Author:
Bela Ban

Nested Class Summary
static interface RouterStub.ConnectionListener
           
static class RouterStub.ConnectionStatus
           
 
Field Summary
protected  java.net.InetAddress bind_addr
           
protected  RouterStub.ConnectionListener conn_listener
           
protected  RouterStub.ConnectionStatus connectionState
           
protected  java.io.DataInputStream input
           
protected  java.util.concurrent.locks.ReentrantLock lock
           
protected static Log log
           
protected  java.io.DataOutputStream output
           
protected  TUNNEL.StubReceiver receiver
           
protected  java.lang.String router_host
           
protected  int router_port
           
protected  java.net.Socket sock
           
protected  int sock_conn_timeout
           
protected  int sock_read_timeout
           
protected  boolean tcp_nodelay
           
 
Constructor Summary
RouterStub(java.lang.String routerHost, int routerPort, java.net.InetAddress bindAddress, RouterStub.ConnectionListener l)
          Creates a stub for a remote Router object.
 
Method Summary
protected  void _doConnect()
           
 void checkConnection()
          Checks whether the connection is open
 void connect(java.lang.String group, Address addr, java.lang.String logical_name, java.util.List<PhysicalAddress> phys_addrs)
          Register this process with the router under group.
protected  void connectionStateChanged(RouterStub.ConnectionStatus newState)
           
 void destroy()
           
 void disconnect(java.lang.String group, Address addr)
           
 void doConnect()
           
 RouterStub.ConnectionStatus getConnectionStatus()
           
 java.net.InetSocketAddress getGossipRouterAddress()
           
 java.io.DataInputStream getInputStream()
           
 java.util.List<PingData> getMembers(java.lang.String group)
           
 TUNNEL.StubReceiver getReceiver()
           
 java.net.Socket getSocket()
           
 int getSocketConnectionTimeout()
           
 int getSocketReadTimeout()
           
 void interrupt()
           
 boolean isConnected()
           
 boolean isTcpNoDelay()
           
 void join(long wait)
           
 void sendToAllMembers(java.lang.String group, byte[] data, int offset, int length)
           
 void sendToMember(java.lang.String group, Address dest, byte[] data, int offset, int length)
           
 void setReceiver(TUNNEL.StubReceiver receiver)
           
 void setSocketConnectionTimeout(int sock_conn_timeout)
           
 void setSocketReadTimeout(int sock_read_timeout)
           
 void setTcpNoDelay(boolean tcp_nodelay)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

router_host

protected final java.lang.String router_host

router_port

protected final int router_port

sock

protected java.net.Socket sock

output

protected java.io.DataOutputStream output

input

protected java.io.DataInputStream input

connectionState

protected volatile RouterStub.ConnectionStatus connectionState

log

protected static final Log log

conn_listener

protected final RouterStub.ConnectionListener conn_listener

bind_addr

protected final java.net.InetAddress bind_addr

sock_conn_timeout

protected int sock_conn_timeout

sock_read_timeout

protected int sock_read_timeout

tcp_nodelay

protected boolean tcp_nodelay

receiver

protected volatile TUNNEL.StubReceiver receiver

lock

protected final java.util.concurrent.locks.ReentrantLock lock
Constructor Detail

RouterStub

public RouterStub(java.lang.String routerHost,
                  int routerPort,
                  java.net.InetAddress bindAddress,
                  RouterStub.ConnectionListener l)
Creates a stub for a remote Router object.

Parameters:
routerHost - The name of the router's host
routerPort - The router's port
Throws:
java.net.SocketException
Method Detail

setReceiver

public void setReceiver(TUNNEL.StubReceiver receiver)

getReceiver

public TUNNEL.StubReceiver getReceiver()

isTcpNoDelay

public boolean isTcpNoDelay()

setTcpNoDelay

public void setTcpNoDelay(boolean tcp_nodelay)

interrupt

public void interrupt()

join

public void join(long wait)
          throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

getSocketConnectionTimeout

public int getSocketConnectionTimeout()

setSocketConnectionTimeout

public void setSocketConnectionTimeout(int sock_conn_timeout)

getSocketReadTimeout

public int getSocketReadTimeout()

setSocketReadTimeout

public void setSocketReadTimeout(int sock_read_timeout)

isConnected

public boolean isConnected()

getConnectionStatus

public RouterStub.ConnectionStatus getConnectionStatus()

connect

public void connect(java.lang.String group,
                    Address addr,
                    java.lang.String logical_name,
                    java.util.List<PhysicalAddress> phys_addrs)
             throws java.lang.Exception
Register this process with the router under group.

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

doConnect

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

_doConnect

protected void _doConnect()
                   throws java.lang.Exception
Throws:
java.lang.Exception

checkConnection

public void checkConnection()
Checks whether the connection is open


disconnect

public void disconnect(java.lang.String group,
                       Address addr)

destroy

public void destroy()

getSocket

public java.net.Socket getSocket()

getMembers

public java.util.List<PingData> getMembers(java.lang.String group)
                                    throws java.lang.Exception
Throws:
java.lang.Exception

getGossipRouterAddress

public java.net.InetSocketAddress getGossipRouterAddress()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

sendToAllMembers

public void sendToAllMembers(java.lang.String group,
                             byte[] data,
                             int offset,
                             int length)
                      throws java.lang.Exception
Throws:
java.lang.Exception

sendToMember

public void sendToMember(java.lang.String group,
                         Address dest,
                         byte[] data,
                         int offset,
                         int length)
                  throws java.lang.Exception
Throws:
java.lang.Exception

getInputStream

public java.io.DataInputStream getInputStream()

connectionStateChanged

protected void connectionStateChanged(RouterStub.ConnectionStatus newState)


Copyright © 1998-2012 Bela Ban / Red Hat. All Rights Reserved.