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,AdditionalJmxObjects,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 intbuffered_input_stream_sizeprotected intbuffered_output_stream_sizeprotected booleanlog_accept_errorprotected TcpServersrv-
Fields inherited from class org.jgroups.protocols.BasicTCP
client_bind_addr, client_bind_port, conn_expire_time, defer_client_bind_addr, linger, max_length, peer_addr_read_timeout, reaper_interval, recv_buf_size, send_buf_size, sock_conn_timeout, tcp_nodelay
-
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 TCP()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TCPclearConnections()intgetBufferedInputStreamSize()intgetBufferedOutputStreamSize()intgetOpenConnections()protected PhysicalAddressgetPhysicalAddress()protected voidhandleConnect()protected voidhandleDisconnect()booleanlogAcceptError()TCPlogAcceptError(boolean l)java.lang.StringprintConnections()voidretainAll(java.util.Collection<Address> members)voidsend(Address dest, byte[] data, int offset, int length)TCPsetBufferedInputStreamSize(int buffered_input_stream_size)TCPsetBufferedOutputStreamSize(int buffered_output_stream_size)voidsetSocketFactory(SocketFactory factory)Sets a SocketFactory.voidstart()Creates the unicast and multicast sockets and starts the unicast and multicast receiver threadsvoidstop()This method is called on aJChannel.disconnect().-
Methods inherited from class org.jgroups.protocols.BasicTCP
deferClientBindAddr, deferClientBindAddr, down, getClientBindAddr, getClientBindPort, getConnExpireTime, getInfo, getLinger, getMaxLength, getPeerAddrReadTimeout, getReaperInterval, getRecvBufSize, getSendBufSize, getSockConnTimeout, init, reaperInterval, receive, sendMulticast, sendUnicast, setClientBindAddr, setClientBindPort, setConnExpireTime, setLinger, setMaxLength, setPeerAddrReadTimeout, setReaperInterval, setRecvBufSize, setSendBufSize, setSockConnTimeout, supportsMulticasting, tcpNodelay, tcpNodelay
-
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, destroy, 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, 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, sendToSingleMember, setBindAddress, setBindPort, setBindToAllInterfaces, setBundler, setBundlerCapacity, setDiagnosticsEnabled, setDiagnosticsHandler, setDropWhenFull, setInAllThreadFactories, setInternalThreadPool, setInternalThreadPoolThreadFactory, setLevel, setLogDiscardMessages, setLogDiscardMessagesVersion, setMaxBundleSize, setMessageProcessingPolicy, setPortRange, setSourceAddress, setThreadDumpsThreshold, setThreadFactory, setThreadNames, setThreadPool, setThreadPoolKeepAliveTime, setThreadPoolMaxThreads, setThreadPoolMinThreads, setThreadPoolThreadFactory, setTimer, setTimeService, shutdownThreadPool, startDiagnostics, stopDiagnostics, submitToThreadPool, submitToThreadPool, supportedKeys, timestamp, toString, 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
-
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
-
-
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)
-
logAcceptError
public boolean logAcceptError()
-
logAcceptError
public TCP logAcceptError(boolean l)
-
getOpenConnections
public int getOpenConnections()
-
printConnections
public java.lang.String printConnections()
- Specified by:
printConnectionsin classBasicTCP
-
clearConnections
public TCP clearConnections()
-
setSocketFactory
public void setSocketFactory(SocketFactory factory)
Description copied from class:ProtocolSets a SocketFactory. Socket factories are typically provided by the transport (TP)- Overrides:
setSocketFactoryin 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.ExceptionDescription copied from class:TPCreates the unicast and multicast sockets and starts the unicast and multicast receiver threads- Overrides:
startin 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:ProtocolThis method is called on aJChannel.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
-
handleConnect
protected void handleConnect() throws java.lang.Exception- Overrides:
handleConnectin classTP- Throws:
java.lang.Exception
-
handleDisconnect
protected void handleDisconnect()
- Overrides:
handleDisconnectin classTP
-
getPhysicalAddress
protected PhysicalAddress getPhysicalAddress()
- Specified by:
getPhysicalAddressin classTP
-
-