org.apache.ignite.spi.communication.tcp.internal

## Class TcpCommunicationSpiMBeanImpl

- java.lang.Object
- - org.apache.ignite.spi.IgniteSpiMBeanAdapter
  - - org.apache.ignite.spi.communication.tcp.internal.TcpCommunicationSpiMBeanImpl

All Implemented Interfaces:
  TcpCommunicationSpiMBean, IgniteSpiManagementMBean

    public class TcpCommunicationSpiMBeanImpl
    extends IgniteSpiMBeanAdapter
    implements TcpCommunicationSpiMBean

MBean implementation for TcpCommunicationSpi.

### Field Summary

### Fields inherited from class org.apache.ignite.spi.IgniteSpiMBeanAdapter

`spiAdapter`

### Constructor Summary

Constructors
Constructor and Description
`TcpCommunicationSpiMBeanImpl(IgniteSpiAdapter spiAdapter, TcpCommunicationMetricsListener metricsLsnr, TcpCommunicationConfiguration cfg, ClusterStateProvider stateProvider)`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `dumpStats()` Dumps SPI per-connection stats to logs.
`int` `getAckSendThreshold()` Gets number of received messages per connection to node after which acknowledgment message is sent.
`int` `getConnectionsPerNode()` Gets number of connections to each remote node. if `TcpCommunicationSpiMBean.isUsePairedConnections()` is `true` then number of connections is doubled and half is used for incoming and half for outgoing messages.
`long` `getConnectTimeout()` Gets connect timeout used when establishing connection with remote nodes.
`long` `getIdleConnectionTimeout()` Gets maximum idle connection time upon which idle connections will be closed.
`String` `getLocalAddress()` Gets local host address for socket binding.
`int` `getLocalPort()` Gets local port for socket binding.
`int` `getLocalPortRange()` Gets maximum number of local ports tried if all previously tried ports are occupied.
`long` `getMaxConnectTimeout()` Gets maximum connect timeout.
`int` `getMessageQueueLimit()` Gets message queue limit for incoming and outgoing messages.
`int` `getOutboundMessagesQueueSize()` Gets outbound messages queue size.
`long` `getReceivedBytesCount()` Gets received bytes count.
`Map<UUID,Long>` `getReceivedMessagesByNode()` Gets received messages counts (grouped by node).
`Map<String,Long>` `getReceivedMessagesByType()` Gets received messages counts (grouped by type).
`int` `getReceivedMessagesCount()` Gets received messages count.
`int` `getReconnectCount()` Gets maximum number of reconnect attempts used when establishing connection with remote nodes.
`int` `getSelectorsCount()` Gets count of selectors used in TCP server.
`long` `getSelectorSpins()` Defines how many non-blocking `selector.selectNow()` should be made before falling into `selector.select(long)` in NIO server.
`long` `getSentBytesCount()` Gets sent bytes count.
`Map<UUID,Long>` `getSentMessagesByNode()` Gets sent messages counts (grouped by node).
`Map<String,Long>` `getSentMessagesByType()` Gets sent messages counts (grouped by type).
`int` `getSentMessagesCount()` Gets sent messages count.
`int` `getSharedMemoryPort()` Gets local port for shared memory communication.
`int` `getSlowClientQueueLimit()` Gets slow client queue limit.
`int` `getSocketReceiveBuffer()` Gets receive buffer size for sockets created or accepted by this SPI.
`int` `getSocketSendBuffer()` Gets send buffer size for sockets created or accepted by this SPI.
`long` `getSocketWriteTimeout()` Gets socket write timeout for TCP connections.
`int` `getUnacknowledgedMessagesBufferSize()` Gets maximum number of stored unacknowledged messages per connection to node.
`boolean` `isDirectBuffer()` Gets flag that indicates whether direct or heap allocated buffer is used.
`boolean` `isDirectSendBuffer()` Gets flag defining whether direct send buffer should be used.
`boolean` `isTcpNoDelay()` Gets value for `TCP_NODELAY` socket option.
`boolean` `isUsePairedConnections()` Returns `true` if `TcpCommunicationSpi` should maintain connection for outgoing and incoming messages separately.

### Methods inherited from class org.apache.ignite.spi.IgniteSpiMBeanAdapter

`getIgniteHome, getLocalNodeId, getName, getStartTimestamp, getStartTimestampFormatted, getUpTime, getUpTimeFormatted`

### 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.IgniteSpiManagementMBean

`getIgniteHome, getLocalNodeId, getName, getStartTimestamp, getStartTimestampFormatted, getUpTime, getUpTimeFormatted`

### Constructor Detail

#### TcpCommunicationSpiMBeanImpl

    public TcpCommunicationSpiMBeanImpl(IgniteSpiAdapter spiAdapter,
                                        TcpCommunicationMetricsListener metricsLsnr,
                                        TcpCommunicationConfiguration cfg,
                                        ClusterStateProvider stateProvider)

