Class TcpCommunicationConfigInitializer
- java.lang.Object
-
- org.apache.ignite.spi.IgniteSpiAdapter
-
- org.apache.ignite.spi.communication.tcp.internal.TcpCommunicationConfigInitializer
-
- All Implemented Interfaces:
CommunicationSpi<Message>,IgniteSpi
- Direct Known Subclasses:
TcpCommunicationSpi
public abstract class TcpCommunicationConfigInitializer extends IgniteSpiAdapter implements CommunicationSpi<Message>
Only may implement it TcpCommunicationSpi.
-
-
Field Summary
Fields Modifier and Type Field Description protected AttributeNamesattributeNamesAttribute names.protected TcpCommunicationConfigurationcfgConfig.protected ConnectionPolicyconnPlcConnection policy.protected TcpCommunicationMetricsListenermetricsLsnrStatistics.protected TracingtracingTracing.-
Fields inherited from class org.apache.ignite.spi.IgniteSpiAdapter
ignite, igniteInstanceName, log
-
-
Constructor Summary
Constructors Constructor Description TcpCommunicationConfigInitializer()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description intboundPort()longfailureDetectionTimeout()Returns failure detection timeout set to use for network related operations.booleanfailureDetectionTimeoutEnabled()Checks whether failure detection timeout is enabled for thisIgniteSpi.voidfailureDetectionTimeoutEnabled(boolean enabled)Enables or disables failure detection timeout.booleanforceClientToServerConnections()intgetAckSendThreshold()AddressResolvergetAddressResolver()intgetConnectionsPerNode()longgetConnectTimeout()longgetIdleConnectionTimeout()StringgetLocalAddress()intgetLocalPort()SeesetLocalPort(int).intgetLocalPortRange()longgetMaxConnectTimeout()Gets maximum connect timeout.intgetMessageQueueLimit()Gets message queue limit for incoming and outgoing messages.Map<String,Object>getNodeAttributes()This method is called before SPI starts (before methodIgniteSpi.spiStart(String)is called).intgetReconnectCount()Gets maximum number of reconnect attempts used when establishing connection with remote nodes.intgetSelectorsCount()longgetSelectorSpins()intgetSharedMemoryPort()Deprecated.This property is ignored and will be removed in future releases.intgetSlowClientQueueLimit()intgetSocketReceiveBuffer()intgetSocketSendBuffer()longgetSocketWriteTimeout()intgetUnacknowledgedMessagesBufferSize()protected voidinjectResources(Ignite ignite)Injects resources.booleanisDirectBuffer()Gets flag that indicates whether direct or heap allocated buffer is used.booleanisDirectSendBuffer()Gets flag defining whether direct send buffer should be used.booleanisFilterReachableAddresses()Gets value forFILTER_REACHABLE_ADDRESSESsocket option.booleanisTcpNoDelay()Gets value forTCP_NODELAYsocket option.booleanisUsePairedConnections()TcpCommunicationSpisetAckSendThreshold(int ackSndThreshold)Sets number of received messages per connection to node after which acknowledgment message is sent.TcpCommunicationSpisetAddressResolver(AddressResolver addrRslvr)Sets address resolver.voidsetConnectionRequestor(ConnectionRequestor connectionRequestor)TcpCommunicationSpisetConnectionsPerNode(int maxConnectionsPerNode)Sets number of connections to each remote node. ifisUsePairedConnections()istruethen number of connections is doubled and half is used for incoming and half for outgoing messages.TcpCommunicationSpisetConnectTimeout(long connTimeout)Sets connect timeout used when establishing connection with remote nodes.TcpCommunicationSpisetDirectBuffer(boolean directBuf)Sets flag to allocate direct or heap buffer in SPI.TcpCommunicationSpisetDirectSendBuffer(boolean directSndBuf)Sets whether to use direct buffer for sending.TcpCommunicationSpisetFilterReachableAddresses(boolean filterReachableAddresses)Setting this option totrueenables filter for reachable addresses on creating tcp client.TcpCommunicationSpisetForceClientToServerConnections(boolean forceClientToSrvConnections)Applicable for clients only.TcpCommunicationSpisetIdleConnectionTimeout(long idleConnTimeout)Sets maximum idle connection timeout upon which a connection to client will be closed.TcpCommunicationSpisetLocalAddress(String locAddr)Sets local host address for socket binding.TcpCommunicationSpisetLocalPort(int locPort)Sets local port for socket binding.TcpCommunicationSpisetLocalPortRange(int locPortRange)Sets local port range for local host ports (value must greater than or equal to 0).TcpCommunicationSpisetMaxConnectTimeout(long maxConnTimeout)Sets maximum connect timeout.TcpCommunicationSpisetMessageQueueLimit(int msgQueueLimit)Sets message queue limit for incoming and outgoing messages.TcpCommunicationSpisetName(String name)Sets SPI name.TcpCommunicationSpisetReconnectCount(int reconCnt)Sets maximum number of reconnect attempts used when establishing connection with remote nodes.TcpCommunicationSpisetSelectorsCount(int selectorsCnt)Sets the count of selectors te be used in TCP server.TcpCommunicationSpisetSelectorSpins(long selectorSpins)Defines how many non-blockingselector.selectNow()should be made before falling intoselector.select(long)in NIO server.TcpCommunicationSpisetSharedMemoryPort(int shmemPort)Deprecated.This property is ignored and will be removed in future releases.TcpCommunicationSpisetSlowClientQueueLimit(int slowClientQueueLimit)Sets slow client queue limit.TcpCommunicationSpisetSocketReceiveBuffer(int sockRcvBuf)Sets receive buffer size for sockets created or accepted by this SPI.TcpCommunicationSpisetSocketSendBuffer(int sockSndBuf)Sets send buffer size for sockets created or accepted by this SPI.TcpCommunicationSpisetSocketWriteTimeout(long sockWriteTimeout)Sets socket write timeout for TCP connection.TcpCommunicationSpisetTcpNoDelay(boolean tcpNoDelay)Sets value forTCP_NODELAYsocket option.TcpCommunicationSpisetUnacknowledgedMessagesBufferSize(int unackedMsgsBufSize)Sets maximum number of stored unacknowledged messages per connection to node.TcpCommunicationSpisetUsePairedConnections(boolean usePairedConnections)Set this totrueifTcpCommunicationSpishould maintain connection for outgoing and incoming messages separately.-
Methods inherited from class org.apache.ignite.spi.IgniteSpiAdapter
addTimeoutObject, assertParameter, checkConfigurationConsistency0, clientFailureDetectionTimeout, configInfo, createSpiAttributeName, getConsistentAttributeNames, getExceptionRegistry, getLocalNode, getName, getSpiContext, ignite, initFailureDetectionTimeout, injectables, isNodeStopping, onBeforeStart, onClientDisconnected, onClientReconnected, onContextDestroyed, onContextDestroyed0, onContextInitialized, onContextInitialized0, registerMBean, removeTimeoutObject, started, startInfo, startStopwatch, stopInfo, unregisterMBean
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.ignite.spi.communication.CommunicationSpi
getOutboundMessagesQueueSize, getReceivedBytesCount, getReceivedMessagesCount, getSentBytesCount, getSentMessagesCount, resetMetrics, sendMessage, setListener
-
Methods inherited from interface org.apache.ignite.spi.IgniteSpi
getName, onClientDisconnected, onClientReconnected, onContextDestroyed, onContextInitialized, spiStart, spiStop
-
-
-
-
Field Detail
-
cfg
protected final TcpCommunicationConfiguration cfg
Config.
-
attributeNames
protected AttributeNames attributeNames
Attribute names.
-
metricsLsnr
protected TcpCommunicationMetricsListener metricsLsnr
Statistics.
-
connPlc
protected ConnectionPolicy connPlc
Connection policy.
-
tracing
protected Tracing tracing
Tracing.
-
-
Method Detail
-
setAddressResolver
@IgniteSpiConfiguration(optional=true) public TcpCommunicationSpi setAddressResolver(AddressResolver addrRslvr)
Sets address resolver.- Parameters:
addrRslvr- Address resolver.- Returns:
thisfor chaining.
-
getAddressResolver
public AddressResolver getAddressResolver()
- Returns:
- Address resolver.
-
injectResources
@IgniteInstanceResource protected void injectResources(Ignite ignite)
Injects resources.- Overrides:
injectResourcesin classIgniteSpiAdapter- Parameters:
ignite- Ignite.
-
setLocalAddress
@IgniteSpiConfiguration(optional=true) public TcpCommunicationSpi setLocalAddress(String locAddr)
Sets local host address for socket binding. Note that one node could have additional addresses beside the loopback one. This configuration parameter is optional.- Parameters:
locAddr- IP address. Default value is any available local IP address.- Returns:
thisfor chaining.
-
getLocalAddress
public String getLocalAddress()
- Returns:
- Grid node IP address.
-
setLocalPort
@IgniteSpiConfiguration(optional=true) public TcpCommunicationSpi setLocalPort(int locPort)
Sets local port for socket binding.If not provided, default value is
TcpCommunicationSpi.DFLT_PORT.- Parameters:
locPort- Port number.- Returns:
thisfor chaining.
-
getLocalPort
public int getLocalPort()
SeesetLocalPort(int).- Returns:
- Port number.
-
setLocalPortRange
@IgniteSpiConfiguration(optional=true) public TcpCommunicationSpi setLocalPortRange(int locPortRange)
Sets local port range for local host ports (value must greater than or equal to 0). If provided local port (seesetLocalPort(int)} is occupied, implementation will try to increment the port number for as long as it is less than initial value plus this range.If port range value is 0, then implementation will try bind only to the port provided by
setLocalPort(int)method and fail if binding to this port did not succeed.Local port range is very useful during development when more than one grid nodes need to run on the same physical machine.
If not provided, default value is
TcpCommunicationSpi.DFLT_PORT_RANGE.- Parameters:
locPortRange- New local port range.- Returns:
thisfor chaining.
-
getLocalPortRange
public int getLocalPortRange()
- Returns:
- Local Port range.
-
isUsePairedConnections
public boolean isUsePairedConnections()
- Returns:
trueto use paired connections andfalseotherwise.
-
setUsePairedConnections
@IgniteSpiConfiguration(optional=true) public TcpCommunicationSpi setUsePairedConnections(boolean usePairedConnections)
Set this totrueifTcpCommunicationSpishould maintain connection for outgoing and incoming messages separately. In this case total number of connections between local and each remote node isgetConnectionsPerNode()* 2.Set this to
falseif each connection ofgetConnectionsPerNode()should be used for outgoing and incoming messages. In this case total number of connections between local and each remote node isgetConnectionsPerNode().Default is
false.- Parameters:
usePairedConnections-trueto use paired connections andfalseotherwise.- Returns:
thisfor chaining.- See Also:
getConnectionsPerNode()
-
setConnectionsPerNode
@IgniteSpiConfiguration(optional=true) public TcpCommunicationSpi setConnectionsPerNode(int maxConnectionsPerNode)
Sets number of connections to each remote node. ifisUsePairedConnections()istruethen number of connections is doubled and half is used for incoming and half for outgoing messages.- Parameters:
maxConnectionsPerNode- Number of connections per node.- Returns:
thisfor chaining.- See Also:
isUsePairedConnections()
-
getConnectionsPerNode
public int getConnectionsPerNode()
- Returns:
- Number of connections per node.
-
setSharedMemoryPort
@IgniteSpiConfiguration(optional=true) @Deprecated public TcpCommunicationSpi setSharedMemoryPort(int shmemPort)
Deprecated.This property is ignored and will be removed in future releases.
-
getSharedMemoryPort
@Deprecated public int getSharedMemoryPort()
Deprecated.This property is ignored and will be removed in future releases.
-
setIdleConnectionTimeout
@IgniteSpiConfiguration(optional=true) public TcpCommunicationSpi setIdleConnectionTimeout(long idleConnTimeout)
Sets maximum idle connection timeout upon which a connection to client will be closed.If not provided, default value is
TcpCommunicationSpi.DFLT_IDLE_CONN_TIMEOUT.- Parameters:
idleConnTimeout- Maximum idle connection time.- Returns:
thisfor chaining.
-
getIdleConnectionTimeout
public long getIdleConnectionTimeout()
- Returns:
- Maximum idle connection time.
-
getSocketWriteTimeout
public long getSocketWriteTimeout()
- Returns:
- Socket write timeout for TCP connections.
-
setSocketWriteTimeout
@IgniteSpiConfiguration(optional=true) public TcpCommunicationSpi setSocketWriteTimeout(long sockWriteTimeout)
Sets socket write timeout for TCP connection. If message can not be written to socket within this time then connection is closed and reconnect is attempted.Default to
TcpCommunicationSpi.DFLT_SOCK_WRITE_TIMEOUT.- Parameters:
sockWriteTimeout- Socket write timeout for TCP connection.- Returns:
thisfor chaining.
-
getAckSendThreshold
public int getAckSendThreshold()
- Returns:
- Number of received messages after which acknowledgment is sent.
-
setAckSendThreshold
@IgniteSpiConfiguration(optional=true) public TcpCommunicationSpi setAckSendThreshold(int ackSndThreshold)
Sets number of received messages per connection to node after which acknowledgment message is sent.Default to
TcpCommunicationSpi.DFLT_ACK_SND_THRESHOLD.- Parameters:
ackSndThreshold- Number of received messages after which acknowledgment is sent.- Returns:
thisfor chaining.
-
getUnacknowledgedMessagesBufferSize
public int getUnacknowledgedMessagesBufferSize()
- Returns:
- Maximum number of unacknowledged messages.
-
setUnacknowledgedMessagesBufferSize
@IgniteSpiConfiguration(optional=true) public TcpCommunicationSpi setUnacknowledgedMessagesBufferSize(int unackedMsgsBufSize)
Sets maximum number of stored unacknowledged messages per connection to node. If number of unacknowledged messages exceeds this number then connection to node is closed and reconnect is attempted.- Parameters:
unackedMsgsBufSize- Maximum number of unacknowledged messages.- Returns:
thisfor chaining.
-
setConnectTimeout
@IgniteSpiConfiguration(optional=true) public TcpCommunicationSpi setConnectTimeout(long connTimeout)
Sets connect timeout used when establishing connection with remote nodes.0is interpreted as infinite timeout.If not provided, default value is
TcpCommunicationSpi.DFLT_CONN_TIMEOUT.When this property is explicitly set
IgniteConfiguration.getFailureDetectionTimeout()is ignored.- Parameters:
connTimeout- Connect timeout.- Returns:
thisfor chaining.
-
getConnectTimeout
public long getConnectTimeout()
- Returns:
- Connect timeout.
-
setMaxConnectTimeout
@IgniteSpiConfiguration(optional=true) public TcpCommunicationSpi setMaxConnectTimeout(long maxConnTimeout)
Sets maximum connect timeout. If handshake is not established within connect timeout, then SPI tries to repeat handshake procedure with increased connect timeout. Connect timeout can grow till maximum timeout value, if maximum timeout value is reached then the handshake is considered as failed.0is interpreted as infinite timeout.If not provided, default value is
TcpCommunicationSpi.DFLT_MAX_CONN_TIMEOUT.When this property is explicitly set
IgniteConfiguration.getFailureDetectionTimeout()is ignored.- Parameters:
maxConnTimeout- Maximum connect timeout.- Returns:
thisfor chaining.
-
getMaxConnectTimeout
public long getMaxConnectTimeout()
Gets maximum connect timeout.- Returns:
- Maximum connect timeout.
-
setReconnectCount
@IgniteSpiConfiguration(optional=true) public TcpCommunicationSpi setReconnectCount(int reconCnt)
Sets maximum number of reconnect attempts used when establishing connection with remote nodes.If not provided, default value is
TcpCommunicationSpi.DFLT_RECONNECT_CNT.When this property is explicitly set
IgniteConfiguration.getFailureDetectionTimeout()is ignored.- Parameters:
reconCnt- Maximum number of reconnection attempts.- Returns:
thisfor chaining.
-
getReconnectCount
public int getReconnectCount()
Gets maximum number of reconnect attempts used when establishing connection with remote nodes.- Returns:
- Reconnects count.
-
setDirectBuffer
@IgniteSpiConfiguration(optional=true) public TcpCommunicationSpi setDirectBuffer(boolean directBuf)
Sets flag to allocate direct or heap buffer in SPI. If value istrue, then SPI will useByteBuffer.allocateDirect(int)call. Otherwise, SPI will useByteBuffer.allocate(int)call.If not provided, default value is
true.- Parameters:
directBuf- Flag indicates to allocate direct or heap buffer in SPI.- Returns:
thisfor chaining.
-
isDirectBuffer
public boolean isDirectBuffer()
Gets flag that indicates whether direct or heap allocated buffer is used.- Returns:
- Flag that indicates whether direct or heap allocated buffer is used.
-
isDirectSendBuffer
public boolean isDirectSendBuffer()
Gets flag defining whether direct send buffer should be used.- Returns:
Trueif direct buffers should be used.
-
setDirectSendBuffer
@IgniteSpiConfiguration(optional=true) public TcpCommunicationSpi setDirectSendBuffer(boolean directSndBuf)
Sets whether to use direct buffer for sending. If not provided default isfalse.- Parameters:
directSndBuf-Trueto use direct buffers for send.- Returns:
thisfor chaining.
-
setSelectorsCount
@IgniteSpiConfiguration(optional=true) public TcpCommunicationSpi setSelectorsCount(int selectorsCnt)
Sets the count of selectors te be used in TCP server. If not provided, default value isTcpCommunicationSpi.DFLT_SELECTORS_CNT.- Parameters:
selectorsCnt- Selectors count.- Returns:
thisfor chaining.
-
getSelectorsCount
public int getSelectorsCount()
- Returns:
- Count of selectors in TCP server.
-
getSelectorSpins
public long getSelectorSpins()
- Returns:
- Selector thread busy-loop iterations.
-
setSelectorSpins
@IgniteSpiConfiguration(optional=true) public TcpCommunicationSpi setSelectorSpins(long selectorSpins)
Defines how many non-blockingselector.selectNow()should be made before falling intoselector.select(long)in NIO server. Long value. Default is0. Can be set toLong.MAX_VALUEso selector threads will never block.- Parameters:
selectorSpins- Selector thread busy-loop iterations.- Returns:
thisfor chaining.
-
setConnectionRequestor
public void setConnectionRequestor(ConnectionRequestor connectionRequestor)
-
setTcpNoDelay
@IgniteSpiConfiguration(optional=true) public TcpCommunicationSpi setTcpNoDelay(boolean tcpNoDelay)
Sets value forTCP_NODELAYsocket option. Each socket will be opened using provided value.Setting this option to
truedisables Nagle's algorithm for socket decreasing latency and delivery time for small messages.For systems that work under heavy network load it is advisable to set this value to
false.If not provided, default value is
TcpCommunicationSpi.DFLT_TCP_NODELAY.- Parameters:
tcpNoDelay-Trueto disable TCP delay.- Returns:
thisfor chaining.
-
isTcpNoDelay
public boolean isTcpNoDelay()
Gets value forTCP_NODELAYsocket option.- Returns:
Trueif TCP delay is disabled.
-
isFilterReachableAddresses
public boolean isFilterReachableAddresses()
Gets value forFILTER_REACHABLE_ADDRESSESsocket option.- Returns:
Trueif needed to filter reachable addresses.
-
setFilterReachableAddresses
@IgniteSpiConfiguration(optional=true) public TcpCommunicationSpi setFilterReachableAddresses(boolean filterReachableAddresses)
Setting this option totrueenables filter for reachable addresses on creating tcp client.Usually its advised to set this value to
false.If not provided, default value is
TcpCommunicationSpi.DFLT_FILTER_REACHABLE_ADDRESSES.- Parameters:
filterReachableAddresses-Trueto filter reachable addresses.- Returns:
thisfor chaining.
-
setSocketReceiveBuffer
@IgniteSpiConfiguration(optional=true) public TcpCommunicationSpi setSocketReceiveBuffer(int sockRcvBuf)
Sets receive buffer size for sockets created or accepted by this SPI.If not provided, default is
TcpCommunicationSpi.DFLT_SOCK_BUF_SIZE.- Parameters:
sockRcvBuf- Socket receive buffer size.- Returns:
thisfor chaining.
-
getSocketReceiveBuffer
public int getSocketReceiveBuffer()
- Returns:
- Socket receive buffer size.
-
setSocketSendBuffer
@IgniteSpiConfiguration(optional=true) public TcpCommunicationSpi setSocketSendBuffer(int sockSndBuf)
Sets send buffer size for sockets created or accepted by this SPI.If not provided, default is
TcpCommunicationSpi.DFLT_SOCK_BUF_SIZE.- Parameters:
sockSndBuf- Socket send buffer size.- Returns:
thisfor chaining.
-
getSocketSendBuffer
public int getSocketSendBuffer()
- Returns:
- Socket send buffer size.
-
setMessageQueueLimit
@IgniteSpiConfiguration(optional=true) public TcpCommunicationSpi setMessageQueueLimit(int msgQueueLimit)
Sets message queue limit for incoming and outgoing messages.When set to positive number send queue is limited to the configured value.
0disables the size limitations.If not provided, default is
TcpCommunicationSpi.DFLT_MSG_QUEUE_LIMIT.- Parameters:
msgQueueLimit- Send queue size limit.- Returns:
thisfor chaining.
-
getMessageQueueLimit
public int getMessageQueueLimit()
Gets message queue limit for incoming and outgoing messages.- Returns:
- Send queue size limit.
-
getSlowClientQueueLimit
public int getSlowClientQueueLimit()
- Returns:
- Slow client queue limit.
-
failureDetectionTimeoutEnabled
public void failureDetectionTimeoutEnabled(boolean enabled)
Enables or disables failure detection timeout.- Overrides:
failureDetectionTimeoutEnabledin classIgniteSpiAdapter- Parameters:
enabled-trueif enable,falseotherwise.
-
failureDetectionTimeoutEnabled
public boolean failureDetectionTimeoutEnabled()
Checks whether failure detection timeout is enabled for thisIgniteSpi.- Overrides:
failureDetectionTimeoutEnabledin classIgniteSpiAdapter- Returns:
trueif enabled,falseotherwise.
-
failureDetectionTimeout
public long failureDetectionTimeout()
Returns failure detection timeout set to use for network related operations.- Overrides:
failureDetectionTimeoutin classIgniteSpiAdapter- Returns:
- failure detection timeout in milliseconds or
0if the timeout is disabled.
-
forceClientToServerConnections
public boolean forceClientToServerConnections()
- Returns:
- Force client to server connections flag.
- See Also:
setForceClientToServerConnections(boolean)
-
setForceClientToServerConnections
@IgniteSpiConfiguration(optional=true) public TcpCommunicationSpi setForceClientToServerConnections(boolean forceClientToSrvConnections)
Applicable for clients only. Sets PSI in the mode when server node cannot open TCP connection to the current node. Possile reasons for that may be specific network configurations or security rules. In this mode, when server needs the connection with client, it usesDiscoverySpiprotocol to notify client about it. After that client opens the required connection from its side.
-
setSlowClientQueueLimit
@IgniteSpiConfiguration(optional=true) public TcpCommunicationSpi setSlowClientQueueLimit(int slowClientQueueLimit)
Sets slow client queue limit. When set to a positive number, communication SPI will monitor clients outbound message queue sizes and will drop those clients whose queue exceeded this limit. This value should be set to less or equal value thangetMessageQueueLimit()which controls message back-pressure for server nodes. The default value for this parameter is0which meansunlimited.- Parameters:
slowClientQueueLimit- Slow client queue limit.- Returns:
thisfor chaining.
-
boundPort
public int boundPort()
- Returns:
- Bound TCP server port.
-
setName
public TcpCommunicationSpi setName(String name)
Sets SPI name.- Overrides:
setNamein classIgniteSpiAdapter- Parameters:
name- SPI name.- Returns:
thisfor chaining.
-
getNodeAttributes
public Map<String,Object> getNodeAttributes() throws IgniteSpiException
This method is called before SPI starts (before methodIgniteSpi.spiStart(String)is called). It allows SPI implementation to add attributes to a local node. Kernal collects these attributes from all SPI implementations loaded up and then passes it to discovery SPI so that they can be exchanged with other nodes.- Specified by:
getNodeAttributesin interfaceIgniteSpi- Overrides:
getNodeAttributesin classIgniteSpiAdapter- Returns:
- Map of local node attributes this SPI wants to add.
- Throws:
IgniteSpiException- Throws in case of any error.
-
-