use of com.hazelcast.internal.server.ServerConnection in project hazelcast by hazelcast.
the class TextChannelInitializer method initChannel.
@Override
public void initChannel(Channel channel) {
ServerConnection connection = (TcpServerConnection) channel.attributeMap().get(ServerConnection.class);
SingleProtocolEncoder encoder = new SingleProtocolEncoder(new TextEncoder(connection));
InboundHandler decoder = rest ? new RestApiTextDecoder(connection, (TextEncoder) encoder.getFirstOutboundHandler(), true) : new MemcacheTextDecoder(connection, (TextEncoder) encoder.getFirstOutboundHandler(), true);
TextHandshakeDecoder handshaker = new TextHandshakeDecoder(rest ? ProtocolType.REST : ProtocolType.MEMCACHE, decoder, encoder);
channel.outboundPipeline().addLast(encoder);
channel.inboundPipeline().addLast(handshaker);
}
use of com.hazelcast.internal.server.ServerConnection in project hazelcast by hazelcast.
the class MemberChannelInitializer method initChannel.
@Override
public void initChannel(Channel channel) {
ServerConnection connection = (TcpServerConnection) channel.attributeMap().get(ServerConnection.class);
OutboundHandler[] outboundHandlers = serverContext.createOutboundHandlers(EndpointQualifier.MEMBER, connection);
InboundHandler[] inboundHandlers = serverContext.createInboundHandlers(EndpointQualifier.MEMBER, connection);
SingleProtocolEncoder protocolEncoder = new SingleProtocolEncoder(new MemberProtocolEncoder(outboundHandlers));
SingleProtocolDecoder protocolDecoder = new SingleProtocolDecoder(ProtocolType.MEMBER, inboundHandlers, protocolEncoder, true);
channel.outboundPipeline().addLast(protocolEncoder);
channel.inboundPipeline().addLast(protocolDecoder);
}
use of com.hazelcast.internal.server.ServerConnection in project hazelcast by hazelcast.
the class ClientChannelInitializer method initChannel.
@Override
public void initChannel(Channel channel) {
ServerConnection connection = (TcpServerConnection) channel.attributeMap().get(ServerConnection.class);
SingleProtocolEncoder protocolEncoder = new SingleProtocolEncoder(new ClientMessageEncoder());
SingleProtocolDecoder protocolDecoder = new SingleProtocolDecoder(CLIENT, new ClientMessageDecoder(connection, serverContext.getClientEngine(), serverContext.properties()), protocolEncoder);
channel.outboundPipeline().addLast(protocolEncoder);
channel.inboundPipeline().addLast(protocolDecoder);
}
use of com.hazelcast.internal.server.ServerConnection in project hazelcast by hazelcast.
the class UnifiedProtocolDecoder method initChannelForText.
private void initChannelForText(String protocol, boolean restApi) {
protocolEncoder.signalEncoderCanReplace();
ChannelOptions config = channel.options();
config.setOption(SO_RCVBUF, clientRcvBuf());
ServerConnection connection = (TcpServerConnection) channel.attributeMap().get(ServerConnection.class);
TextEncoder encoder = new TextEncoder(connection);
channel.attributeMap().put(TextEncoder.TEXT_ENCODER, encoder);
TextDecoder decoder = restApi ? new RestApiTextDecoder(connection, encoder, false) : new MemcacheTextDecoder(connection, encoder, false);
decoder.src(newByteBuffer(config.getOption(SO_RCVBUF), config.getOption(DIRECT_BUF)));
// we need to restore whatever is read
decoder.src().put(stringToBytes(protocol));
channel.inboundPipeline().replace(this, decoder);
}
use of com.hazelcast.internal.server.ServerConnection in project hazelcast by hazelcast.
the class UnifiedProtocolDecoder method initChannelForCluster.
private void initChannelForCluster() {
protocolEncoder.signalEncoderCanReplace();
channel.options().setOption(SO_SNDBUF, props.getInteger(SOCKET_RECEIVE_BUFFER_SIZE) * KILO_BYTE);
ServerConnection connection = (TcpServerConnection) channel.attributeMap().get(ServerConnection.class);
connection.setConnectionType(ConnectionType.MEMBER);
channel.inboundPipeline().replace(this, serverContext.createInboundHandlers(EndpointQualifier.MEMBER, connection));
}
Aggregations