## org.jgroups.stack
Class GossipRouter

    java.lang.Object
      org.jgroups.stack.GossipRouter

    public class GossipRouter

extends java.lang.Object

Router for TCP based group comunication (using layer TCP instead of UDP). Instead of the TCP layer sending packets point-to-point to each other member, it sends the packet to the router which - depending on the target address - multicasts or unicasts it to the group / or single member.

This class is especially interesting for applets which cannot directly make connections (neither UDP nor TCP) to a host different from the one they were loaded from. Therefore, an applet would create a normal channel plus protocol stack, but the bottom layer would have to be the TCP layer which sends all packets point-to-point (over a TCP connection) to the router, which in turn forwards them to their end location(s) (also over TCP). A centralized router would therefore have to be running on the host the applet was loaded from.

An alternative for running JGroups in an applet (IP multicast is not allows in applets as of 1.2), is to use point-to-point UDP communication via the gossip server. However, then the appplet has to be signed which involves additional administrative effort on the part of the user.

Note that a GossipRouter is also a good way of running JGroups in Amazon's EC2 environment which (as of summer 09) doesn't support IP multicasting.

Since:
  2.1.1
Author:
  Bela Ban, Vladimir Blagojevic, Ovidiu Feodorov <ovidiuf@users.sourceforge.net>

Nested Class Summary
`static interface` `GossipRouter.ConnectionTearListener`

Field Summary
`static byte` `CLOSE`
`static byte` `CONNECT`
`static byte` `CONNECT_OK`
`protected java.util.List<GossipRouter.ConnectionTearListener>` `connectionTearListeners`
`protected ThreadFactory` `default_thread_factory`
`static byte` `DISCONNECT`
`static byte` `DISCONNECT_OK`
`static byte` `GOSSIP_GET`
`protected Log` `log`
`static byte` `MESSAGE`
`static byte` `OP_FAIL`
`static byte` `PING`
`static int` `PORT`
`static byte` `SUSPECT`
`protected java.util.Timer` `timer`

Constructor Summary
`GossipRouter()`
`GossipRouter(int port)`
`GossipRouter(int port, java.lang.String bindAddressString)`
`GossipRouter(int port, java.lang.String bindAddressString, boolean jmx)`
`GossipRouter(int port, java.lang.String bindAddressString, boolean jmx, long expiryTime)`

