Package org.jgroups.protocols
Class TUNNEL
- java.lang.Object
-
- org.jgroups.stack.Protocol
-
- org.jgroups.protocols.TP
-
- org.jgroups.protocols.TUNNEL
-
- All Implemented Interfaces:
Lifecycle,DiagnosticsHandler.ProbeHandler,RouterStub.StubReceiver
public class TUNNEL extends TP implements RouterStub.StubReceiver
Replacement for UDP. Instead of sending packets via UDP, a TCP connection is opened to a Router (using the RouterStub client-side stub), the IP address/port of which was given using channel propertiesrouter_hostandrouter_port. All outgoing traffic is sent via this TCP socket to the Router which distributes it to all connected TUNNELs in this group. Incoming traffic received from Router will simply be passed up the stack.A TUNNEL layer can be used to penetrate a firewall, most firewalls allow creating TCP connections to the outside world, however, they do not permit outside hosts to initiate a TCP connection to a host inside the firewall. Therefore, the connection created by the inside host is reused by Router to send traffic from an outside host to a host inside the firewall.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classTUNNEL.DefaultTUNNELPolicystatic interfaceTUNNEL.TUNNELPolicy
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Stringgossip_router_hostsprotected java.util.List<java.net.InetSocketAddress>gossip_routersprotected longheartbeat_intervalprotected longheartbeat_timeoutprotected longreconnect_intervalprotected java.net.DatagramSocketsockprotected RouterStubManagerstubManagerprotected booleantcp_nodelayprotected TUNNEL.TUNNELPolicytunnel_policyprotected booleanuse_nio-
Fields inherited from class org.jgroups.protocols.TP
avg_batch_size, bind_addr, bind_port, bundler, bundler_type, cluster_name, connectLock, diag_handler, external_addr, external_port, header, is_trace, last_discovery_request, LIST, local_physical_addr, local_transport, local_transport_class, log_discard_msgs, log_discard_msgs_version, logical_addr_cache, logical_addr_cache_expiration, logical_addr_cache_max_size, logical_addr_cache_reaper, logical_addr_cache_reaper_interval, loopback_copy, loopback_separate_thread, members, message_processing_policy, MIN_WAIT_BETWEEN_DISCOVERIES, msg_factory, msg_factory_class, MSG_OVERHEAD, msg_processing_policy, msg_stats, MULTICAST, port_range, print_function, receive_interfaces, receive_on_all_interfaces, socket_factory, suppress_log_different_cluster, suppress_log_different_version, suppress_time_different_cluster_warnings, suppress_time_different_version_warnings, thread_factory, thread_naming_pattern, thread_pool, time_service, time_service_interval, timer, timer_handle_non_blocking_tasks, use_virtual_threads, view, who_has_cache, who_has_cache_timeout
-
Fields inherited from class org.jgroups.stack.Protocol
after_creation_hook, down_prot, ergonomics, id, local_addr, log, stack, stats, up_prot
-
-
Constructor Summary
Constructors Constructor Description TUNNEL()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddestroy()This method is called on aJChannel.close().private voiddisconnectStub()java.lang.Objectdown(Event evt)An event is to be sent down the stack.java.lang.StringgetInfo()protected PhysicalAddressgetPhysicalAddress()longgetReconnectInterval()RouterStubManagergetStubManager()voidinit()Called after a protocol has been created and before the protocol is started.booleanisHeartbeatTaskRunning()booleanisReconnectorTaskRunning()booleanisTcpNodelay()booleanisTimeoutCheckTaskRunning()java.lang.Stringprint()java.lang.StringprintReconnectList()java.lang.StringprintStubs()voidreceive(GossipData data)protected voidsendTo(Address dest, byte[] buf, int offset, int length)voidsendToAll(byte[] data, int offset, int length)Fetches the physical addrs for all mbrs and sends the msg to each physical address.protected voidsendUnicast(Address dest, byte[] data, int offset, int length)voidsendUnicast(PhysicalAddress dest, byte[] data, int offset, int length)Send a unicast to a member.TUNNELsetGossipRouterHosts(java.lang.String hosts)TUNNELsetReconnectInterval(long r)TUNNELsetTcpNodelay(boolean nd)TUNNELsetTUNNELPolicy(TUNNEL.TUNNELPolicy policy)booleansupportsMulticasting()We can simply send a message with dest == null and the GossipRouter will take care of routing it to all members in the clusterjava.lang.StringtoString()booleanuseNio()TUNNELuseNio(boolean use_nio)-
Methods inherited from class org.jgroups.protocols.TP
_send, addPhysicalAddressToCache, addPhysicalAddressToCache, avgBatchSize, bundler, clearDifferentClusterCache, clearDifferentVersionCache, clearLogicalAddressCache, createBundler, createDiagnosticsHandler, defaultHeaders, disableDiagnostics, doSend, down, dumpTimerTasks, enableBlockingTimerTasks, enableDiagnostics, evictLogicalAddressCache, evictLogicalAddressCache, fetchLocalAddresses, fetchPhysicalAddrs, fetchResponsesFromDiscoveryProtocol, getAllPhysicalAddressesFromCache, getAvgBatchSize, getBindAddr, getBindAddress, getBindPort, getBundler, getBundlerClass, getBundlerType, getClusterName, getClusterNameAscii, getDiagnosticsHandler, getDifferentClusterMessages, getDifferentVersionMessages, getExternalAddr, getExternalPort, getLocalPhysicalAddress, getLocalTransport, getLogDiscardMessages, getLogDiscardMessagesVersion, getLogicalAddrCacheExpiration, getLogicalAddrCacheMaxSize, getLogicalAddrCacheReaperInterval, getLogicalAddressCache, getMessageFactory, getMessageFactoryClass, getMessageStats, getMsgFactoryClass, getNumThreads, getNumTimerTasks, getPhysicalAddressFromCache, getPortRange, getReceiveInterfaces, getSocketFactory, getSuppressTimeDifferentClusterWarnings, getSuppressTimeDifferentVersionWarnings, getThreadFactory, getThreadNamingPattern, getThreadPool, getThreadPoolThreadFactory, getTimer, getTimerClass, getTimerThreads, getTimeService, getTimeServiceInterval, getWhoHasCacheTimeout, handleConnect, handleDisconnect, handleMessageBatch, handleProbe, handleSingleMessage, isLogicalAddressCacheReaperRunning, isMulticastCapable, isReceiveOnAllInterfaces, isTrace, isTrace, localPhysicalAddress, logDiscardMsgs, logDiscardMsgs, logDiscardMsgsVersion, logDiscardMsgsVersion, loggerType, loopback, loopbackCopy, loopbackCopy, loopbackSeparateThread, loopbackSeparateThread, passBatchUp, passMessageUp, printLogicalAddressCache, printWhoHasCache, processBatch, receive, receive, receiveOnAllInterfaces, receiveOnAllInterfaces, registerLocalAddress, registerProbeHandler, removeCancelledTimerTasks, removeLogicalAddressFromCache, resetStats, sameCluster, setAddress, setBindAddr, setBindAddress, setBindPort, setBindToAllInterfaces, setBundler, setBundlerType, setDiagnosticsHandler, setExternalAddr, setExternalPort, setInAllThreadFactories, setLevel, setLocalTransport, setLocalTransport, setLogDiscardMessages, setLogDiscardMessagesVersion, setLogicalAddrCacheExpiration, setLogicalAddrCacheMaxSize, setLogicalAddrCacheReaperInterval, setMessageFactory, setMessageProcessingPolicy, setMsgFactoryClass, setPortRange, setSocketFactory, setSourceAddress, setSuppressTimeDifferentClusterWarnings, setSuppressTimeDifferentVersionWarnings, setThreadFactory, setThreadNames, setThreadPool, setThreadPoolThreadFactory, setTimer, setTimeService, setTimeServiceInterval, setWhoHasCacheTimeout, start, startDiagnostics, stop, stopDiagnostics, supportedKeys, timestamp, unicastDestMismatch, unregisterProbeHandler, unsetThreadNames, useVirtualThreads, useVirtualThreads, versionMatch, view
-
Methods inherited from class org.jgroups.stack.Protocol
accept, addr, addr, afterCreationHook, enableStats, getAddress, getComponents, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getLog, getName, getProtocolStack, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, level, parse, providedDownServices, providedUpServices, requiredDownServices, requiredUpServices, resetStatistics, setDownProtocol, setErgonomics, setId, setProtocolStack, setUpProtocol, setValue, statsEnabled, up, up, up
-
-
-
-
Field Detail
-
reconnect_interval
protected long reconnect_interval
-
tcp_nodelay
protected boolean tcp_nodelay
-
use_nio
protected boolean use_nio
-
gossip_router_hosts
protected java.lang.String gossip_router_hosts
-
heartbeat_interval
protected long heartbeat_interval
-
heartbeat_timeout
protected long heartbeat_timeout
-
gossip_routers
protected final java.util.List<java.net.InetSocketAddress> gossip_routers
-
tunnel_policy
protected TUNNEL.TUNNELPolicy tunnel_policy
-
sock
protected java.net.DatagramSocket sock
-
stubManager
protected volatile RouterStubManager stubManager
-
-
Method Detail
-
getReconnectInterval
public long getReconnectInterval()
-
setReconnectInterval
public TUNNEL setReconnectInterval(long r)
-
isTcpNodelay
public boolean isTcpNodelay()
-
setTcpNodelay
public TUNNEL setTcpNodelay(boolean nd)
-
useNio
public boolean useNio()
-
useNio
public TUNNEL useNio(boolean use_nio)
-
supportsMulticasting
public boolean supportsMulticasting()
We can simply send a message with dest == null and the GossipRouter will take care of routing it to all members in the cluster- Specified by:
supportsMulticastingin classTP
-
setGossipRouterHosts
public TUNNEL setGossipRouterHosts(java.lang.String hosts) throws java.net.UnknownHostException
- Throws:
java.net.UnknownHostException
-
isReconnectorTaskRunning
public boolean isReconnectorTaskRunning()
-
isHeartbeatTaskRunning
public boolean isHeartbeatTaskRunning()
-
isTimeoutCheckTaskRunning
public boolean isTimeoutCheckTaskRunning()
-
print
public java.lang.String print()
-
printStubs
public java.lang.String printStubs()
-
printReconnectList
public java.lang.String printReconnectList()
-
getStubManager
public RouterStubManager getStubManager()
-
setTUNNELPolicy
public TUNNEL setTUNNELPolicy(TUNNEL.TUNNELPolicy policy)
-
init
public void init() throws java.lang.ExceptionDescription copied from class:ProtocolCalled after a protocol has been created and before the protocol is started. Attributes are already set. Other protocols are not yet connected and events cannot yet be sent.
-
destroy
public void destroy()
Description copied from class:ProtocolThis method is called on aJChannel.close(). Does some cleanup; after the call, the VM will terminate
-
disconnectStub
private void disconnectStub()
-
down
public java.lang.Object down(Event evt)
Description copied from class:ProtocolAn event is to be sent down the stack. A protocol may want to examine its type and perform some action on it, depending on the event's type. If the event is a message MSG, then the protocol may need to add a header to it (or do nothing at all) before sending it down the stack usingdown_prot.down().
-
receive
public void receive(GossipData data)
- Specified by:
receivein interfaceRouterStub.StubReceiver
-
sendToAll
public void sendToAll(byte[] data, int offset, int length) throws java.lang.ExceptionDescription copied from class:TPFetches the physical addrs for all mbrs and sends the msg to each physical address. Asks discovery for missing members' physical addresses if needed
-
sendUnicast
public void sendUnicast(PhysicalAddress dest, byte[] data, int offset, int length) throws java.lang.Exception
Description copied from class:TPSend a unicast to a member. Note that the destination address is a *physical*, not a logical address- Specified by:
sendUnicastin classTP- Parameters:
dest- Must be a non-null unicast addressdata- The data to be sent. This is not a copy, so don't modify it- Throws:
java.lang.Exception
-
sendTo
protected void sendTo(Address dest, byte[] buf, int offset, int length) throws java.lang.Exception
-
sendUnicast
protected void sendUnicast(Address dest, byte[] data, int offset, int length) throws java.lang.Exception
- Throws:
java.lang.Exception
-
getPhysicalAddress
protected PhysicalAddress getPhysicalAddress()
- Specified by:
getPhysicalAddressin classTP
-
-