org.jgroups.protocols
Class TCP

java.lang.Object
  extended by org.jgroups.stack.Protocol
      extended by org.jgroups.protocols.TP
          extended by org.jgroups.protocols.BasicTCP
              extended by org.jgroups.protocols.TCP
All Implemented Interfaces:
TCPConnectionMap.Receiver

public class TCP
extends BasicTCP
implements TCPConnectionMap.Receiver

TCP based protocol. Creates a server socket, which gives us the local address of this group member. For each accept() on the server socket, a new thread is created that listens on the socket. For each outgoing message m, if m.dest is in the outgoing hash table, the associated socket will be reused to send message, otherwise a new socket is created and put in the hash table. When a socket connection breaks or a member is removed from the group, the corresponding items in the incoming and outgoing hash tables will be removed as well.

This functionality is in TCPConnectionMap, which is used by TCP. TCP sends messages using ct.send() and registers with the connection table to receive all incoming messages.

Author:
Bela Ban

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jgroups.protocols.TP
TP.Bundler, TP.DefaultBundler, TP.DefaultBundler2, TP.ProtocolAdapter, TP.TransferQueueBundler, TP.TransferQueueBundler2
 
Field Summary
 
Fields inherited from class org.jgroups.protocols.BasicTCP
client_bind_addr, client_bind_port, conn_expire_time, defer_client_bind_addr, linger, peer_addr_read_timeout, reaper_interval, recv_buf_size, send_buf_size, send_queue_size, sock_conn_timeout, tcp_nodelay, use_send_queues
 
Fields inherited from class org.jgroups.protocols.TP
bind_addr, bind_interface_str, bind_port, bundler, bundler_capacity, bundler_type, can_bind_to_mcast_addr, channel_name, connect_count, connectLock, default_thread_factory, diag_handler, diagnostics_addr, diagnostics_bind_interfaces, diagnostics_passcode, diagnostics_port, diagnostics_ttl, discard_incompatible_packets, enable_bundling, enable_diagnostics, enable_unicast_bundling, external_addr, external_port, f, global_thread_factory, header, last_discovery_request, LIST, local_addr, log_discard_msgs, log_discard_msgs_version, logical_addr_cache, logical_addr_cache_expiration, logical_addr_cache_max_size, loopback, max_bundle_size, max_bundle_timeout, members, MULTICAST, num_bytes_received, num_bytes_sent, num_incoming_msgs_received, num_msgs_received, num_msgs_sent, num_oob_msgs_received, OOB, oob_thread_factory, oob_thread_pool, oob_thread_pool_enabled, oob_thread_pool_keep_alive_time, oob_thread_pool_max_threads, oob_thread_pool_min_threads, oob_thread_pool_queue, oob_thread_pool_queue_enabled, oob_thread_pool_queue_max_size, physical_addr_max_fetch_attempts, port_range, preregistered_probe_handlers, print_function, receive_interfaces, receive_on_all_interfaces, singleton_name, socket_factory, suppress_log_different_cluster, suppress_log_different_version, suppress_time_different_cluster_warnings, suppress_time_different_version_warnings, thread_naming_pattern, thread_pool, thread_pool_enabled, thread_pool_keep_alive_time, thread_pool_max_threads, thread_pool_min_threads, thread_pool_queue, thread_pool_queue_enabled, thread_pool_queue_max_size, thread_pool_rejection_policy, tick_time, timer, timer_keep_alive_time, timer_max_threads, timer_min_threads, timer_queue_max_size, timer_rejection_policy, timer_thread_factory, timer_type, up_prots, wheel_size, who_has_cache, who_has_cache_timeout
 
Fields inherited from class org.jgroups.stack.Protocol
down_prot, ergonomics, id, log, name, stack, stats, up_prot
 
Constructor Summary
TCP()
           
 
Method Summary
protected  TCPConnectionMap createConnectionMap(long reaperInterval, long connExpireTime, java.net.InetAddress bindAddress, java.net.InetAddress externalAddress, int external_port, int startPort, int endPort)
           
 int getOpenConnections()
           
protected  PhysicalAddress getPhysicalAddress()
           
protected  void handleConnect()
           
protected  void handleDisconnect()
           
 java.lang.String printConnections()
           
 void retainAll(java.util.Collection<Address> members)
           
 void send(Address dest, byte[] data, int offset, int length)
           
 void setSocketFactory(SocketFactory factory)
          Sets a SocketFactory.
 void start()
          Creates the unicast and multicast sockets and starts the unicast and multicast receiver threads
 void stop()
          This method is called on a Channel.disconnect().
 
Methods inherited from class org.jgroups.protocols.BasicTCP
getConnExpireTime, getInfo, getReaperInterval, handleDownEvent, init, receive, sendMulticast, sendUnicast, setConnExpireTime, setReaperInterval, supportsMulticasting
 
