Search in sources :

Example 1 with RestApiTextDecoder

use of com.hazelcast.internal.nio.ascii.RestApiTextDecoder 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)

Aggregations

ChannelOptions (com.hazelcast.internal.networking.ChannelOptions)1 MemcacheTextDecoder (com.hazelcast.internal.nio.ascii.MemcacheTextDecoder)1 RestApiTextDecoder (com.hazelcast.internal.nio.ascii.RestApiTextDecoder)1 TextDecoder (com.hazelcast.internal.nio.ascii.TextDecoder)1 TextEncoder (com.hazelcast.internal.nio.ascii.TextEncoder)1 ServerConnection (com.hazelcast.internal.server.ServerConnection)1