Package org.jgroups.protocols
Class TUNNEL
- java.lang.Object
-
- org.jgroups.stack.Protocol
-
- org.jgroups.protocols.TP
-
- org.jgroups.protocols.TUNNEL
-
- All Implemented Interfaces:
AdditionalJmxObjects
,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_host
androuter_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.
- Author:
- Bela Ban, Vladimir Blagojevic
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
TUNNEL.TUNNELPolicy
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
gossip_router_hosts
protected java.util.List<java.net.InetSocketAddress>
gossip_routers
protected long
reconnect_interval
protected java.net.DatagramSocket
sock
protected RouterStubManager
stubManager
protected boolean
tcp_nodelay
protected TUNNEL.TUNNELPolicy
tunnel_policy
protected boolean
use_nio
-
Fields inherited from class org.jgroups.protocols.TP
avg_batch_size, bind_addr, bind_port, bundler, bundler_capacity, bundler_num_spins, bundler_type, bundler_wait_strategy, cluster_name, connectLock, diag_enable_tcp, diag_enable_udp, diag_handler, diagnostics_addr, diagnostics_bind_addr, diagnostics_bind_interfaces, diagnostics_passcode, diagnostics_port, diagnostics_port_range, diagnostics_ttl, drop_when_full, enable_diagnostics, external_addr, external_port, header, internal_pool, internal_thread_factory, is_trace, last_discovery_request, LIST, local_addr, local_physical_addr, 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, max_bundle_size, members, message_processing_policy, MIN_WAIT_BETWEEN_DISCOVERIES, MSG_OVERHEAD, msg_processing_max_buffer_size, msg_processing_policy, msg_stats, MULTICAST, port_range, preregistered_probe_handlers, print_function, receive_interfaces, receive_on_all_interfaces, socket_factory, spawn_thread_on_full_pool, suppress_log_different_cluster, suppress_log_different_version, suppress_time_different_cluster_warnings, suppress_time_different_version_warnings, thread_dump_path, thread_dumps, thread_dumps_threshold, thread_factory, thread_naming_pattern, thread_pool, thread_pool_enabled, thread_pool_keep_alive_time, thread_pool_max_threads, thread_pool_min_threads, time_service, time_service_interval, timer, timer_handle_non_blocking_tasks, use_common_fork_join_pool, use_fibers, use_fork_join_pool, use_ip_addrs, view, who_has_cache, who_has_cache_timeout
-
Fields inherited from class org.jgroups.stack.Protocol
after_creation_hook, down_prot, ergonomics, id, log, stack, stats, up_prot
-
-
Constructor Summary
Constructors Constructor Description TUNNEL()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
destroy()
This method is called on aJChannel.close()
.java.lang.Object
down(Event evt)
An event is to be sent down the stack.java.lang.String
getInfo()
protected PhysicalAddress
getPhysicalAddress()
long
getReconnectInterval()
RouterStubManager
getStubManager()
void
init()
Called after instance has been created (null constructor) and before protocol is started.java.lang.String
print()
java.lang.String
printReconnectList()
java.lang.String
printStubs()
void
receive(GossipData data)
void
sendMulticast(byte[] data, int offset, int length)
Send to all members in the group.protected void
sendToSingleMember(Address dest, byte[] buf, int offset, int length)
protected void
sendUnicast(Address dest, byte[] data, int offset, int length)
void
sendUnicast(PhysicalAddress dest, byte[] data, int offset, int length)
Send a unicast to 1 member.void
setGossipRouterHosts(java.lang.String hosts)
void
setReconnectInterval(long reconnect_interval)
void
setTUNNELPolicy(TUNNEL.TUNNELPolicy policy)
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 clusterjava.lang.String
toString()
-
Methods inherited from class org.jgroups.protocols.TP
_send, addPhysicalAddressToCache, addPhysicalAddressToCache, avgBatchSize, bundler, bundlerNumSpins, bundlerNumSpins, bundlerStats, bundlerStatsReset, bundlerWaitStrategy, bundlerWaitStrategy, clearDifferentClusterCache, clearDifferentVersionCache, clearLogicalAddressCache, createBundler, createDiagnosticsHandler, createThreadPool, diagEnableTcp, diagEnableUdp, diagTcpEnabled, disableDiagnostics, doSend, down, dumpTimerTasks, enableBlockingTimerTasks, enableDiagnostics, evictLogicalAddressCache, evictLogicalAddressCache, fetchLocalAddresses, fetchPhysicalAddrs, fetchResponsesFromDiscoveryProtocol, getAllPhysicalAddressesFromCache, getAvgBatchSize, getBindAddress, getBindPort, getBundler, getBundlerBufferSize, getBundlerCapacity, getBundlerClass, getClusterName, getClusterNameAscii, getDiagnosticsHandler, getDifferentClusterMessages, getDifferentVersionMessages, getDropWhenFull, getInternalThreadPool, getInternalThreadPoolSize, getInternalThreadPoolSizeLargest, getInternalThreadPoolThreadFactory, getJmxObjects, getLocalAddress, getLocalPhysicalAddress, getLogDiscardMessages, getLogDiscardMessagesVersion, getMaxBundleSize, getMessageProcessingMaxBufferSize, getMessageStats, getNumberOfThreadDumps, getNumMessagesSent, getNumThreads, getNumTimerTasks, getPhysicalAddressFromCache, getPortRange, getReceiveInterfaces, getSocketFactory, getThreadDumpsThreshold, getThreadFactory, getThreadNamingPattern, getThreadPool, getThreadPoolKeepAliveTime, getThreadPoolMaxThreads, getThreadPoolMinThreads, getThreadPoolSize, getThreadPoolSizeActive, getThreadPoolSizeLargest, getThreadPoolThreadFactory, getTimer, getTimerClass, getTimerThreads, getTimeService, getUseIpAddresses, handleConnect, handleDisconnect, handleMessageBatch, handleProbe, handleSingleMessage, incrBatchesSent, incrNumSingleMsgsSent, isDiagnosticsEnabled, isDiagnosticsRunning, isDiagUdEnabled, isLogicalAddressCacheReaperRunning, isMulticastCapable, isReceiveOnAllInterfaces, localAddress, loggerType, loopback, passBatchUp, passMessageUp, printLogicalAddressCache, printWhoHasCache, processBatch, receive, receive, registerLocalAddress, registerProbeHandler, removeCancelledTimerTasks, removeLogicalAddressFromCache, resetStats, resetThreadDumps, runInNewThread, send, sendToMembers, setBindAddress, setBindPort, setBindToAllInterfaces, setBundler, setBundlerCapacity, setDiagnosticsEnabled, setDiagnosticsHandler, setDropWhenFull, setInAllThreadFactories, setInternalThreadPool, setInternalThreadPoolThreadFactory, setLevel, setLogDiscardMessages, setLogDiscardMessagesVersion, setMaxBundleSize, setMessageProcessingPolicy, setPortRange, setSocketFactory, setSourceAddress, setThreadDumpsThreshold, setThreadFactory, setThreadNames, setThreadPool, setThreadPoolKeepAliveTime, setThreadPoolMaxThreads, setThreadPoolMinThreads, setThreadPoolThreadFactory, setTimer, setTimeService, shutdownThreadPool, start, startDiagnostics, stop, stopDiagnostics, submitToThreadPool, submitToThreadPool, supportedKeys, timestamp, unicastDestMismatch, unregisterProbeHandler, unsetThreadNames, useFibers, versionMatch, view
-
Methods inherited from class org.jgroups.stack.Protocol
accept, afterCreationHook, enableStats, getConfigurableObjects, 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
-
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
-
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:
supportsMulticasting
in classTP
-
setGossipRouterHosts
public void setGossipRouterHosts(java.lang.String hosts) throws java.net.UnknownHostException
- Throws:
java.net.UnknownHostException
-
print
public java.lang.String print()
-
printStubs
public java.lang.String printStubs()
-
printReconnectList
public java.lang.String printReconnectList()
-
getStubManager
public RouterStubManager getStubManager()
-
getReconnectInterval
public long getReconnectInterval()
-
setReconnectInterval
public void setReconnectInterval(long reconnect_interval)
-
setTUNNELPolicy
public void setTUNNELPolicy(TUNNEL.TUNNELPolicy policy)
-
init
public void init() throws java.lang.Exception
Description copied from class:Protocol
Called after instance has been created (null constructor) and before protocol is started. Properties are already set. Other protocols are not yet connected and events cannot yet be sent.
-
destroy
public void destroy()
Description copied from class:Protocol
This method is called on aJChannel.close()
. Does some cleanup; after the call the VM will terminate
-
down
public java.lang.Object down(Event evt)
Description copied from class:Protocol
An 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:
receive
in interfaceRouterStub.StubReceiver
-
sendMulticast
public void sendMulticast(byte[] data, int offset, int length) throws java.lang.Exception
Description copied from class:TP
Send to all members in the group. UDP would use an IP multicast message, whereas TCP would send N messages, one for each member- Specified by:
sendMulticast
in classTP
- Parameters:
data
- The data to be sent. This is not a copy, so don't modify it- Throws:
java.lang.Exception
-
sendUnicast
public void sendUnicast(PhysicalAddress dest, byte[] data, int offset, int length) throws java.lang.Exception
Description copied from class:TP
Send a unicast to 1 member. Note that the destination address is a *physical*, not a logical address- Specified by:
sendUnicast
in 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
-
sendToSingleMember
protected void sendToSingleMember(Address dest, byte[] buf, int offset, int length) throws java.lang.Exception
- Overrides:
sendToSingleMember
in classTP
- 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:
getPhysicalAddress
in classTP
-
-