Interface TransmissionHandler
-
public interface TransmissionHandlerClass 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 inGridIoManagerprior 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
TransmissionPolicyis used for such purpose. IfTransmissionPolicy.FILEtype is received by remote node the #fileHandler() will be picked up to process this file, the otherwise for theTransmissionPolicy.CHUNKthe #chunkHandler() will be picked up.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description 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.StringfilePath(UUID nodeId, TransmissionMeta fileMeta)Absolute path of a file to receive remote transmission data into.voidonEnd(UUID rmtNodeId)The end of the handled transmission.voidonException(UUID nodeId, Throwable err)TheTransmissionCancelledExceptionwill 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 aByteBufferwith data from input for further processing. Activated when theTransmissionPolicy.CHUNKpolicy sent.The
TransmissionCancelledExceptioncan 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. TheTransmissionCancelledExceptioncan 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 theTransmissionPolicy.FILEpolicy sent.The
TransmissionCancelledExceptioncan 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
FileChannelmanner.
-
onException
void onException(UUID nodeId, Throwable err)
TheTransmissionCancelledExceptionwill 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.
-
-