public interface ChannelInboundHandler
ChannelInboundHandler
provides control when data is received and needs to be processed. For example data
has received on the socket and needs to be decoded into a Packet.
ChannelInboundHandler
are not expected to be thread-safe; each channel will gets its own instance(s).
A ChannelInboundHandler
is constructed through a ChannelInitializer
.
MemberChannelInboundHandler
that reads out any Packet from the decrypted ByteBuffer. Using this
approach encryption can easily be added to any type of communication, not only member 2 member communication.
Currently security is added by using a Channel
, but this is not needed if the handlers form a pipeline.
Netty follows a similar approach with pipelining and adding encryption.
There is no explicit support for setting up a 'pipeline' of ChannelInboundHandler/WriterHandlers but t can easily be realized
by setting up the chain and let a handler explicitly forward to the next. Since it isn't a common practice for the handler
so far, isn't needed to add additional complexity to the system; just set up a chain manually.
pseudo code:
public class DecryptingReadHandler implements ChannelInboundHandler { private final ChannelInboundHandler next; public DecryptingReadHandler(ChannelInboundHandler next) { this.next = next; } public void onRead(ByteBuffer src) { decrypt(src, decryptedSrc); next.onRead(decryptedSrc) } }The
next
ChannelInboundHandler is the next item in the pipeline.
For encryption is similar approach can be followed where the DecryptingWriteHandler is the last ChannelOutboundHandler in
the pipeline.Modifier and Type | Method and Description |
---|---|
void |
onRead(ByteBuffer src)
A callback to indicate that data is available in the src ByteBuffer to be processed.
|
void onRead(ByteBuffer src) throws Exception
src
- the ByteBuffer containing the data to read. The ByteBuffer is already in reading mode and when completed,
should not be converted to write-mode using clear/compact.Exception
- if something fails while reading data from the ByteBuffer or processing the data (e.g. when a Packet
fails to get processed). When an exception is thrown, the ChannelErrorHandler
is called.Copyright © 2018 Hazelcast, Inc.. All Rights Reserved.