Class TCP_NIO2
java.lang.Object
org.jgroups.stack.Protocol
org.jgroups.protocols.TPConfig
org.jgroups.protocols.TP
org.jgroups.protocols.BasicTCP
org.jgroups.protocols.TCP_NIO2
- All Implemented Interfaces:
ConnectionListener, Receiver, Lifecycle, DiagnosticsHandler.ProbeHandler
Protocol using TCP/IP to send and receive messages. Contrary to
TCP, TCP_NIO uses non-blocking I/O (NIO),
which eliminates the thread per connection model. Instead, TCP_NIO uses a single selector to poll for incoming
messages and dispatches handling of those to a (configurable) thread pool.
Most of the functionality is in NioServer. TCP_NIO sends
messages using BaseServer.send(Address,byte[],int,int) and registers with the server
to receive messages.
- Since:
- 3.6.5
- Author:
- Bela Ban
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected intprotected longprotected NioServerFields inherited from class BasicTCP
client_bind_addr, client_bind_port, conn_expire_time, connected, defer_client_bind_addr, enable_suspect_events, is_member, linger, log_details, max_length, num_suspect_events, peer_addr_read_timeout, reaper_interval, recv_buf_size, send_buf_size, sock_conn_timeout, tcp_nodelay, use_acksFields inherited from class TP
LIST, MIN_WAIT_BETWEEN_DISCOVERIES, MSG_OVERHEAD, MULTICASTFields inherited from class TPConfig
async_executor, bind_addr, bind_port, bundler, bundler_type, cluster_name, connectLock, diag_handler, external_addr, external_port, header, is_trace, last_discovery_request, 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, members, message_processing_policy, msg_processing_policy, msg_stats, 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_direct_memory, use_vthreads, view, who_has_cache, who_has_cache_timeoutFields inherited from class Protocol
after_creation_hook, down_prot, ergonomics, id, local_addr, log, policies, preview_warning, stack, stats, up_prot -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclearConnections(boolean graceful) booleancopyOnPartialWrite(boolean c) intintprotected PhysicalAddressReturns the physical address of this transportlongprotected voidprotected voidbooleanbooleanintnumDrops()intintvoidreaderIdleTime(long t) voidretainAll(Collection<Address> members) voidsendUnicast(PhysicalAddress dest, ByteBuffer data) Send a unicast message to a member.setMaxSendBuffers(int m) setReaderIdleTime(long r) voidstart()Creates the unicast and multicast sockets and starts the unicast and multicast receiver threadsvoidstop()Called on aJChannel.disconnect(); stops work (e.g.Methods inherited from class BasicTCP
connectionClosed, connectionEstablished, deferClientBindAddr, deferClientBindAddr, down, enableSuspectEvents, enableSuspectEvents, getClientBindAddr, getClientBindPort, getConnExpireTime, getLinger, getMaxLength, getPeerAddrReadTimeout, getReaperInterval, getRecvBufSize, getSendBufSize, getSockConnTimeout, init, logDetails, logDetails, numSuspectEvents, reaperInterval, resetStats, setClientBindAddr, setClientBindPort, setConnExpireTime, setLinger, setMaxLength, setPeerAddrReadTimeout, setReaperInterval, setRecvBufSize, setSendBufSize, setSockConnTimeout, supportsMulticasting, tcpNodelay, tcpNodelay, useAcks, useAcksMethods inherited from class TP
addPhysicalAddressToCache, addPhysicalAddressToCache, clearLogicalAddressCache, destroy, disableDiagnostics, doSend, down, enableDiagnostics, evictLogicalAddressCache, evictLogicalAddressCache, fetchLocalAddresses, fetchPhysicalAddrs, fetchResponsesFromDiscoveryProtocol, getAllPhysicalAddressesFromCache, getPhysicalAddressFromCache, handleMessageBatch, handleProbe, handleSingleMessage, passBatchUp, passMessageUp, processBatch, receive, receive, registerLocalAddress, removeLogicalAddressFromCache, sendTo, sendToAll, sendUnicasts, setAddress, setInAllThreadFactories, setSourceAddress, setThreadNames, startDiagnostics, stopDiagnostics, supportedKeys, toString, unicastDestMismatch, unsetThreadNames, versionMatchMethods inherited from class TPConfig
bundler, clearDifferentClusterCache, clearDifferentVersionCache, clusterName, createBundler, createDiagnosticsHandler, defaultHeaders, dumpTimerTasks, enableAllStats, enableBlockingTimerTasks, enableStats, getAsyncExecutor, getBindAddr, getBindAddress, getBindPort, getBundler, getBundlerClass, getBundlerType, getClusterName, getClusterNameAscii, getDiagnosticsHandler, getDifferentClusterMessages, getDifferentVersionMessages, getExternalAddr, getExternalPort, getLocalPhysicalAddress, getLocalTransport, getLogDiscardMessages, getLogDiscardMessagesVersion, getLogicalAddrCacheExpiration, getLogicalAddrCacheMaxSize, getLogicalAddrCacheReaperInterval, getLogicalAddressCache, getMessageProcessingPolicy, getMessageStats, getNumberOfThreadDumps, getNumMcastMsgsReceived, getNumMcastMsgsSent, getNumRejectedMsgs, getNumThreads, getNumTimerTasks, getNumUcastMsgsReceived, getNumUcastMsgsSent, getPortRange, getReceiveInterfaces, getRTT, getSocketFactory, getSuppressTimeDifferentClusterWarnings, getSuppressTimeDifferentVersionWarnings, getThreadFactory, getThreadNamingPattern, getThreadPool, getTimer, getTimerClass, getTimerThreads, getTimeService, getTimeServiceInterval, getWhoHasCacheTimeout, isLogicalAddressCacheReaperRunning, isReceiveOnAllInterfaces, isTrace, isTrace, localPhysicalAddress, logDiscardMsgs, logDiscardMsgs, logDiscardMsgsVersion, logDiscardMsgsVersion, loggerType, msgProcessingPolicy, msgProcessingPolicy, printLogicalAddressCache, printWhoHasCache, receiveOnAllInterfaces, receiveOnAllInterfaces, registerProbeHandler, removeCancelledTimerTasks, sameCluster, setAsyncExecutor, setBindAddr, setBindAddress, setBindPort, setBindToAllInterfaces, setBundler, setBundlerType, setDiagnosticsHandler, setExternalAddr, setExternalPort, setLevel, setLocalTransport, setLocalTransport, setLogDiscardMessages, setLogDiscardMessagesVersion, setLogicalAddrCacheExpiration, setLogicalAddrCacheMaxSize, setLogicalAddrCacheReaperInterval, setMessageProcessingPolicy, setMessageStats, setPortRange, setSocketFactory, setSuppressTimeDifferentClusterWarnings, setSuppressTimeDifferentVersionWarnings, setThreadFactory, setThreadPool, setTimer, setTimeService, setTimeServiceInterval, setWhoHasCacheTimeout, threadNamingPattern, timestamp, unregisterProbeHandler, unregisterProbeHandler, useDirectMemory, useDirectMemory, useVirtualThreads, useVirtualThreads, viewMethods inherited from class 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, previewWarning, previewWarning, providedDownServices, providedUpServices, removePolicy, requiredDownServices, requiredUpServices, resetStatistics, setDownProtocol, setErgonomics, setId, setPolicies, setProtocolStack, setUpProtocol, setValue, statsEnabled, up, up, up
-
Field Details
-
server
-
max_send_buffers
protected int max_send_buffers -
copy_on_partial_write
protected boolean copy_on_partial_write -
reader_idle_time
protected long reader_idle_time
-
-
Constructor Details
-
TCP_NIO2
public TCP_NIO2()
-
-
Method Details
-
getMaxSendBuffers
public int getMaxSendBuffers() -
setMaxSendBuffers
-
copyOnPartialWrite
public boolean copyOnPartialWrite() -
copyOnPartialWrite
-
getReaderIdleTime
public long getReaderIdleTime() -
setReaderIdleTime
-
getOpenConnections
public int getOpenConnections() -
printConnections
- Specified by:
printConnectionsin classBasicTCP
-
printBuffers
-
clearConnections
- Specified by:
clearConnectionsin classBasicTCP
-
isSelectorOpen
public boolean isSelectorOpen() -
isAcceptorRunning
public boolean isAcceptorRunning() -
numSelects
public int numSelects() -
numPartialWrites
public int numPartialWrites() -
numDrops
public int numDrops() -
readerIdleTime
public void readerIdleTime(long t) -
sendUnicast
Description copied from class:TPSend a unicast message 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 physical unicast address (e.g.IpAddress)data- The data to be sent. This is not a copy, so don't modify it- Throws:
Exception
-
retainAll
-
start
Description copied from class:TPCreates the unicast and multicast sockets and starts the unicast and multicast receiver threads -
stop
-
handleConnect
- Overrides:
handleConnectin classTP- Throws:
Exception
-
handleDisconnect
protected void handleDisconnect()- Overrides:
handleDisconnectin classTP
-
getPhysicalAddress
Description copied from class:TPReturns the physical address of this transport- Specified by:
getPhysicalAddressin classTP
-