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

## Class InboundConnectionHandler

- java.lang.Object
- - org.apache.ignite.internal.util.nio.GridNioServerListenerAdapter<Message>
  - - org.apache.ignite.spi.communication.tcp.internal.InboundConnectionHandler

All Implemented Interfaces:
  EventListener, GridNioServerListener<Message>

    public class InboundConnectionHandler
    extends GridNioServerListenerAdapter<Message>

This class implement NioListener which process handshake stage, and transmit messages to session.

### Constructor Summary

Constructors
Constructor and Description

`InboundConnectionHandler(IgniteLogger log, TcpCommunicationConfiguration cfg, Function<UUID,ClusterNode> nodeGetter, Supplier<ClusterNode> locNodeSupplier, ClusterStateProvider stateProvider, ConnectionClientPool clientPool, CommunicationWorker commWorker, ConnectGateway connectGate, Supplier<FailureProcessor> failureProcessorSupplier, AttributeNames attributeNames, TcpCommunicationMetricsListener metricsLsnr, GridNioServerWrapper nioSrvWrapper, CountDownLatch ctxInitLatch, boolean client, Supplier<Ignite> igniteExSupplier, CommunicationListener<Message> lsnr)`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `communicationWorker(CommunicationWorker commWorker)`
`void` `metricsListener(@Nullable TcpCommunicationMetricsListener metricsLsnr)`
`void` `onConnected(GridNioSession ses)` This method is called whenever a new client is connected and session is created.
`void` `onDisconnected(GridNioSession ses, @Nullable Exception e)` This method is called whenever client is disconnected due to correct connection close or due to `IOException` during network operations.
`void` `onFailure(FailureType failureType, Throwable failure)` Called when critical failure occurs in server implementation.
`void` `onMessage(GridNioSession ses, Message msg)` This method is called whenever a `GridNioParser` returns non-null value.
`void` `onMessageSent(GridNioSession ses, Message msg)` Handle message sent.
`void` `onSessionWriteTimeout(GridNioSession ses)` Called when session has non-empty write queue and server did not send any data within timeout interval.
`void` `setClientPool(ConnectionClientPool pool)`
`void` `setNioSrvWrapper(GridNioServerWrapper nioSrvWrapper)`
`void` `stop()` Disable processing of incoming messages.

### Methods inherited from class org.apache.ignite.internal.util.nio.GridNioServerListenerAdapter

`onSessionIdleTimeout`

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

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

### Constructor Detail

#### InboundConnectionHandler

    public InboundConnectionHandler(IgniteLogger log,
                                    TcpCommunicationConfiguration cfg,
                                    Function<UUID,ClusterNode> nodeGetter,
                                    Supplier<ClusterNode> locNodeSupplier,
                                    ClusterStateProvider stateProvider,
                                    ConnectionClientPool clientPool,
                                    CommunicationWorker commWorker,
                                    ConnectGateway connectGate,
                                    Supplier<FailureProcessor> failureProcessorSupplier,
                                    AttributeNames attributeNames,
                                    TcpCommunicationMetricsListener metricsLsnr,
                                    GridNioServerWrapper nioSrvWrapper,
                                    CountDownLatch ctxInitLatch,
                                    boolean client,
                                    Supplier<Ignite> igniteExSupplier,
                                    CommunicationListener<Message> lsnr)

Parameters:
  `log` - Logger.
  `cfg` - Config.
  `nodeGetter` - Node getter.
  `locNodeSupplier` - Local node supplier.
  `stateProvider` - State provider.
  `clientPool` - Client pool.
  `commWorker` - Communication worker.
  `connectGate` - Connect gate.
  `failureProcessorSupplier` - Failure processor supplier.
  `attributeNames` - Attribute names.
  `metricsLsnr` - Metrics listener.
  `nioSrvWrapper` - Nio server wrapper.
  `ctxInitLatch` - Context initialize latch.
  `client` - Client.
  `igniteExSupplier` - Returns already exists instance from spi.
  `lsnr` - Message listener

### Method Detail

#### setNioSrvWrapper

    public void setNioSrvWrapper(GridNioServerWrapper nioSrvWrapper)

Parameters:
  `nioSrvWrapper` - Nio server wrapper.

#### setClientPool

    public void setClientPool(ConnectionClientPool pool)

Parameters:
  `pool` - Pool.

#### onSessionWriteTimeout

    public void onSessionWriteTimeout(GridNioSession ses)

Called when session has non-empty write queue and server did not send any data within timeout interval.

Specified by:
  `onSessionWriteTimeout` in interface `GridNioServerListener<Message>`
Overrides:
  `onSessionWriteTimeout` in class `GridNioServerListenerAdapter<Message>`
Parameters:
  `ses` - Session that has timed out writes.

#### onConnected

    public void onConnected(GridNioSession ses)

This method is called whenever a new client is connected and session is created.

Parameters:
  `ses` - Newly created session for remote client.

#### onMessageSent

    public void onMessageSent(GridNioSession ses,
                              Message msg)

Handle message sent.

Specified by:
  `onMessageSent` in interface `GridNioServerListener<Message>`
Overrides:
  `onMessageSent` in class `GridNioServerListenerAdapter<Message>`
Parameters:
  `ses` - Session.
  `msg` - Message.

#### onMessage

    public void onMessage(GridNioSession ses,
                          Message msg)

This method is called whenever a `GridNioParser` returns non-null value.

Parameters:
  `ses` - Session on which message was received.
  `msg` - Parsed message.

#### onFailure

    public void onFailure(FailureType failureType,
                          Throwable failure)

Called when critical failure occurs in server implementation.

Specified by:
  `onFailure` in interface `GridNioServerListener<Message>`
Overrides:
  `onFailure` in class `GridNioServerListenerAdapter<Message>`

#### onDisconnected

    public void onDisconnected(GridNioSession ses,
                               @Nullable
                               @Nullable Exception e)

This method is called whenever client is disconnected due to correct connection close or due to `IOException` during network operations.

Parameters:
  `ses` - Closed session.
  `e` - Exception occurred, if any.

#### stop

    public void stop()

Disable processing of incoming messages.

#### communicationWorker

    public void communicationWorker(CommunicationWorker commWorker)

Parameters:
  `commWorker` - New communication worker.

#### metricsListener

    public void metricsListener(@Nullable
                                @Nullable TcpCommunicationMetricsListener metricsLsnr)

Parameters:
  `metricsLsnr` - New metrics listener.

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.16.0
Release Date | : December 15 2023