Support "default" for tcpNoDelay and tcpKeepAlive
Allow to set the value default to network.tcp.no_delay and network.tcp.keep_alive so they won't be set at all, since on solaris, setting tcpNoDelay can actually cause failure relates to #7115
This commit is contained in:
parent
5ccc7beaf4
commit
95762e8126
|
@ -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.
|
||||
|
|
|
@ -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<HttpSer
|
|||
|
||||
private final String publishHost;
|
||||
|
||||
private final Boolean tcpNoDelay;
|
||||
|
||||
private final Boolean tcpKeepAlive;
|
||||
|
||||
private final String tcpNoDelay;
|
||||
private final String tcpKeepAlive;
|
||||
private final Boolean reuseAddress;
|
||||
|
||||
private final ByteSizeValue tcpSendBufferSize;
|
||||
|
@ -135,8 +134,8 @@ public class NettyHttpServerTransport extends AbstractLifecycleComponent<HttpSer
|
|||
this.port = componentSettings.get("port", settings.get("http.port", "9200-9300"));
|
||||
this.bindHost = componentSettings.get("bind_host", settings.get("http.bind_host", settings.get("http.host")));
|
||||
this.publishHost = componentSettings.get("publish_host", settings.get("http.publish_host", settings.get("http.host")));
|
||||
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));
|
||||
|
@ -197,11 +196,11 @@ public class NettyHttpServerTransport extends AbstractLifecycleComponent<HttpSer
|
|||
|
||||
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());
|
||||
|
|
|
@ -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<Transport> 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<Transport> 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<Transport> 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<Transport> 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());
|
||||
|
|
Loading…
Reference in New Issue