diff --git a/src/main/java/org/elasticsearch/transport/Transport.java b/src/main/java/org/elasticsearch/transport/Transport.java index 741a34cf2b1..e377252d853 100644 --- a/src/main/java/org/elasticsearch/transport/Transport.java +++ b/src/main/java/org/elasticsearch/transport/Transport.java @@ -31,6 +31,10 @@ import java.io.IOException; */ public interface Transport extends LifecycleComponent { + public static class TransportSettings { + public static final String TRANSPORT_TCP_COMPRESS = "transport.tcp.compress"; + } + void transportServiceAdapter(TransportServiceAdapter service); /** diff --git a/src/main/java/org/elasticsearch/transport/netty/NettyTransport.java b/src/main/java/org/elasticsearch/transport/netty/NettyTransport.java index 56aa1044a94..95e8e534a0f 100644 --- a/src/main/java/org/elasticsearch/transport/netty/NettyTransport.java +++ b/src/main/java/org/elasticsearch/transport/netty/NettyTransport.java @@ -179,7 +179,7 @@ public class NettyTransport extends AbstractLifecycleComponent implem this.port = componentSettings.get("port", settings.get("transport.tcp.port", "9300-9400")); this.bindHost = componentSettings.get("bind_host", settings.get("transport.bind_host", settings.get("transport.host"))); this.publishHost = componentSettings.get("publish_host", settings.get("transport.publish_host", settings.get("transport.host"))); - this.compress = settings.getAsBoolean("transport.tcp.compress", false); + 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)); diff --git a/src/test/java/org/elasticsearch/test/TestCluster.java b/src/test/java/org/elasticsearch/test/TestCluster.java index 101a18fbd49..4803da08369 100644 --- a/src/test/java/org/elasticsearch/test/TestCluster.java +++ b/src/test/java/org/elasticsearch/test/TestCluster.java @@ -48,6 +48,7 @@ import org.elasticsearch.node.internal.InternalNode; import org.elasticsearch.test.engine.MockEngineModule; import org.elasticsearch.test.store.MockFSIndexStoreModule; import org.elasticsearch.test.transport.AssertingLocalTransportModule; +import org.elasticsearch.transport.Transport; import org.elasticsearch.transport.TransportModule; import org.elasticsearch.transport.TransportService; import org.junit.Assert; @@ -137,6 +138,8 @@ public final class TestCluster implements Iterable { .put("gateway.type", "none"); if (isLocalTransportConfigured()) { builder.put(TransportModule.TRANSPORT_TYPE_KEY, AssertingLocalTransportModule.class.getName()); + } else { + builder.put(Transport.TransportSettings.TRANSPORT_TCP_COMPRESS, random.nextInt(10) == 0); } this.defaultSettings = builder.build(); this.nodeSettingsSource = nodeSettingsSource;