Parameters:
  `spiAdapter` - Spi adapter.
  `metricsLsnr` - Metrics listener.
  `cfg` - Config.
  `stateProvider` - State provider.

### Method Detail

#### getLocalAddress

    public String getLocalAddress()

Gets local host address for socket binding. Beside loopback address physical node could have several other ones, but only one is assigned to grid node.

Specified by:
  `getLocalAddress` in interface `TcpCommunicationSpiMBean`
Returns:
  Grid node IP address.

#### getLocalPort

    public int getLocalPort()

Gets local port for socket binding.

Specified by:
  `getLocalPort` in interface `TcpCommunicationSpiMBean`
Returns:
  Port number.

#### getLocalPortRange

    public int getLocalPortRange()

Gets maximum number of local ports tried if all previously tried ports are occupied.

Specified by:
  `getLocalPortRange` in interface `TcpCommunicationSpiMBean`
Returns:
  Local port range.

#### isUsePairedConnections

    public boolean isUsePairedConnections()

Returns `true` if `TcpCommunicationSpi` should maintain connection for outgoing and incoming messages separately. In this case total number of connections between local and some remote node is `TcpCommunicationSpiMBean.getConnectionsPerNode()` * 2.

Returns `false` if each connection of `TcpCommunicationSpiMBean.getConnectionsPerNode()` should be used for outgoing and incoming messages.

Default is `false`.

Specified by:
  `isUsePairedConnections` in interface `TcpCommunicationSpiMBean`
Returns:
  `true` to use paired connections and `false` otherwise.
See Also:
  `TcpCommunicationSpiMBean.getConnectionsPerNode()`

#### getConnectionsPerNode

    public int getConnectionsPerNode()

Gets number of connections to each remote node. if `TcpCommunicationSpiMBean.isUsePairedConnections()` is `true` then number of connections is doubled and half is used for incoming and half for outgoing messages.

Specified by:
  `getConnectionsPerNode` in interface `TcpCommunicationSpiMBean`
Returns:
  Number of connections per node.
See Also:
  `TcpCommunicationSpiMBean.isUsePairedConnections()`

#### getSharedMemoryPort

    public int getSharedMemoryPort()

Gets local port for shared memory communication.

Specified by:
  `getSharedMemoryPort` in interface `TcpCommunicationSpiMBean`
Returns:
  Port number.

#### getIdleConnectionTimeout

    public long getIdleConnectionTimeout()

Gets maximum idle connection time upon which idle connections will be closed.

Specified by:
  `getIdleConnectionTimeout` in interface `TcpCommunicationSpiMBean`
Returns:
  Maximum idle connection time.

#### getSocketWriteTimeout

    public long getSocketWriteTimeout()

Gets socket write timeout for TCP connections. If message can not be written to socket within this time then connection is closed and reconnect is attempted.

Specified by:
  `getSocketWriteTimeout` in interface `TcpCommunicationSpiMBean`
Returns:
  Socket write timeout for TCP connections.

#### getAckSendThreshold

    public int getAckSendThreshold()

Gets number of received messages per connection to node after which acknowledgment message is sent.

Specified by:
  `getAckSendThreshold` in interface `TcpCommunicationSpiMBean`
Returns:
  Number of received messages after which acknowledgment is sent.

#### getUnacknowledgedMessagesBufferSize

    public int getUnacknowledgedMessagesBufferSize()

Gets 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.

Specified by:
  `getUnacknowledgedMessagesBufferSize` in interface `TcpCommunicationSpiMBean`
Returns:
  Maximum number of unacknowledged messages.

#### getConnectTimeout

    public long getConnectTimeout()

Gets connect timeout used when establishing connection with remote nodes.

Specified by:
  `getConnectTimeout` in interface `TcpCommunicationSpiMBean`
Returns:
  Connect timeout.

#### getMaxConnectTimeout

    public long getMaxConnectTimeout()

Gets maximum connect timeout.

Specified by:
  `getMaxConnectTimeout` in interface `TcpCommunicationSpiMBean`
Returns:
  Maximum connect timeout.

#### getReconnectCount

    public int getReconnectCount()

Gets maximum number of reconnect attempts used when establishing connection with remote nodes.

Specified by:
  `getReconnectCount` in interface `TcpCommunicationSpiMBean`
Returns:
  Reconnects count.

#### isDirectBuffer

    public boolean isDirectBuffer()

Gets flag that indicates whether direct or heap allocated buffer is used.

Specified by:
  `isDirectBuffer` in interface `TcpCommunicationSpiMBean`
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.

Specified by:
  `isDirectSendBuffer` in interface `TcpCommunicationSpiMBean`
Returns:
  `True` if direct buffers should be used.

#### getSelectorsCount

    public int getSelectorsCount()

