org.apache.ignite.internal.util.nio

## Class GridNioFilterChain<T>

- java.lang.Object
- - org.apache.ignite.internal.util.nio.GridNioFilterAdapter
  - - org.apache.ignite.internal.util.nio.GridNioFilterChain<T>

All Implemented Interfaces:
  GridNioFilter

    public class GridNioFilterChain<T>
    extends GridNioFilterAdapter

Filter chain implementation for nio server filters.

### Field Summary

### Fields inherited from class org.apache.ignite.internal.util.nio.GridNioFilterAdapter

`nextFilter, prevFilter`

### Constructor Summary

Constructors
Constructor and Description
`GridNioFilterChain(IgniteLogger log, GridNioServerListener<T> lsnr, GridNioFilter head, GridNioFilter... filters)` Constructor.

### Method Summary

Methods
`void` `onExceptionCaught(GridNioSession ses, IgniteCheckedException e)` Starts chain notification from head to tail.
`void` `onMessageReceived(GridNioSession ses, Object msg)` Starts chain notification from head to tail.
`GridNioFuture<?>` `onPauseReads(GridNioSession ses)` Starts chain notification from tail to head.
`GridNioFuture<?>` `onResumeReads(GridNioSession ses)` Starts chain notification from tail to head.
`GridNioFuture<Boolean>` `onSessionClose(GridNioSession ses)` Starts chain notification from tail to head.
`void` `onSessionClosed(GridNioSession ses)` Starts chain notification from head to tail.
`void` `onSessionIdleTimeout(GridNioSession ses)` Called when session is idle for longer time that is allowed by NIO server.
`void` `onSessionOpened(GridNioSession ses)` Starts chain notification from head to tail.
`GridNioFuture<?>` `onSessionWrite(GridNioSession ses, Object msg, boolean fut, IgniteInClosure<IgniteException> ackC)` Starts chain notification from tail to head.
`void` `onSessionWriteTimeout(GridNioSession ses)` Called when session has not empty write buffer that has not been fully flushed during max timeout allowed by NIO server.
`void` `start()` Starts all filters in order from application layer to the network layer.
`void` `stop()` Stops all filters in order from network layer to the application layer.
`String` `toString()`

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

`nextFilter, nextFilter, previousFilter, previousFilter, proceedExceptionCaught, proceedMessageReceived, proceedPauseReads, proceedResumeReads, proceedSessionClose, proceedSessionClosed, proceedSessionIdleTimeout, proceedSessionOpened, proceedSessionWrite, proceedSessionWriteTimeout`

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

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

### Constructor Detail

#### GridNioFilterChain

    public GridNioFilterChain(IgniteLogger log,
                      GridNioServerListener<T> lsnr,
                      GridNioFilter head,
                      GridNioFilter... filters)

Constructor.

Parameters:
  `log` - Logger instance.
  `lsnr` - Listener for events passed through chain.
  `head` - First filter in chain, it expected to be connected to actual endpoint.
  `filters` - Filters applied between listener and head. Will be inserted in the same order, so chain will look like (lsnr) -> (filters[0]) -> ... -> (filters[n]) -> (head).

### Method Detail

#### toString

    public String toString()

Overrides:
  `toString` in class `GridNioFilterAdapter`

#### start

    public void start()

Starts all filters in order from application layer to the network layer.

Specified by:
  `start` in interface `GridNioFilter`
Overrides:
  `start` in class `GridNioFilterAdapter`

#### stop

    public void stop()

Stops all filters in order from network layer to the application layer.

Specified by:
  `stop` in interface `GridNioFilter`
Overrides:
  `stop` in class `GridNioFilterAdapter`

#### onSessionOpened

    public void onSessionOpened(GridNioSession ses)
                         throws IgniteCheckedException

Starts chain notification from head to tail.

Parameters:
  `ses` - Session that was created.
Throws:
  `IgniteCheckedException` - If IgniteCheckedException occurred while handling event.

#### onSessionClosed

    public void onSessionClosed(GridNioSession ses)
                         throws IgniteCheckedException

Starts chain notification from head to tail.

Parameters:
  `ses` - Session that was closed.
Throws:
  `IgniteCheckedException` - If IgniteCheckedException occurred while handling event.

#### onExceptionCaught

    public void onExceptionCaught(GridNioSession ses,
                         IgniteCheckedException e)

Starts chain notification from head to tail.

Parameters:
  `ses` - Session in which GridNioException was caught.
  `e` - IgniteCheckedException instance.

#### onMessageReceived

    public void onMessageReceived(GridNioSession ses,
                         Object msg)
                           throws IgniteCheckedException

Starts chain notification from head to tail.

Parameters:
  `ses` - Session in which message was received.
  `msg` - Received message.
Throws:
  `IgniteCheckedException` - If IgniteCheckedException occurred while handling event.

#### onSessionWrite

    public GridNioFuture<?> onSessionWrite(GridNioSession ses,
                                  Object msg,
                                  boolean fut,
                                  IgniteInClosure<IgniteException> ackC)
                                    throws IgniteCheckedException

Starts chain notification from tail to head.

Parameters:
  `ses` - Session to which message should be written.
  `msg` - Message to write.
  `fut` - `True` if write future should be created.
  `ackC` - Closure invoked when message ACK is received.
Returns:
  Send future.
Throws:
  `IgniteCheckedException` - If IgniteCheckedException occurred while handling event.

#### onSessionClose

    public GridNioFuture<Boolean> onSessionClose(GridNioSession ses)
                                          throws IgniteCheckedException

Starts chain notification from tail to head.

Parameters:
  `ses` - Session to close.
Returns:
  Close future.
Throws:
  `IgniteCheckedException` - If IgniteCheckedException occurred while handling event.

#### onSessionIdleTimeout

    public void onSessionIdleTimeout(GridNioSession ses)
                              throws IgniteCheckedException

Called when session is idle for longer time that is allowed by NIO server.

Parameters:
  `ses` - Session that is idle.
Throws:
  `IgniteCheckedException` - If filter is not in chain or GridNioException occurred in the underlying filter.

#### onSessionWriteTimeout

    public void onSessionWriteTimeout(GridNioSession ses)
                               throws IgniteCheckedException

Called when session has not empty write buffer that has not been fully flushed during max timeout allowed by NIO server.

Parameters:
  `ses` - Session that has timed out writes.
Throws:
  `IgniteCheckedException` - If filter is not in chain or GridNioException occurred in the underlying filter.

#### onPauseReads

    public GridNioFuture<?> onPauseReads(GridNioSession ses)
                                  throws IgniteCheckedException

Starts chain notification from tail to head.

Specified by:
  `onPauseReads` in interface `GridNioFilter`
Overrides:
  `onPauseReads` in class `GridNioFilterAdapter`
Parameters:
  `ses` - Session to pause reads.
Returns:
  Future.
Throws:
  `IgniteCheckedException` - If IgniteCheckedException occurred while handling event.

#### onResumeReads

    public GridNioFuture<?> onResumeReads(GridNioSession ses)
                                   throws IgniteCheckedException

Starts chain notification from tail to head.

Specified by:
  `onResumeReads` in interface `GridNioFilter`
Overrides:
  `onResumeReads` in class `GridNioFilterAdapter`
Parameters:
  `ses` - Session to resume reads.
Returns:
  Future.
Throws:
  `IgniteCheckedException` - If IgniteCheckedException occurred while handling event.

2017 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.2.0
Release Date | : September 15 2017