diff --git a/docs/reference/modules/network.asciidoc b/docs/reference/modules/network.asciidoc index 83b71345cd4..a00dffd3ce6 100644 --- a/docs/reference/modules/network.asciidoc +++ b/docs/reference/modules/network.asciidoc @@ -72,10 +72,10 @@ share the following allowed settings: |======================================================================= |Setting |Description |`network.tcp.no_delay` |Enable or disable tcp no delay setting. -Defaults to `true`. +Defaults to `true`. coming[1.4,Can be set to `default` to not be set at all.] -|`network.tcp.keep_alive` |Enable or disable tcp keep alive. By default -not explicitly set. +|`network.tcp.keep_alive` |Enable or disable tcp keep alive. Defaults +to `true`. coming[1.4,Can be set to `default` to not be set at all]. |`network.tcp.reuse_address` |Should an address be reused or not. Defaults to `true` on non-windows machines. diff --git a/src/main/java/org/elasticsearch/http/netty/NettyHttpServerTransport.java b/src/main/java/org/elasticsearch/http/netty/NettyHttpServerTransport.java index 9a5f079b3c1..474cf2274e9 100644 --- a/src/main/java/org/elasticsearch/http/netty/NettyHttpServerTransport.java +++ b/src/main/java/org/elasticsearch/http/netty/NettyHttpServerTransport.java @@ -20,6 +20,7 @@ package org.elasticsearch.http.netty; import org.elasticsearch.ElasticsearchException; +import org.elasticsearch.common.Booleans; import org.elasticsearch.common.component.AbstractLifecycleComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.netty.NettyUtils; @@ -88,10 +89,8 @@ public class NettyHttpServerTransport extends AbstractLifecycleComponent 0) { serverBootstrap.setOption("child.sendBufferSize", tcpSendBufferSize.bytes()); diff --git a/src/main/java/org/elasticsearch/transport/netty/NettyTransport.java b/src/main/java/org/elasticsearch/transport/netty/NettyTransport.java index 6ec63ece023..b0cb6cc70df 100644 --- a/src/main/java/org/elasticsearch/transport/netty/NettyTransport.java +++ b/src/main/java/org/elasticsearch/transport/netty/NettyTransport.java @@ -23,6 +23,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import org.elasticsearch.*; import org.elasticsearch.cluster.node.DiscoveryNode; +import org.elasticsearch.common.Booleans; import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.ReleasableBytesReference; import org.elasticsearch.common.component.AbstractLifecycleComponent; @@ -128,11 +129,8 @@ public class NettyTransport extends AbstractLifecycleComponent implem final boolean compress; final TimeValue connectTimeout; - - final Boolean tcpNoDelay; - - final Boolean tcpKeepAlive; - + final String tcpNoDelay; + final String tcpKeepAlive; final Boolean reuseAddress; final ByteSizeValue tcpSendBufferSize; @@ -196,8 +194,8 @@ public class NettyTransport extends AbstractLifecycleComponent implem this.publishPort = componentSettings.getAsInt("publish_port", settings.getAsInt("transport.publish_port", 0)); this.compress = settings.getAsBoolean(TransportSettings.TRANSPORT_TCP_COMPRESS, false); this.connectTimeout = componentSettings.getAsTime("connect_timeout", settings.getAsTime("transport.tcp.connect_timeout", settings.getAsTime(TCP_CONNECT_TIMEOUT, TCP_DEFAULT_CONNECT_TIMEOUT))); - this.tcpNoDelay = componentSettings.getAsBoolean("tcp_no_delay", settings.getAsBoolean(TCP_NO_DELAY, true)); - this.tcpKeepAlive = componentSettings.getAsBoolean("tcp_keep_alive", settings.getAsBoolean(TCP_KEEP_ALIVE, true)); + this.tcpNoDelay = componentSettings.get("tcp_no_delay", settings.get(TCP_NO_DELAY, "true")); + this.tcpKeepAlive = componentSettings.get("tcp_keep_alive", settings.get(TCP_KEEP_ALIVE, "true")); this.reuseAddress = componentSettings.getAsBoolean("reuse_address", settings.getAsBoolean(TCP_REUSE_ADDRESS, NetworkUtils.defaultReuseAddress())); this.tcpSendBufferSize = componentSettings.getAsBytesSize("tcp_send_buffer_size", settings.getAsBytesSize(TCP_SEND_BUFFER_SIZE, TCP_DEFAULT_SEND_BUFFER_SIZE)); this.tcpReceiveBufferSize = componentSettings.getAsBytesSize("tcp_receive_buffer_size", settings.getAsBytesSize(TCP_RECEIVE_BUFFER_SIZE, TCP_DEFAULT_RECEIVE_BUFFER_SIZE)); @@ -271,11 +269,11 @@ public class NettyTransport extends AbstractLifecycleComponent implem } clientBootstrap.setPipelineFactory(configureClientChannelPipelineFactory()); clientBootstrap.setOption("connectTimeoutMillis", connectTimeout.millis()); - if (tcpNoDelay != null) { - clientBootstrap.setOption("tcpNoDelay", tcpNoDelay); + if (!"default".equals(tcpNoDelay)) { + clientBootstrap.setOption("tcpNoDelay", Booleans.parseBoolean(tcpNoDelay, null)); } - if (tcpKeepAlive != null) { - clientBootstrap.setOption("keepAlive", tcpKeepAlive); + if (!"default".equals(tcpKeepAlive)) { + clientBootstrap.setOption("keepAlive", Booleans.parseBoolean(tcpKeepAlive, null)); } if (tcpSendBufferSize != null && tcpSendBufferSize.bytes() > 0) { clientBootstrap.setOption("sendBufferSize", tcpSendBufferSize.bytes()); @@ -306,11 +304,11 @@ public class NettyTransport extends AbstractLifecycleComponent implem workerCount)); } serverBootstrap.setPipelineFactory(configureServerChannelPipelineFactory()); - if (tcpNoDelay != null) { - serverBootstrap.setOption("child.tcpNoDelay", tcpNoDelay); + if (!"default".equals(tcpNoDelay)) { + serverBootstrap.setOption("child.tcpNoDelay", Booleans.parseBoolean(tcpNoDelay, null)); } - if (tcpKeepAlive != null) { - serverBootstrap.setOption("child.keepAlive", tcpKeepAlive); + if (!"default".equals(tcpKeepAlive)) { + serverBootstrap.setOption("child.keepAlive", Booleans.parseBoolean(tcpKeepAlive, null)); } if (tcpSendBufferSize != null && tcpSendBufferSize.bytes() > 0) { serverBootstrap.setOption("child.sendBufferSize", tcpSendBufferSize.bytes());