org.apache.ignite.internal.util.nio

## Interface GridNioSession

All Known Implementing Classes:
  GridNioSessionImpl

    public interface GridNioSession

This interface represents established or closed connection between nio server and remote client.

### Method Summary

Methods
`boolean` `accepted()`
`<T> T` `addMeta(int key, T val)` Adds metadata associated with specified key.
`long` `bytesReceived()` Gets the total count of bytes received since the session was created.
`long` `bytesSent()` Gets the total count of bytes sent since the session was created.
`GridNioFuture<Boolean>` `close()` Performs a request for asynchronous session close.
`long` `closeTime()` If session is closed, this method will return session close time returned by `System.currentTimeMillis()`.
`long` `createTime()` Gets the time when the session was created.
`long` `lastReceiveTime()` Returns the time when last read activity was performed on this session.
`long` `lastSendScheduleTime()` Returns time when last send was scheduled on this session.
`long` `lastSendTime()` Returns time when last send activity was performed on this session.
`InetSocketAddress` `localAddress()` Gets local address of this session.
`<T> T` `meta(int key)` Gets metadata associated with specified key.
`GridNioFuture<?>` `pauseReads()` Pauses reads.
`boolean` `readsPaused()` Checks whether reads are paused.
`GridNioRecoveryDescriptor` `recoveryDescriptor()`
`void` `recoveryDescriptor(GridNioRecoveryDescriptor recoveryDesc)`
`InetSocketAddress` `remoteAddress()` Gets address of remote peer on this session.
`<T> T` `removeMeta(int key)` Removes metadata with the specified key.
`GridNioFuture<?>` `resumeReads()` Resumes session reads.
`GridNioFuture<?>` `send(Object msg)` Performs a request for asynchronous data send.

### Method Detail

#### localAddress

    @Nullable
    InetSocketAddress localAddress()

Gets local address of this session.

Returns:
  Local network address or `null` if non-socket communication is used.

#### remoteAddress

    @Nullable
    InetSocketAddress remoteAddress()

Gets address of remote peer on this session.

Returns:
  Address of remote peer or `null` if non-socket communication is used.

#### bytesSent

    long bytesSent()

Gets the total count of bytes sent since the session was created.

Returns:
  Total count of bytes sent.

#### bytesReceived

    long bytesReceived()

Gets the total count of bytes received since the session was created.

Returns:
  Total count of bytes received.

#### createTime

    long createTime()

Gets the time when the session was created.

Returns:
  Time when this session was created returned by `System.currentTimeMillis()`.

#### closeTime

    long closeTime()

If session is closed, this method will return session close time returned by `System.currentTimeMillis()`. If session is not closed, this method will return `0`.

Returns:
  Session close time.

#### lastReceiveTime

    long lastReceiveTime()

Returns the time when last read activity was performed on this session.

Returns:
  Lats receive time.

#### lastSendTime

    long lastSendTime()

Returns time when last send activity was performed on this session.

Returns:
  Last send time.

#### lastSendScheduleTime

    long lastSendScheduleTime()

Returns time when last send was scheduled on this session.

Returns:
  Last send schedule time.

#### close

    GridNioFuture<Boolean> close()

Performs a request for asynchronous session close.

Returns:
  Future representing result.

#### send

    GridNioFuture<?> send(Object msg)

Performs a request for asynchronous data send.

Parameters:
  `msg` - Message to be sent. This message will be eventually passed in to a parser plugged to the nio server.
Returns:
  Future representing result.

#### meta

    @Nullable
    <T> T meta(int key)

Gets metadata associated with specified key.

Parameters:
  `key` - Key to look up.
Returns:
  Associated meta object or `null` if meta was not found.

#### addMeta

    @Nullable
    <T> T addMeta(int key,
                         @Nullable
                         T val)

Adds metadata associated with specified key.

Parameters:
  `key` - Metadata Key.
  `val` - Metadata value.
Returns:
  Previously associated object or `null` if no objects were associated.

#### removeMeta

    @Nullable
    <T> T removeMeta(int key)

Removes metadata with the specified key.

Parameters:
  `key` - Metadata key.
Returns:
  Object that was associated with the key or `null`.

#### accepted

    boolean accepted()

Returns:
  `True` if this connection was initiated from remote node.

#### resumeReads

    GridNioFuture<?> resumeReads()

Resumes session reads.

Returns:
  Future representing result.

#### pauseReads

    GridNioFuture<?> pauseReads()

Pauses reads.

Returns:
  Future representing result.

#### readsPaused

    boolean readsPaused()

Checks whether reads are paused.

Returns:
  `True` if reads are paused.

#### recoveryDescriptor

    void recoveryDescriptor(GridNioRecoveryDescriptor recoveryDesc)

Parameters:
  `recoveryDesc` - Recovery descriptor.

#### recoveryDescriptor

    @Nullable
    GridNioRecoveryDescriptor recoveryDescriptor()

Returns:
  Recovery descriptor if recovery is supported, `null otherwise.`

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.5.0-b1
Release Date | : December 1 2015