Search in sources :

Example 16 with ServerConnection

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);
}
Also used : SingleProtocolEncoder(com.hazelcast.internal.server.tcp.SingleProtocolEncoder) InboundHandler(com.hazelcast.internal.networking.InboundHandler) TcpServerConnection(com.hazelcast.internal.server.tcp.TcpServerConnection) ServerConnection(com.hazelcast.internal.server.ServerConnection) TcpServerConnection(com.hazelcast.internal.server.tcp.TcpServerConnection) TextHandshakeDecoder(com.hazelcast.internal.server.tcp.TextHandshakeDecoder)

Example 17 with ServerConnection

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);
}
Also used : OutboundHandler(com.hazelcast.internal.networking.OutboundHandler) InboundHandler(com.hazelcast.internal.networking.InboundHandler) ServerConnection(com.hazelcast.internal.server.ServerConnection)

Example 18 with ServerConnection

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);
}
Also used : ClientMessageDecoder(com.hazelcast.client.impl.protocol.util.ClientMessageDecoder) ServerConnection(com.hazelcast.internal.server.ServerConnection) ClientMessageEncoder(com.hazelcast.client.impl.protocol.util.ClientMessageEncoder)

Example 19 with ServerConnection

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);
}
Also used : MemcacheTextDecoder(com.hazelcast.internal.nio.ascii.MemcacheTextDecoder) TextEncoder(com.hazelcast.internal.nio.ascii.TextEncoder) ServerConnection(com.hazelcast.internal.server.ServerConnection) RestApiTextDecoder(com.hazelcast.internal.nio.ascii.RestApiTextDecoder) ChannelOptions(com.hazelcast.internal.networking.ChannelOptions) RestApiTextDecoder(com.hazelcast.internal.nio.ascii.RestApiTextDecoder) TextDecoder(com.hazelcast.internal.nio.ascii.TextDecoder) MemcacheTextDecoder(com.hazelcast.internal.nio.ascii.MemcacheTextDecoder)

Example 20 with ServerConnection

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));
}
Also used : ServerConnection(com.hazelcast.internal.server.ServerConnection)

Aggregations

ServerConnection (com.hazelcast.internal.server.ServerConnection)22 Address (com.hazelcast.cluster.Address)6 ClientMessageDecoder (com.hazelcast.client.impl.protocol.util.ClientMessageDecoder)2 InboundHandler (com.hazelcast.internal.networking.InboundHandler)2 OutboundHandler (com.hazelcast.internal.networking.OutboundHandler)2 ServerConnectionManager (com.hazelcast.internal.server.ServerConnectionManager)2 TcpServerConnection (com.hazelcast.internal.server.tcp.TcpServerConnection)2 Operation (com.hazelcast.spi.impl.operationservice.Operation)2 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 UUID (java.util.UUID)2 Test (org.junit.Test)2 ClientEndpointImpl (com.hazelcast.client.impl.ClientEndpointImpl)1 ClientMessageEncoder (com.hazelcast.client.impl.protocol.util.ClientMessageEncoder)1 ClusterState (com.hazelcast.cluster.ClusterState)1 MemberImpl (com.hazelcast.cluster.impl.MemberImpl)1 EndpointConfig (com.hazelcast.config.EndpointConfig)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 HazelcastInstanceNotActiveException (com.hazelcast.core.HazelcastInstanceNotActiveException)1 CPGroup (com.hazelcast.cp.CPGroup)1