public class TCP_NIO2 extends BasicTCP
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.
TP.BatchHandler, TP.ProtocolAdapter, TP.SingleMessageHandler, TP.SingleMessageHandlerWithClusterName
Modifier and Type | Field and Description |
---|---|
protected boolean |
copy_on_partial_write |
protected int |
max_send_buffers |
protected long |
reader_idle_time |
protected NioServer |
server |
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
avg_batch_size, bind_addr, bind_interface_str, bind_port, BUNDLE_MSG, bundler, bundler_capacity, bundler_num_spins, bundler_type, bundler_wait_strategy, can_bind_to_mcast_addr, cluster_name, connect_count, connectLock, default_thread_factory, diag_handler, diagnostics_addr, diagnostics_bind_interfaces, diagnostics_passcode, diagnostics_port, diagnostics_ttl, discard_incompatible_packets, enable_batching, enable_bundling, enable_diagnostics, enable_unicast_bundling, external_addr, external_port, f, global_thread_factory, header, ignore_dont_bundle, internal_thread_factory, internal_thread_pool, internal_thread_pool_enabled, internal_thread_pool_keep_alive_time, internal_thread_pool_max_threads, internal_thread_pool_min_threads, internal_thread_pool_queue, internal_thread_pool_queue_enabled, internal_thread_pool_queue_max_size, internal_thread_pool_rejection_policy, 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_interval, loopback, loopback_copy, loopback_separate_thread, max_bundle_size, max_bundle_timeout, members, MIN_WAIT_BETWEEN_DISCOVERIES, MSG_OVERHEAD, MULTICAST, no_bundler_initial_buf_size, no_bundler_pool_size, num_batches_received, num_batches_sent, num_bytes_received, num_bytes_sent, num_incoming_msgs_received, num_internal_msgs_received, num_msgs_received, num_msgs_sent, num_oob_msgs_received, num_rejected_msgs, num_single_msgs_received, num_single_msgs_sent, num_single_msgs_sent_instead_of_batch, 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, oob_thread_pool_rejection_policy, 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, time_service, time_service_interval, 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, view, wheel_size, who_has_cache, who_has_cache_timeout
after_creation_hook, down_prot, ergonomics, id, log, name, stack, stats, up_prot
Constructor and Description |
---|
TCP_NIO2() |
Modifier and Type | Method and Description |
---|---|
void |
clearConnections() |
int |
getOpenConnections() |
protected PhysicalAddress |
getPhysicalAddress() |
protected void |
handleConnect() |
protected void |
handleDisconnect() |
boolean |
isAcceptorRunning() |
boolean |
isSelectorOpen() |
int |
numPartialWrites() |
int |
numSelects() |
java.lang.String |
printBuffers() |
java.lang.String |
printConnections() |
void |
readerIdleTime(long t) |
void |
retainAll(java.util.Collection<Address> members) |
void |
send(Address dest,
byte[] data,
int offset,
int length) |
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() . |
getConnExpireTime, getInfo, getReaperInterval, handleDownEvent, init, receive, receive, sendMulticast, sendUnicast, setConnExpireTime, setReaperInterval, supportsMulticasting
_send, addPhysicalAddressToCache, assertPositive, bundler, bundlerNumSpins, bundlerNumSpins, bundlerWaitStrategy, bundlerWaitStrategy, clearDifferentClusterCache, clearDifferentVersionCache, clearLogicalAddressCache, createBundler, createThreadPool, destroy, disableDiagnostics, doSend, down, dumpTimerTasks, enableDiagnostics, evictLogicalAddressCache, evictLogicalAddressCache, fetchLocalAddresses, fetchPhysicalAddrs, fetchResponsesFromDiscoveryProtocol, getAllPhysicalAddressesFromCache, getAvgBatchSize, getBindAddress, getBindPort, getBundler, getBundlerBufferSize, getBundlerCapacity, getBundlerClass, getClusterName, getClusterName, getClusterNameAscii, getDefaultThreadPool, getDefaultThreadPoolThreadFactory, getDifferentClusterMessages, getDifferentVersionMessages, getInternalMaxQueueSize, getInternalMessages, getInternalPoolSize, getInternalPoolSizeActive, getInternalQueueSize, getInternalThreadPool, getInternalThreadPoolThreadFactory, getLocalAddress, getLocalPhysicalAddress, getLogDiscardMessages, getLogDiscardMessagesVersion, getMaxBundleSize, getMaxBundleTimeout, getNumBytesReceived, getNumBytesSent, getNumMessagesReceived, getNumMessagesSent, getNumThreads, getNumTimerTasks, getOOBMaxQueueSize, getOOBMessages, getOOBPoolSize, getOOBPoolSizeActive, getOOBQueueSize, getOOBThreadPool, getOOBThreadPoolKeepAliveTime, getOOBThreadPoolMaxThreads, getOOBThreadPoolMinThreads, getOOBThreadPoolThreadFactory, getPhysicalAddressFromCache, getPortRange, getReceiveInterfaces, getRegularMaxQueueSize, getRegularMessages, getRegularPoolSize, getRegularPoolSizeActive, getRegularQueueSize, getSingletonName, getSocketFactory, getThreadFactory, getThreadNamingPattern, getThreadPoolKeepAliveTime, getThreadPoolMaxThreads, getThreadPoolMinThreads, getTimer, getTimerClass, getTimerKeepAliveTime, getTimerMaxThreads, getTimerMinThreads, getTimerQueueSize, getTimerThreadFactory, getTimerThreads, getTimeService, getUpProtocols, handleMessageBatch, handleProbe, handleSingleMessage, incrBatchesSent, incrBatchesSent, incrSingleMsgsInsteadOfBatches, isDefaulThreadPoolEnabled, isDiagnosticsHandlerRunning, isDiscardIncompatiblePackets, isEnableBundling, isEnableUnicastBundling, isLogicalAddressCacheReaperRunning, isLoopback, isMulticastCapable, isOOBThreadPoolEnabled, isReceiveOnAllInterfaces, isSingleton, localAddress, loggerType, loopback, passBatchUp, passMessageUp, passToAllUpProtocols, pickThreadPool, printLogicalAddressCache, printWhoHasCache, readMessage, readMessageBatch, readMessageList, registerLocalAddress, registerProbeHandler, removeAndDispatchNonBundledMessages, removeLogicalAddressFromCache, resetStats, send, sendToMembers, sendToSingleMember, setBindAddress, setBindPort, setBindToAllInterfaces, setBundler, setDefaultThreadPool, setDefaultThreadPoolThreadFactory, setDiagnosticsHandler, setDiscardIncompatiblePackets, setEnableBundling, setEnableUnicastBundling, setInAllThreadFactories, setInternalThreadPool, setInternalThreadPoolThreadFactory, setLogDiscardMessages, setLogDiscardMessagesVersion, setLoopback, setMaxBundleSize, setMaxBundleTimeout, setOOBRejectionPolicy, setOOBThreadPool, setOOBThreadPoolKeepAliveTime, setOOBThreadPoolMaxThreads, setOOBThreadPoolMinThreads, setOOBThreadPoolQueueEnabled, setOOBThreadPoolThreadFactory, setPingData, setPortRange, setRegularRejectionPolicy, setSocketFactory, setSourceAddress, setThreadFactory, setThreadNames, setThreadPoolKeepAliveTime, setThreadPoolMaxThreads, setThreadPoolMinThreads, setThreadPoolQueueEnabled, setTimer, setTimerKeepAliveTime, setTimerMaxThreads, setTimerMinThreads, setTimerThreadFactory, setTimeService, shutdownThreadPool, startDiagnostics, stopDiagnostics, supportedKeys, toString, unregisterProbeHandler, unsetThreadNames, up, versionMatch, view, writeMessage, writeMessageList, writeMessageListHeader
accept, afterCreationHook, dumpStats, enableStats, getConfigurableObjects, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getLog, getName, getProtocolStack, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, level, parse, printStats, providedDownServices, providedUpServices, requiredDownServices, requiredUpServices, resetStatistics, setDownProtocol, setErgonomics, setId, setLevel, setProtocolStack, setUpProtocol, setValue, setValues, statsEnabled, up
protected NioServer server
protected int max_send_buffers
protected boolean copy_on_partial_write
protected long reader_idle_time
public int getOpenConnections()
public java.lang.String printConnections()
printConnections
in class BasicTCP
public java.lang.String printBuffers()
public void clearConnections()
public boolean isSelectorOpen()
public boolean isAcceptorRunning()
public int numSelects()
public int numPartialWrites()
public void readerIdleTime(long t)
public void send(Address dest, byte[] data, int offset, int length) throws java.lang.Exception
public void retainAll(java.util.Collection<Address> members)
public void start() throws java.lang.Exception
TP
start
in class TP
java.lang.Exception
- Thrown if protocol cannot be started successfully. This will cause the ProtocolStack
to fail, so Channel.connect(String)
will throw an exceptionpublic void stop()
Protocol
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 flushedprotected void handleConnect() throws java.lang.Exception
handleConnect
in class TP
java.lang.Exception
protected void handleDisconnect()
handleDisconnect
in class TP
protected PhysicalAddress getPhysicalAddress()
getPhysicalAddress
in class TP
Copyright © 1998-2020 Red Hat. All Rights Reserved.