Methods inherited from class org.jgroups.protocols.TP
addPhysicalAddressToCache, clearDifferentClusterCache, clearDifferentVersionCache, clearLogicalAddressCache, createThreadPool, destroy, dispatchToThreadPool, doSend, down, dumpTimerTasks, evictLogicalAddressCache, evictLogicalAddressCache, fetchLocalAddresses, getAllPhysicalAddressesFromCache, getBindAddress, getBindPort, getBundlerBufferSize, getDefaultThreadPool, getDefaultThreadPoolThreadFactory, getDifferentClusterMessages, getDifferentVersionMessages, getLogDiscardMessages, getLogDiscardMessagesVersion, getMaxBundleSize, getMaxBundleTimeout, getNumBytesReceived, getNumBytesSent, getNumMessagesReceived, getNumMessagesSent, getNumThreads, getNumTimerTasks, getOOBMaxQueueSize, getOOBMessages, getOOBPoolSize, getOOBQueueSize, getOOBThreadPool, getOOBThreadPoolKeepAliveTime, getOOBThreadPoolMaxThreads, getOOBThreadPoolMinThreads, getOOBThreadPoolThreadFactory, getPhysicalAddressFromCache, getPortRange, getReceiveInterfaces, getRegularMaxQueueSize, getRegularMessages, getRegularPoolSize, getRegularQueueSize, getSingletonName, getSocketFactory, getThreadFactory, getThreadNamingPattern, getThreadPoolKeepAliveTime, getThreadPoolMaxThreads, getThreadPoolMinThreads, getTimer, getTimerClass, getTimerKeepAliveTime, getTimerMaxThreads, getTimerMinThreads, getTimerQueueSize, getTimerThreadFactory, getTimerThreads, getUpProtocols, isDefaulThreadPoolEnabled, isDiscardIncompatiblePackets, isEnableBundling, isEnableUnicastBundling, isLoopback, isMulticastCapable, isOOBThreadPoolEnabled, isReceiveOnAllInterfaces, isSingleton, passMessageUp, passToAllUpProtocols, printLogicalAddressCache, printWhoHasCache, readMessage, readMessageList, registerLocalAddress, registerProbeHandler, removeLogicalAddressFromCache, resetStats, send, sendToAllPhysicalAddresses, sendToSingleMember, setBindAddress, setBindPort, setBindToAllInterfaces, setDefaultThreadPool, setDefaultThreadPoolThreadFactory, setDiagnosticsHandler, setDiscardIncompatiblePackets, setEnableBundling, setEnableUnicastBundling, setInAllThreadFactories, setLogDiscardMessages, setLogDiscardMessagesVersion, setLoopback, setMaxBundleSize, setMaxBundleTimeout, setOOBRejectionPolicy, setOOBThreadPool, setOOBThreadPoolKeepAliveTime, setOOBThreadPoolMaxThreads, setOOBThreadPoolMinThreads, setOOBThreadPoolThreadFactory, setPortRange, setRegularRejectionPolicy, setSourceAddress, setThreadFactory, setThreadNames, setThreadPoolKeepAliveTime, setThreadPoolMaxThreads, setThreadPoolMinThreads, setThreadPoolQueueEnabled, setTimer, setTimerKeepAliveTime, setTimerMaxThreads, setTimerMinThreads, setTimerThreadFactory, shutdownThreadPool, toString, unregisterProbeHandler, unsetThreadNames, up, writeMessage, writeMessageList
 
Methods inherited from class org.jgroups.stack.Protocol
dumpStats, enableStats, getConfigurableObjects, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getName, getProtocolStack, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, printStats, providedDownServices, providedUpServices, requiredDownServices, requiredUpServices, resetStatistics, setDownProtocol, setErgonomics, setId, setLevel, setProtocolStack, setUpProtocol, setValue, setValues, statsEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jgroups.blocks.TCPConnectionMap.Receiver
receive
 

Constructor Detail

TCP

public TCP()
Method Detail

getOpenConnections

public int getOpenConnections()

printConnections

public java.lang.String printConnections()
Specified by:
printConnections in class BasicTCP

setSocketFactory

public void setSocketFactory(SocketFactory factory)
Description copied from class: Protocol
Sets a SocketFactory. Socket factories are typically provided by the transport (TP) or TP.ProtocolAdapter

Overrides:
setSocketFactory in class TP

send

public void send(Address dest,
                 byte[] data,
                 int offset,
                 int length)
          throws java.lang.Exception
Specified by:
send in class BasicTCP
Throws:
java.lang.Exception

retainAll

public void retainAll(java.util.Collection<Address> members)
Specified by:
retainAll in class BasicTCP

start

public void start()
           throws java.lang.Exception
Description copied from class: TP
Creates the unicast and multicast sockets and starts the unicast and multicast receiver threads

Overrides:
start in class TP
Throws:
java.lang.Exception - Thrown if protocol cannot be started successfully. This will cause the ProtocolStack to fail, so Channel.connect(String) will throw an exception

stop

public void stop()
Description copied from class: Protocol
This method is called on a Channel.disconnect(). Stops work (e.g. by closing multicast socket). Will be called from top to bottom. This means that at the time of the method invocation the neighbor protocol below is still working. This method will replace the STOP, STOP_OK, CLEANUP and CLEANUP_OK events. The ProtocolStack guarantees that when this method is called all messages in the down queue will have been flushed

Overrides:
stop in class TP

handleConnect

protected void handleConnect()
                      throws java.lang.Exception
Overrides:
handleConnect in class TP
Throws:
java.lang.Exception

handleDisconnect

protected void handleDisconnect()
Overrides:
handleDisconnect in class TP

createConnectionMap

protected TCPConnectionMap createConnectionMap(long reaperInterval,
                                               long connExpireTime,
                                               java.net.InetAddress bindAddress,
                                               java.net.InetAddress externalAddress,
                                               int external_port,
                                               int startPort,
                                               int endPort)
                                        throws java.lang.Exception
Parameters:
reaperInterval -
connExpireTime -
bindAddress -
startPort -
Returns:
TCPConnectionMap Subclasses override this method to initialize a different version of ConnectionMap
Throws:
java.lang.Exception

getPhysicalAddress

protected PhysicalAddress getPhysicalAddress()
Specified by:
getPhysicalAddress in class TP


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