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());
}
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);
}
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);
}
Aggregations