Class GossipRouter
- All Implemented Interfaces:
ConnectionListener,Receiver,DiagnosticsHandler.ProbeHandler
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumprotected static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Map<String, ConcurrentMap<Address, GossipRouter.Entry>> protected InetAddressprotected DiagnosticsHandlerprotected GossipRouter.DumpMessagesprotected booleanprotected longprotected booleanprotected intprotected final Logprotected intprotected intprotected static final BiConsumer<Short, Message> protected booleanprotected final Map<Address, ByteArrayDataOutputStream> protected intprotected longprotected intprotected final AtomicBooleanprotected BaseServerprotected SocketFactoryprotected ThreadFactoryprotected TLSprotected boolean -
Constructor Summary
ConstructorsConstructorDescriptionGossipRouter(String bind_addr, int local_port) GossipRouter(InetAddress bind_addr, int local_port) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddAddressMapping(Address sender, String group, Address addr, PhysicalAddress phys_addr, String logical_name) bindAddress(InetAddress addr) voidconnectionClosed(Connection conn) voidprotected static voiddump(GossipData data) dumpMessages(boolean d) booleanemitSuspectEvents(boolean flag) longexpiryTime(long t) protected ByteArrayDataOutputStreamgetOutputStream(Address mbr, int size) protected voidhandleGetMembersRequest(Address sender, DataInput in) protected voidhandleHeartbeat(Address sender) handleProbe(String... keys) Handles a probe.protected voidhandleRegister(Address sender, DataInput in) protected void(package private) static voidhelp()init()booleanjmx()jmx(boolean flag) intlingerTimeout(int t) static voidintmaxLength(int len) intmaxSendQueue(int s) booleannonBlockingSends(boolean b) intintintport()port(int port) protected GossipDatareadRequest(DataInput in) protected GossipDatareadRequest(DataInput in, GossipType type) longreaperInterval(long t) voidDelivers a message from a given sender to the applicationvoidReceive data from the given sendervoidreceive(Address sender, ByteBuffer buf) Delivers a message from a given sender to the applicationintrecvBufferSize(int s) protected voidremoveAddressMapping(String group, Address addr) protected voidremoveFromAddressMappings(Address client_addr) protected voidprotected voidroute(String group, Address dest, ByteBuffer buf) booleanrunning()protected voidsendToAllMembersInGroup(Set<Map.Entry<Address, GossipRouter.Entry>> dests, byte[] buf, int offset, int len) protected voidsendToAllMembersInGroup(Set<Map.Entry<Address, GossipRouter.Entry>> dests, ByteBuffer buf) protected voidsendToAllMembersInGroup(Set<Map.Entry<Address, GossipRouter.Entry>> dests, GossipData request) protected voidsendToMember(Address dest, byte[] buf, int offset, int len) protected voidsendToMember(Address dest, ByteBuffer buf) protected voidsendToMember(Address dest, GossipData request) start()Lifecycle operation.voidstop()Always called before destroy().String[]Returns a list of supported keystls()booleanuseNio()useNio(boolean flag)
-
Field Details
-
bind_addr
-
port
protected int port -
expiry_time
protected long expiry_time -
reaper_interval
protected long reaper_interval -
linger_timeout
protected int linger_timeout -
thread_factory
-
socket_factory
-
recv_buf_size
protected int recv_buf_size -
jmx
protected boolean jmx -
use_nio
protected boolean use_nio -
emit_suspect_events
protected boolean emit_suspect_events -
dump_msgs
-
max_length
protected int max_length -
server
-
running
-
log
-
diag
-
tls
-
non_blocking_sends
protected boolean non_blocking_sends -
max_send_queue
protected int max_send_queue -
address_mappings
-
output_streams
-
MSG_CONSUMER
-
-
Constructor Details
-
Method Details
-
localAddress
-
bindAddress
-
bindAddress
-
port
public int port() -
port
-
expiryTime
public long expiryTime() -
expiryTime
-
reaperInterval
public long reaperInterval() -
reaperInterval
-
lingerTimeout
public int lingerTimeout() -
lingerTimeout
-
recvBufferSize
public int recvBufferSize() -
recvBufferSize
-
threadPoolFactory
-
threadPoolFactory
-
socketFactory
-
socketFactory
-
jmx
public boolean jmx() -
jmx
-
useNio
public boolean useNio() -
useNio
-
emitSuspectEvents
public boolean emitSuspectEvents() -
emitSuspectEvents
-
dumpMessages
-
dumpMessages
-
dumpMessages
-
maxLength
public int maxLength() -
maxLength
-
diagHandler
-
tls
-
tls
-
nonBlockingSends
public boolean nonBlockingSends() -
nonBlockingSends
-
maxSendQueue
public int maxSendQueue() -
maxSendQueue
-
running
public boolean running() -
numRegisteredClusters
public int numRegisteredClusters() -
numRegisteredClients
public int numRegisteredClients() -
init
- Throws:
Exception
-
start
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:
Exception
-
stop
public void stop()Always called before destroy(). Close connections and frees resources. -
dumpRoutingTable
-
dumpAddressMappings
-
receive
Description copied from interface:ReceiverDelivers a message from a given sender to the application- Specified by:
receivein interfaceReceiver- Overrides:
receivein classReceiverAdapter- Parameters:
sender- The sender of the messagebuf- The buffer. An application typically de-serializes data from the buffer into objects used by the application. Note that when receive() returns, it is not safe to use the buffer any longer; if an application needs to use a buffer after this callback returns, it must make a copy.offset- The offset at which the received data startslength- The length of the received data
-
receive
Description copied from interface:ReceiverDelivers a message from a given sender to the application- Specified by:
receivein interfaceReceiver- Parameters:
sender- The sender of the messagebuf- The buffer. An application typically de-serializes data from the buffer into objects used by the application. Note that when receive() returns, it is not safe to use the buffer any longer; if an application needs to use a buffer after this callback returns, it must make a copy.Note that buf could be a direct ByteBuffer.
-
receive
Description copied from interface:ReceiverReceive data from the given sender -
handleProbe
Description copied from interface:DiagnosticsHandler.ProbeHandlerHandles a probe. For each key that is handled, the key and its result should be in the returned map.- Specified by:
handleProbein interfaceDiagnosticsHandler.ProbeHandler- Returns:
- A map of keys and values. A null return value is permissible.
-
supportedKeys
Description copied from interface:DiagnosticsHandler.ProbeHandlerReturns a list of supported keys- Specified by:
supportedKeysin interfaceDiagnosticsHandler.ProbeHandler
-
getOutputStream
-
handleHeartbeat
-
handleRegister
-
handleUnregister
-
handleGetMembersRequest
-
dump
-
connectionClosed
- Specified by:
connectionClosedin interfaceConnectionListener
-
connectionEstablished
- Specified by:
connectionEstablishedin interfaceConnectionListener
-
readRequest
-
readRequest
-
addAddressMapping
protected void addAddressMapping(Address sender, String group, Address addr, PhysicalAddress phys_addr, String logical_name) -
removeAddressMapping
-
removeFromAddressMappings
-
route
-
route
-
sendToAllMembersInGroup
protected void sendToAllMembersInGroup(Set<Map.Entry<Address, GossipRouter.Entry>> dests, GossipData request) -
sendToAllMembersInGroup
protected void sendToAllMembersInGroup(Set<Map.Entry<Address, GossipRouter.Entry>> dests, byte[] buf, int offset, int len) -
sendToAllMembersInGroup
protected void sendToAllMembersInGroup(Set<Map.Entry<Address, GossipRouter.Entry>> dests, ByteBuffer buf) -
sendToMember
-
sendToMember
-
sendToMember
-
main
- Throws:
Exception
-
help
static void help()
-