Search in sources :

Example 1 with ChannelOptions

use of com.hazelcast.internal.networking.ChannelOptions in project hazelcast by hazelcast.

the class IOUtil method setChannelOptions.

/**
 * Sets configured channel options on given {@link Channel}.
 *
 * @param channel the {@link Channel} on which options will be set
 * @param config  the endpoint configuration
 */
public static void setChannelOptions(Channel channel, EndpointConfig config) {
    ChannelOptions options = channel.options();
    options.setOption(DIRECT_BUF, config.isSocketBufferDirect()).setOption(TCP_NODELAY, config.isSocketTcpNoDelay()).setOption(SO_KEEPALIVE, config.isSocketKeepAlive()).setOption(SO_SNDBUF, config.getSocketSendBufferSizeKb() * KILO_BYTE).setOption(SO_RCVBUF, config.getSocketRcvBufferSizeKb() * KILO_BYTE).setOption(SO_LINGER, config.getSocketLingerSeconds());
}
Also used : ChannelOptions(com.hazelcast.internal.networking.ChannelOptions)

Example 2 with ChannelOptions

use of com.hazelcast.internal.networking.ChannelOptions in project hazelcast by hazelcast.

the class UnifiedChannelInitializer method initChannel.

@Override
public void initChannel(Channel channel) {
    ChannelOptions config = channel.options();
    config.setOption(DIRECT_BUF, props.getBoolean(SOCKET_BUFFER_DIRECT)).setOption(TCP_NODELAY, props.getBoolean(SOCKET_NO_DELAY)).setOption(SO_KEEPALIVE, props.getBoolean(SOCKET_KEEP_ALIVE)).setOption(SO_SNDBUF, props.getInteger(SOCKET_SEND_BUFFER_SIZE) * KILO_BYTE).setOption(SO_RCVBUF, props.getInteger(SOCKET_RECEIVE_BUFFER_SIZE) * KILO_BYTE).setOption(SO_LINGER, props.getSeconds(SOCKET_LINGER_SECONDS));
    UnifiedProtocolEncoder encoder = new UnifiedProtocolEncoder(serverContext);
    UnifiedProtocolDecoder decoder = new UnifiedProtocolDecoder(serverContext, encoder);
    channel.outboundPipeline().addLast(encoder);
    channel.inboundPipeline().addLast(decoder);
}
Also used : ChannelOptions(com.hazelcast.internal.networking.ChannelOptions)

Example 3 with ChannelOptions

use of com.hazelcast.internal.networking.ChannelOptions 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)3 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