Gets count of selectors used in TCP server. Default value equals to the number of CPUs available in the system.

Specified by:
  `getSelectorsCount` in interface `TcpCommunicationSpiMBean`
Returns:
  Count of selectors in TCP server.

#### getSelectorSpins

    public long getSelectorSpins()

Defines how many non-blocking `selector.selectNow()` should be made before falling into `selector.select(long)` in NIO server. Long value. Default is `0`. Can be set to `Long.MAX_VALUE` so selector threads will never block.

Specified by:
  `getSelectorSpins` in interface `TcpCommunicationSpiMBean`
Returns:
  Selector thread busy-loop iterations.

#### isTcpNoDelay

    public boolean isTcpNoDelay()

Gets value for `TCP_NODELAY` socket option.

Specified by:
  `isTcpNoDelay` in interface `TcpCommunicationSpiMBean`
Returns:
  `True` if TCP delay is disabled.

#### getSocketReceiveBuffer

    public int getSocketReceiveBuffer()

Gets receive buffer size for sockets created or accepted by this SPI.

If not provided, default is `TcpCommunicationSpi.DFLT_SOCK_BUF_SIZE`.

Specified by:
  `getSocketReceiveBuffer` in interface `TcpCommunicationSpiMBean`
Returns:
  Socket receive buffer size.

#### getSocketSendBuffer

    public int getSocketSendBuffer()

Gets send buffer size for sockets created or accepted by this SPI.

If not provided, default is `TcpCommunicationSpi.DFLT_SOCK_BUF_SIZE`.

Specified by:
  `getSocketSendBuffer` in interface `TcpCommunicationSpiMBean`
Returns:
  Socket send buffer size.

#### getMessageQueueLimit

    public int getMessageQueueLimit()

Gets message queue limit for incoming and outgoing messages.

Specified by:
  `getMessageQueueLimit` in interface `TcpCommunicationSpiMBean`
Returns:
  Send queue size limit.

#### getSlowClientQueueLimit

    public int getSlowClientQueueLimit()

Gets slow client queue limit.

When set to a positive number, communication SPI will monitor clients outbound queue sizes and will drop those clients whose queue exceeded this limit.

Specified by:
  `getSlowClientQueueLimit` in interface `TcpCommunicationSpiMBean`
Returns:
  Slow client queue limit.

#### dumpStats

    public void dumpStats()

Dumps SPI per-connection stats to logs.

Specified by:
  `dumpStats` in interface `TcpCommunicationSpiMBean`

#### getSentMessagesCount

    public int getSentMessagesCount()

Gets sent messages count.

Specified by:
  `getSentMessagesCount` in interface `TcpCommunicationSpiMBean`
Returns:
  Sent messages count.

#### getSentBytesCount

    public long getSentBytesCount()

Gets sent bytes count.

Specified by:
  `getSentBytesCount` in interface `TcpCommunicationSpiMBean`
Returns:
  Sent bytes count.

#### getReceivedMessagesCount

    public int getReceivedMessagesCount()

Gets received messages count.

Specified by:
  `getReceivedMessagesCount` in interface `TcpCommunicationSpiMBean`
Returns:
  Received messages count.

#### getReceivedBytesCount

    public long getReceivedBytesCount()

Gets received bytes count.

Specified by:
  `getReceivedBytesCount` in interface `TcpCommunicationSpiMBean`
Returns:
  Received bytes count.

#### getReceivedMessagesByType

    public Map<String,Long> getReceivedMessagesByType()

Gets received messages counts (grouped by type).

Specified by:
  `getReceivedMessagesByType` in interface `TcpCommunicationSpiMBean`
Returns:
  Map containing message types and respective counts.

#### getReceivedMessagesByNode

    public Map<UUID,Long> getReceivedMessagesByNode()

Gets received messages counts (grouped by node).

Specified by:
  `getReceivedMessagesByNode` in interface `TcpCommunicationSpiMBean`
Returns:
  Map containing sender nodes and respective counts.

#### getSentMessagesByType

    public Map<String,Long> getSentMessagesByType()

Gets sent messages counts (grouped by type).

Specified by:
  `getSentMessagesByType` in interface `TcpCommunicationSpiMBean`
Returns:
  Map containing message types and respective counts.

#### getSentMessagesByNode

    public Map<UUID,Long> getSentMessagesByNode()

Gets sent messages counts (grouped by node).

Specified by:
  `getSentMessagesByNode` in interface `TcpCommunicationSpiMBean`
Returns:
  Map containing receiver nodes and respective counts.

#### getOutboundMessagesQueueSize

    public int getOutboundMessagesQueueSize()

Gets outbound messages queue size.

Specified by:
  `getOutboundMessagesQueueSize` in interface `TcpCommunicationSpiMBean`
Returns:
  Outbound messages queue size.

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.11.0
Release Date | : September 11 2021