Package org.jgroups.protocols
Class TCP
- java.lang.Object
-
- org.jgroups.stack.Protocol
-
- org.jgroups.protocols.TP
-
- org.jgroups.protocols.BasicTCP
-
- org.jgroups.protocols.TCP
-
- All Implemented Interfaces:
Receiver
,Lifecycle
,DiagnosticsHandler.ProbeHandler
public class TCP extends BasicTCP
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 TcpServer, 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
-
-
Field Summary
Fields Modifier and Type Field Description protected int
buffered_input_stream_size
protected int
buffered_output_stream_size
protected boolean
log_accept_error
protected int
max_send_queue
protected boolean
non_blocking_sends
protected TcpServer
srv
protected TLS
tls
-
Fields inherited from class org.jgroups.protocols.BasicTCP
client_bind_addr, client_bind_port, conn_expire_time, defer_client_bind_addr, linger, log_details, max_length, peer_addr_read_timeout, reaper_interval, recv_buf_size, send_buf_size, sock_conn_timeout, tcp_nodelay, use_acks
-
Fields inherited from class org.jgroups.protocols.TP
async_executor, 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, rtt, 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, policies, stack, stats, up_prot
-
-
Constructor Summary
Constructors Constructor Description TCP()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TCP
clearConnections()
int
getBufferedInputStreamSize()
int
getBufferedOutputStreamSize()
int
getOpenConnections()
protected PhysicalAddress
getPhysicalAddress()
protected void
handleConnect()
protected void
handleDisconnect()
boolean
logAcceptError()
TCP
logAcceptError(boolean l)
int
maxSendQueue()
TCP
maxSendQueue(int s)
boolean
nonBlockingSends()
TCP
nonBlockingSends(boolean b)
java.lang.String
printConnections()
void
retainAll(java.util.Collection<Address> members)
void
send(Address dest, byte[] data, int offset, int length)
TCP
setBufferedInputStreamSize(int buffered_input_stream_size)
TCP
setBufferedOutputStreamSize(int buffered_output_stream_size)
void
setSocketFactory(SocketFactory factory)
Sets a SocketFactory.void
start()
Creates the unicast and multicast sockets and starts the unicast and multicast receiver threadsvoid
stop()
Called on aJChannel.disconnect()
; stops work (e.g.TLS
tls()
TCP
tls(TLS t)
-
Methods inherited from class org.jgroups.protocols.BasicTCP
deferClientBindAddr, deferClientBindAddr, down, getClientBindAddr, getClientBindPort, getConnExpireTime, getInfo, getLinger, getMaxLength, getPeerAddrReadTimeout, getReaperInterval, getRecvBufSize, getSendBufSize, getSockConnTimeout, init, logDetails, logDetails, reaperInterval, sendUnicast, setClientBindAddr, setClientBindPort, setConnExpireTime, setLinger, setMaxLength, setPeerAddrReadTimeout, setReaperInterval, setRecvBufSize, setSendBufSize, setSockConnTimeout, supportsMulticasting, tcpNodelay, tcpNodelay, useAcks, useAcks
-
Methods inherited from class org.jgroups.protocols.TP
_send, addPhysicalAddressToCache, addPhysicalAddressToCache, bundler, clearDifferentClusterCache, clearDifferentVersionCache, clearLogicalAddressCache, createBundler, createDiagnosticsHandler, defaultHeaders, destroy, disableDiagnostics, doSend, down, dumpTimerTasks, enableBlockingTimerTasks, enableDiagnostics, enableStats, evictLogicalAddressCache, evictLogicalAddressCache, fetchLocalAddresses, fetchPhysicalAddrs, fetchResponsesFromDiscoveryProtocol, getAllPhysicalAddressesFromCache, getAsyncExecutor, getBindAddr, getBindAddress, getBindPort, getBundler, getBundlerClass, getBundlerType, getClusterName, getClusterNameAscii, getDiagnosticsHandler, getDifferentClusterMessages, getDifferentVersionMessages, getExternalAddr, getExternalPort, getLocalPhysicalAddress, getLocalTransport, getLogDiscardMessages, getLogDiscardMessagesVersion, getLogicalAddrCacheExpiration, getLogicalAddrCacheMaxSize, getLogicalAddrCacheReaperInterval, getLogicalAddressCache, getMessageFactory, getMessageFactoryClass, getMessageProcessingPolicy, getMessageStats, getMsgFactoryClass, getNumberOfThreadDumps, getNumMcastMsgsReceived, getNumMcastMsgsSent, getNumRejectedMsgs, getNumThreads, getNumTimerTasks, getNumUcastMsgsReceived, getNumUcastMsgsSent, getPhysicalAddressFromCache, getPortRange, getReceiveInterfaces, getRTT, getSocketFactory, getSuppressTimeDifferentClusterWarnings, getSuppressTimeDifferentVersionWarnings, getThreadFactory, getThreadNamingPattern, getThreadPool, getTimer, getTimerClass, getTimerThreads, getTimeService, getTimeServiceInterval, getWhoHasCacheTimeout, 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, sendTo, sendToAll, setAddress, setAsyncExecutor, setBindAddr, setBindAddress, setBindPort, setBindToAllInterfaces, setBundler, setBundlerType, setDiagnosticsHandler, setExternalAddr, setExternalPort, setInAllThreadFactories, setLevel, setLocalTransport, setLocalTransport, setLogDiscardMessages, setLogDiscardMessagesVersion, setLogicalAddrCacheExpiration, setLogicalAddrCacheMaxSize, setLogicalAddrCacheReaperInterval, setMessageFactory, setMessageProcessingPolicy, setMsgFactoryClass, setPortRange, setSourceAddress, setSuppressTimeDifferentClusterWarnings, setSuppressTimeDifferentVersionWarnings, setThreadFactory, setThreadNames, setThreadPool, setTimer, setTimeService, setTimeServiceInterval, setWhoHasCacheTimeout, startDiagnostics, stopDiagnostics, supportedKeys, timestamp, toString, unicastDestMismatch, unregisterProbeHandler, unsetThreadNames, useVirtualThreads, useVirtualThreads, versionMatch, view
-
Methods inherited from class org.jgroups.stack.Protocol
accept, addPolicy, addr, addr, afterCreationHook, down, getAddress, getComponents, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getLog, getName, getPolicies, getProtocolStack, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, level, parse, policies, providedDownServices, providedUpServices, removePolicy, requiredDownServices, requiredUpServices, resetStatistics, setDownProtocol, setErgonomics, setId, setPolicies, setProtocolStack, setUpProtocol, setValue, statsEnabled, up, up, up
-
-
-
-
Field Detail
-
srv
protected TcpServer srv
-
buffered_input_stream_size
protected int buffered_input_stream_size
-
buffered_output_stream_size
protected int buffered_output_stream_size
-
log_accept_error
protected boolean log_accept_error
-
tls
protected TLS tls
-
non_blocking_sends
protected boolean non_blocking_sends
-
max_send_queue
protected int max_send_queue
-
-
Method Detail
-
getBufferedInputStreamSize
public int getBufferedInputStreamSize()
-
setBufferedInputStreamSize
public TCP setBufferedInputStreamSize(int buffered_input_stream_size)
-
getBufferedOutputStreamSize
public int getBufferedOutputStreamSize()
-
setBufferedOutputStreamSize
public TCP setBufferedOutputStreamSize(int buffered_output_stream_size)
-
tls
public TLS tls()
-
logAcceptError
public boolean logAcceptError()
-
logAcceptError
public TCP logAcceptError(boolean l)
-
nonBlockingSends
public boolean nonBlockingSends()
-
nonBlockingSends
public TCP nonBlockingSends(boolean b)
-
maxSendQueue
public int maxSendQueue()
-
maxSendQueue
public TCP maxSendQueue(int s)
-
getOpenConnections
public int getOpenConnections()
-
printConnections
public java.lang.String printConnections()
- Specified by:
printConnections
in classBasicTCP
-
clearConnections
public TCP clearConnections()
-
setSocketFactory
public void setSocketFactory(SocketFactory factory)
Description copied from class:Protocol
Sets a SocketFactory. Socket factories are typically provided by the transport (TP
)- Overrides:
setSocketFactory
in classTP
-
send
public void send(Address dest, byte[] data, int offset, int length) throws java.lang.Exception
-
retainAll
public void retainAll(java.util.Collection<Address> members)
-
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- Specified by:
start
in interfaceLifecycle
- Overrides:
start
in classTP
- Throws:
java.lang.Exception
- Thrown if protocol cannot be started successfully. This will cause the ProtocolStack to fail, soJChannel.connect(String)
will throw an exception
-
stop
public void stop()
Description copied from class:Protocol
Called on aJChannel.disconnect()
; stops work (e.g. by closing multicast socket). Will be called from top to bottom.
-
handleConnect
protected void handleConnect() throws java.lang.Exception
- Overrides:
handleConnect
in classTP
- Throws:
java.lang.Exception
-
handleDisconnect
protected void handleDisconnect()
- Overrides:
handleDisconnect
in classTP
-
getPhysicalAddress
protected PhysicalAddress getPhysicalAddress()
- Specified by:
getPhysicalAddress
in classTP
-
-