Method Summary
`void` `clear()`
`void` `destroy()`
`java.lang.String` `dumpAddresssMappings()`
`java.lang.String` `dumpRoutingTable()`
`java.lang.String` `dumpRoutingTableDetailed()`
`int` `getBacklog()`
`java.lang.String` `getBindAddress()`
`ThreadFactory` `getDefaultThreadPoolThreadFactory()`
`long` `getExpiryTime()`
`static long` `getGossipRequestTimeout()` Deprecated.
`long` `getLingerTimeout()`
`int` `getPort()`
`static long` `getRoutingClientReplyTimeout()` Deprecated.
`long` `getSocketReadTimeout()`
`boolean` `isDiscardLoopbacks()`
`boolean` `isRunning()`
`boolean` `isStarted()`
`static void` `main(java.lang.String[] args)`
`void` `setBacklog(int backlog)`
`void` `setBindAddress(java.lang.String bindAddress)`
`void` `setDiscardLoopbacks(boolean discard_loopbacks)`
`void` `setExpiryTime(long expiryTime)`
`void` `setGossipRequestTimeout(long gossipRequestTimeout)` Deprecated.
`void` `setLingerTimeout(long linger_timeout)`
`void` `setPort(int port)`
`void` `setRoutingClientReplyTimeout(long routingClientReplyTimeout)` Deprecated.
`void` `setSocketReadTimeout(long sock_read_timeout)`
`void` `start()` Lifecycle operation.
`void` `stop()` Always called before destroy().
`static java.lang.String` `type2String(int type)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### CONNECT

    public static final byte CONNECT

See Also:
  Constant Field Values

### DISCONNECT

    public static final byte DISCONNECT

See Also:
  Constant Field Values

### GOSSIP_GET

    public static final byte GOSSIP_GET

See Also:
  Constant Field Values

### MESSAGE

    public static final byte MESSAGE

See Also:
  Constant Field Values

### SUSPECT

    public static final byte SUSPECT

See Also:
  Constant Field Values

### PING

    public static final byte PING

See Also:
  Constant Field Values

### CLOSE

    public static final byte CLOSE

See Also:
  Constant Field Values

### CONNECT_OK

    public static final byte CONNECT_OK

See Also:
  Constant Field Values

### OP_FAIL

    public static final byte OP_FAIL

See Also:
  Constant Field Values

### DISCONNECT_OK

    public static final byte DISCONNECT_OK

See Also:
  Constant Field Values

### PORT

    public static final int PORT

See Also:
  Constant Field Values

### connectionTearListeners

    protected java.util.List<GossipRouter.ConnectionTearListener> connectionTearListeners

### default_thread_factory

    protected ThreadFactory default_thread_factory

### timer

    protected java.util.Timer timer

### log

    protected final Log log

Constructor Detail

### GossipRouter

    public GossipRouter()

### GossipRouter

    public GossipRouter(int port)

### GossipRouter

    public GossipRouter(int port,
                        java.lang.String bindAddressString)

### GossipRouter

    public GossipRouter(int port,
                        java.lang.String bindAddressString,
                        boolean jmx)

### GossipRouter

    public GossipRouter(int port,
                        java.lang.String bindAddressString,
                        boolean jmx,
                        long expiryTime)

Method Detail

### setPort

    public void setPort(int port)

### getPort

    public int getPort()

### setBindAddress

    public void setBindAddress(java.lang.String bindAddress)

### getBindAddress

    public java.lang.String getBindAddress()

### getBacklog

    public int getBacklog()

### setBacklog

    public void setBacklog(int backlog)

### setExpiryTime

    public void setExpiryTime(long expiryTime)

### getExpiryTime

    public long getExpiryTime()

### setGossipRequestTimeout

    @Deprecated
    public void setGossipRequestTimeout(long gossipRequestTimeout)

  Deprecated.

### getGossipRequestTimeout

    @Deprecated
    public static long getGossipRequestTimeout()

  Deprecated.

### setRoutingClientReplyTimeout

    @Deprecated
    public void setRoutingClientReplyTimeout(long routingClientReplyTimeout)

  Deprecated.

### getRoutingClientReplyTimeout

    @Deprecated
    public static long getRoutingClientReplyTimeout()

  Deprecated.

### isStarted

    public boolean isStarted()

### isDiscardLoopbacks

    public boolean isDiscardLoopbacks()

### setDiscardLoopbacks

    public void setDiscardLoopbacks(boolean discard_loopbacks)

### getLingerTimeout

    public long getLingerTimeout()

### setLingerTimeout

    public void setLingerTimeout(long linger_timeout)

### getSocketReadTimeout

    public long getSocketReadTimeout()

### setSocketReadTimeout

    public void setSocketReadTimeout(long sock_read_timeout)

### getDefaultThreadPoolThreadFactory

    public ThreadFactory getDefaultThreadPoolThreadFactory()

### type2String

    public static java.lang.String type2String(int type)

### start

    public void start()
               throws java.lang.Exception

  Lifecycle operation. Called after create(). When this method is called, the managed attributes have already been set.
  Brings the Router into a fully functional state.

  Throws:
    `java.lang.Exception`

### stop

    public void stop()

  Always called before destroy(). Close connections and frees resources.

### clear

    public void clear()

### destroy

    public void destroy()

### isRunning

    public boolean isRunning()

### dumpRoutingTable

    public java.lang.String dumpRoutingTable()

### dumpRoutingTableDetailed

    public java.lang.String dumpRoutingTableDetailed()

### dumpAddresssMappings

    public java.lang.String dumpAddresssMappings()

### main

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

  Throws:
    `java.lang.Exception`

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