org.apache.ignite.internal.managers.communication

## Interface TransmissionHandler

    public interface TransmissionHandler

Class represents a handler for the set of files considered to be transferred from the remote node. This handler must be registered to and appropriate topic in `GridIoManager` prior to opening a new transmission connection to this topic.

NOTE: Only one such handler per registered topic is allowed for the communication manager. Only one thread is allowed for data processing within a single topic.

### TransmissionPolicy

Files from the remote node can be handled of two different ways within a single established connection. It is up to the sender to decide how the particular file must be processed by the remote node. The `TransmissionPolicy` is used for such purpose. If `TransmissionPolicy.FILE` type is received by remote node the #fileHandler() will be picked up to process this file, the otherwise for the `TransmissionPolicy.CHUNK` the #chunkHandler() will be picked up.

### Method Summary

All Methods Instance Methods Abstract Methods
`Consumer<ByteBuffer>` `chunkHandler(UUID nodeId, TransmissionMeta initMeta)` Chunk handler represents by itself the way of input data stream processing.
`Consumer<File>` `fileHandler(UUID nodeId, TransmissionMeta initMeta)` File handler represents by itself the way of input data stream processing.
`String` `filePath(UUID nodeId, TransmissionMeta fileMeta)` Absolute path of a file to receive remote transmission data into.
`void` `onEnd(UUID rmtNodeId)` The end of the handled transmission.
`void` `onException(UUID nodeId, Throwable err)` The `TransmissionCancelledException` will be received by exception handler if the local transmission ends by the user interruption request.

### Method Detail

#### chunkHandler

    Consumer<ByteBuffer> chunkHandler(UUID nodeId,
                                      TransmissionMeta initMeta)

Chunk handler represents by itself the way of input data stream processing. It accepts within each chunk a `ByteBuffer` with data from input for further processing. Activated when the `TransmissionPolicy.CHUNK` policy sent.

The `TransmissionCancelledException` can be thrown to gracefully interrupt the local transmission and the node-senders transmission session.

Parameters:
  `nodeId` - Remote node id from which request has been received.
  `initMeta` - Initial handler meta info.
Returns:
  Instance of chunk handler to process incoming data by chunks.

#### filePath

    String filePath(UUID nodeId,
                    TransmissionMeta fileMeta)

Absolute path of a file to receive remote transmission data into. The `TransmissionCancelledException` can be thrown if it is necessary to gracefully interrupt current transmission session on the node-sender.

Parameters:
  `nodeId` - Remote node id from which request has been received.
  `fileMeta` - File meta info.
Returns:
  Absolute pathname denoting a file.

#### fileHandler

    Consumer<File> fileHandler(UUID nodeId,
                               TransmissionMeta initMeta)

File handler represents by itself the way of input data stream processing. All the data will be processed under the hood using zero-copy transferring algorithm and only start file processing and the end of processing will be provided. Activated when the `TransmissionPolicy.FILE` policy sent.

The `TransmissionCancelledException` can be thrown to gracefully interrupt the local transmission and the node-senders transmission session.

Parameters:
  `nodeId` - Remote node id from which request has been received.
  `initMeta` - Initial handler meta info.
Returns:
  Instance of read handler to process incoming data like the `FileChannel` manner.

#### onException

    void onException(UUID nodeId,
                     Throwable err)

The `TransmissionCancelledException` will be received by exception handler if the local transmission ends by the user interruption request.

Parameters:
  `nodeId` - Remote node id on which the error occurred.
  `err` - The error of fail handling process.

#### onEnd

    void onEnd(UUID rmtNodeId)

The end of the handled transmission. This means that all resources associated with previously opened session is freed and can be reused. Generally, it means that transmission topic from now can safely accept new files.

Parameters:
  `rmtNodeId` - Remote node id from which the source request comes from.

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.13.0
Release Date | : April 20 2022