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

## Class ConnectionClientPool

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

    public class ConnectionClientPool
    extends Object

Registry of client connections.

### Constructor Summary

Constructors
Constructor and Description

`ConnectionClientPool(TcpCommunicationConfiguration cfg, AttributeNames attrs, IgniteLogger log, TcpCommunicationMetricsListener metricsLsnr, Supplier<ClusterNode> locNodeSupplier, Function<UUID,ClusterNode> nodeGetter, Supplier<MessageFormatter> msgFormatterSupplier, WorkersRegistry registry, TcpCommunicationSpi tcpCommSpi, ClusterStateProvider clusterStateProvider, GridNioServerWrapper nioSrvWrapper, String igniteInstanceName)`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addNodeClient(ClusterNode node, int connIdx, GridCommunicationClient addClient)`
`GridCommunicationClient[]` `clientFor(UUID id)`
`String` `clientString(GridCommunicationClient client, ClusterNode node)` Returns the string representation of client with protection from null client value.
`void` `completeFutures(IgniteClientDisconnectedCheckedException err)`
`@Nullable GridCommunicationClient` `createCommunicationClient(ClusterNode node, int connIdx)`
`Iterable<? extends Map.Entry<UUID,GridCommunicationClient[]>>` `entrySet()` Clients entries.
`void` `forceClose()` Close all connections of this instance.
`void` `forceCloseConnection(UUID nodeId)` Closing connections to node.
`GridFutureAdapter<GridCommunicationClient>` `getFut(ConnectionKey connKey)`
`void` `metricsListener(@Nullable TcpCommunicationMetricsListener metricsLsnr)`
`void` `onNodeLeft(UUID nodeId)`
`GridFutureAdapter<GridCommunicationClient>` `putIfAbsentFut(ConnectionKey key, GridFutureAdapter<GridCommunicationClient> fut)`
`void` `removeFut(ConnectionKey connKey, GridFutureAdapter<GridCommunicationClient> fut)`
`boolean` `removeNodeClient(UUID nodeId, GridCommunicationClient rmvClient)`
`GridCommunicationClient` `reserveClient(ClusterNode node, int connIdx)` Returns existing or just created client to node.
`void` `stop()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### ConnectionClientPool

    public ConnectionClientPool(TcpCommunicationConfiguration cfg,
                                AttributeNames attrs,
                                IgniteLogger log,
                                TcpCommunicationMetricsListener metricsLsnr,
                                Supplier<ClusterNode> locNodeSupplier,
                                Function<UUID,ClusterNode> nodeGetter,
                                Supplier<MessageFormatter> msgFormatterSupplier,
                                WorkersRegistry registry,
                                TcpCommunicationSpi tcpCommSpi,
                                ClusterStateProvider clusterStateProvider,
                                GridNioServerWrapper nioSrvWrapper,
                                String igniteInstanceName)

Parameters:
  `cfg` - Config.
  `attrs` - Attributes.
  `log` - Logger.
  `metricsLsnr` - Metrics listener.
  `locNodeSupplier` - Local node supplier.
  `nodeGetter` - Node getter.
  `msgFormatterSupplier` - Message formatter supplier.
  `registry` - Registry.
  `tcpCommSpi` - Tcp communication spi.
  `clusterStateProvider` - Cluster state provider.
  `nioSrvWrapper` - Nio server wrapper.
  `igniteInstanceName` - Ignite instance name.

### Method Detail

#### stop

    public void stop()

#### reserveClient

    public GridCommunicationClient reserveClient(ClusterNode node,
                                                 int connIdx)
                                          throws IgniteCheckedException

Returns existing or just created client to node.

Parameters:
  `node` - Node to which client should be open.
  `connIdx` - Connection index.
Returns:
  The existing or just created client.
Throws:
  `IgniteCheckedException` - Thrown if any exception occurs.

#### createCommunicationClient

    @Nullable
    public @Nullable GridCommunicationClient createCommunicationClient(ClusterNode node,
                                                                                 int connIdx)
                                                                          throws IgniteCheckedException

Parameters:
  `node` - Node to create client for.
  `connIdx` - Connection index.
Returns:
  Client.
Throws:
  `IgniteCheckedException` - If failed.

#### clientString

    public String clientString(GridCommunicationClient client,
                               ClusterNode node)
                        throws IgniteCheckedException

Returns the string representation of client with protection from null client value. If the client if null, string representation is built from cluster node.

Parameters:
  `client` - communication client
  `node` - cluster node to which the client tried to establish a connection
Returns:
  string representation of client
Throws:
  `IgniteCheckedException` - if failed

#### addNodeClient

    public void addNodeClient(ClusterNode node,
                              int connIdx,
                              GridCommunicationClient addClient)

Parameters:
  `node` - Node.
  `connIdx` - Connection index.
  `addClient` - Client to add.

#### removeNodeClient

    public boolean removeNodeClient(UUID nodeId,
                                    GridCommunicationClient rmvClient)

Parameters:
  `nodeId` - Node ID.
  `rmvClient` - Client to remove.
Returns:
  `True` if client was removed.

#### forceCloseConnection

    public void forceCloseConnection(UUID nodeId)
                              throws IgniteCheckedException

Closing connections to node. NOTE: It is recommended only for tests.

Parameters:
  `nodeId` - Node for which to close connections.
Throws:
  `IgniteCheckedException` - If occurs.

#### onNodeLeft

    public void onNodeLeft(UUID nodeId)

Parameters:
  `nodeId` - Node id.

#### clientFor

    public GridCommunicationClient[] clientFor(UUID id)

Parameters:
  `id` - Id.

#### entrySet

    public Iterable<? extends Map.Entry<UUID,GridCommunicationClient[]>> entrySet()

Clients entries.

#### removeFut

    public void removeFut(ConnectionKey connKey,
                          GridFutureAdapter<GridCommunicationClient> fut)

Parameters:
  `connKey` - Connection key.
  `fut` - Future.

#### getFut

    public GridFutureAdapter<GridCommunicationClient> getFut(ConnectionKey connKey)

Parameters:
  `connKey` - Connection key.

#### putIfAbsentFut

    public GridFutureAdapter<GridCommunicationClient> putIfAbsentFut(ConnectionKey key,
                                                                     GridFutureAdapter<GridCommunicationClient> fut)

Parameters:
  `key` - Key.
  `fut` - Future.

#### forceClose

    public void forceClose()

Close all connections of this instance.

#### completeFutures

    public void completeFutures(IgniteClientDisconnectedCheckedException err)

Parameters:
  `err` - Err.

#### metricsListener

    public void metricsListener(@Nullable
                                @Nullable TcpCommunicationMetricsListener metricsLsnr)

Parameters:
  `metricsLsnr` - New statistics.

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.14.0
Release Date | : September 29 2022