Class GossipRouter
- java.lang.Object
-
- org.jgroups.stack.GossipRouter
-
public class GossipRouter extends java.lang.ObjectRouter 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.
- Since:
- 2.1.1
- Version:
- $Id: GossipRouter.java,v 1.26.2.9 2009/02/12 20:05:54 vlada Exp $
- Author:
- Bela Ban, Ovidiu Feodorov
-
-
Field Summary
Fields Modifier and Type Field Description static byteCONNECTprotected ThreadFactorydefault_thread_factorystatic byteDISCONNECTstatic byteDUMPstatic longEXPIRY_TIMEstatic byteGET_RSPstatic byteGOSSIP_GETstatic longGOSSIP_REQUEST_TIMEOUTprotected org.apache.commons.logging.Loglogstatic intPORTstatic byteREGISTERstatic byteROUTER_GETstatic longROUTING_CLIENT_REPLY_TIMEOUTstatic byteSHUTDOWNprotected java.util.concurrent.ExecutorServicethread_poolprotected booleanthread_pool_enabledprotected longthread_pool_keep_alive_timeprotected intthread_pool_max_threadsprotected intthread_pool_min_threadsprotected java.util.concurrent.BlockingQueue<java.lang.Runnable>thread_pool_queueprotected booleanthread_pool_queue_enabledprotected intthread_pool_queue_max_sizeprotected java.lang.Stringthread_pool_rejection_policyprotected java.util.Timertimerstatic byteUNREGISTER
-
Constructor Summary
Constructors Constructor Description GossipRouter()GossipRouter(int port)GossipRouter(int port, java.lang.String bindAddressString)GossipRouter(int port, java.lang.String bindAddressString, long expiryTime)GossipRouter(int port, java.lang.String bindAddressString, long expiryTime, long gossipRequestTimeout, long routingClientReplyTimeout)Creates a gossip router on a given port bound to a specified interface and an expiry time (in msecs) until a cached 'gossip' member entry expires.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidcreate()JBoss MBean lifecycle operation.protected java.util.concurrent.ExecutorServicecreateThreadPool(int min_threads, int max_threads, long keep_alive_time, java.lang.String rejection_policy, java.util.concurrent.BlockingQueue<java.lang.Runnable> queue, ThreadFactory factory)voiddestroy()JBoss MBean lifecycle operation.java.lang.StringdumpRoutingTable()intgetBacklog()java.lang.StringgetBindAddress()ThreadFactorygetDefaultThreadPoolThreadFactory()longgetExpiryTime()longgetGossipRequestTimeout()Deprecated.longgetLingerTimeout()intgetPort()longgetRoutingClientReplyTimeout()Deprecated.longgetSocketReadTimeout()longgetThreadPoolKeepAliveTime()intgetThreadPoolMaxThreads()intgetThreadPoolMinThreads()intgetThreadPoolQueueMaxSize()java.lang.StringgetThreadPoolRejectionPolicy()booleanisDiscardLoopbacks()booleanisStarted()booleanisThreadPoolEnabled()booleanisThreadPoolQueueEnabled()static voidmain(java.lang.String[] args)voidsetBacklog(int backlog)voidsetBindAddress(java.lang.String bindAddress)voidsetDefaultThreadPoolThreadFactory(ThreadFactory factory)voidsetDiscardLoopbacks(boolean discard_loopbacks)voidsetExpiryTime(long expiryTime)voidsetGossipRequestTimeout(long gossipRequestTimeout)Deprecated.voidsetLingerTimeout(long linger_timeout)voidsetPort(int port)voidsetRoutingClientReplyTimeout(long routingClientReplyTimeout)Deprecated.voidsetSocketReadTimeout(long sock_read_timeout)voidsetThreadPoolEnabled(boolean thread_pool_enabled)voidsetThreadPoolKeepAliveTime(long thread_pool_keep_alive_time)voidsetThreadPoolMaxThreads(int thread_pool_max_threads)voidsetThreadPoolMinThreads(int thread_pool_min_threads)voidsetThreadPoolQueueEnabled(boolean thread_pool_queue_enabled)voidsetThreadPoolQueueMaxSize(int thread_pool_queue_max_size)voidsetThreadPoolRejectionPolicy(java.lang.String thread_pool_rejection_policy)voidstart()JBoss MBean lifecycle operation.voidstop()JBoss MBean lifecycle operation.static java.lang.Stringtype2String(int type)
-
-
-
Field Detail
-
CONNECT
public static final byte CONNECT
- See Also:
- Constant Field Values
-
DISCONNECT
public static final byte DISCONNECT
- See Also:
- Constant Field Values
-
REGISTER
public static final byte REGISTER
- See Also:
- Constant Field Values
-
GOSSIP_GET
public static final byte GOSSIP_GET
- See Also:
- Constant Field Values
-
ROUTER_GET
public static final byte ROUTER_GET
- See Also:
- Constant Field Values
-
GET_RSP
public static final byte GET_RSP
- See Also:
- Constant Field Values
-
UNREGISTER
public static final byte UNREGISTER
- See Also:
- Constant Field Values
-
DUMP
public static final byte DUMP
- See Also:
- Constant Field Values
-
SHUTDOWN
public static final byte SHUTDOWN
- See Also:
- Constant Field Values
-
PORT
public static final int PORT
- See Also:
- Constant Field Values
-
EXPIRY_TIME
public static final long EXPIRY_TIME
- See Also:
- Constant Field Values
-
GOSSIP_REQUEST_TIMEOUT
public static final long GOSSIP_REQUEST_TIMEOUT
- See Also:
- Constant Field Values
-
ROUTING_CLIENT_REPLY_TIMEOUT
public static final long ROUTING_CLIENT_REPLY_TIMEOUT
- See Also:
- Constant Field Values
-
thread_pool_min_threads
protected int thread_pool_min_threads
-
thread_pool_max_threads
protected int thread_pool_max_threads
-
thread_pool_keep_alive_time
protected long thread_pool_keep_alive_time
-
thread_pool_enabled
protected boolean thread_pool_enabled
-
thread_pool_queue_enabled
protected boolean thread_pool_queue_enabled
-
thread_pool_queue_max_size
protected int thread_pool_queue_max_size
-
thread_pool_rejection_policy
protected java.lang.String thread_pool_rejection_policy
-
thread_pool
protected java.util.concurrent.ExecutorService thread_pool
-
thread_pool_queue
protected java.util.concurrent.BlockingQueue<java.lang.Runnable> thread_pool_queue
-
default_thread_factory
protected ThreadFactory default_thread_factory
-
timer
protected java.util.Timer timer
-
log
protected final org.apache.commons.logging.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, long expiryTime)
-
GossipRouter
public GossipRouter(int port, java.lang.String bindAddressString, long expiryTime, long gossipRequestTimeout, long routingClientReplyTimeout)Creates a gossip router on a given port bound to a specified interface and an expiry time (in msecs) until a cached 'gossip' member entry expires.Remaining two parameters are deprecated and not used.
- Parameters:
port-bindAddressString-expiryTime-gossipRequestTimeout-routingClientReplyTimeout-
-
-
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 long getGossipRequestTimeout()
Deprecated.
-
setRoutingClientReplyTimeout
@Deprecated public void setRoutingClientReplyTimeout(long routingClientReplyTimeout)
Deprecated.
-
getRoutingClientReplyTimeout
@Deprecated public 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()
-
setDefaultThreadPoolThreadFactory
public void setDefaultThreadPoolThreadFactory(ThreadFactory factory)
-
getThreadPoolMinThreads
public int getThreadPoolMinThreads()
-
setThreadPoolMinThreads
public void setThreadPoolMinThreads(int thread_pool_min_threads)
-
getThreadPoolMaxThreads
public int getThreadPoolMaxThreads()
-
setThreadPoolMaxThreads
public void setThreadPoolMaxThreads(int thread_pool_max_threads)
-
getThreadPoolKeepAliveTime
public long getThreadPoolKeepAliveTime()
-
setThreadPoolKeepAliveTime
public void setThreadPoolKeepAliveTime(long thread_pool_keep_alive_time)
-
isThreadPoolEnabled
public boolean isThreadPoolEnabled()
-
setThreadPoolEnabled
public void setThreadPoolEnabled(boolean thread_pool_enabled)
-
isThreadPoolQueueEnabled
public boolean isThreadPoolQueueEnabled()
-
setThreadPoolQueueEnabled
public void setThreadPoolQueueEnabled(boolean thread_pool_queue_enabled)
-
getThreadPoolQueueMaxSize
public int getThreadPoolQueueMaxSize()
-
setThreadPoolQueueMaxSize
public void setThreadPoolQueueMaxSize(int thread_pool_queue_max_size)
-
getThreadPoolRejectionPolicy
public java.lang.String getThreadPoolRejectionPolicy()
-
setThreadPoolRejectionPolicy
public void setThreadPoolRejectionPolicy(java.lang.String thread_pool_rejection_policy)
-
type2String
public static java.lang.String type2String(int type)
-
create
public void create() throws java.lang.ExceptionJBoss MBean lifecycle operation.- Throws:
java.lang.Exception
-
start
public void start() throws java.lang.ExceptionJBoss MBean lifecycle operation. Called after create(). When this method is called, the managed attributes have already been set.
Brings the Router in fully functional state.- Throws:
java.lang.Exception
-
stop
public void stop()
JBoss MBean lifecycle operation. The JMX agent allways calls this method before destroy(). Close connections and frees resources.
-
destroy
public void destroy()
JBoss MBean lifecycle operation.
-
dumpRoutingTable
public java.lang.String dumpRoutingTable()
-
createThreadPool
protected java.util.concurrent.ExecutorService createThreadPool(int min_threads, int max_threads, long keep_alive_time, java.lang.String rejection_policy, java.util.concurrent.BlockingQueue<java.lang.Runnable> queue, ThreadFactory factory)
-
main
public static void main(java.lang.String[] args) throws java.lang.Exception- Throws:
java.lang.Exception
-
-