diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoverySource.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoverySource.java index 9fe026a7fc0..d1356624014 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoverySource.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoverySource.java @@ -74,6 +74,8 @@ public class RecoverySource extends AbstractComponent { private final ByteSizeValue fileChunkSize; + private final boolean compress; + @Inject public RecoverySource(Settings settings, ThreadPool threadPool, TransportService transportService, IndicesService indicesService, RecoveryThrottler recoveryThrottler) { super(settings); @@ -83,6 +85,7 @@ public class RecoverySource extends AbstractComponent { this.recoveryThrottler = recoveryThrottler; this.fileChunkSize = componentSettings.getAsBytesSize("file_chunk_size", new ByteSizeValue(100, ByteSizeUnit.KB)); + this.compress = componentSettings.getAsBoolean("compress", true); transportService.registerHandler(Actions.START_RECOVERY, new StartRecoveryTransportRequestHandler()); } @@ -165,7 +168,7 @@ public class RecoverySource extends AbstractComponent { long position = indexInput.getFilePointer(); indexInput.readBytes(buf, 0, toRead, false); transportService.submitRequest(request.targetNode(), RecoveryTarget.Actions.FILE_CHUNK, new RecoveryFileChunkRequest(request.shardId(), name, position, len, buf, toRead), - TransportRequestOptions.options().withCompress(), VoidTransportResponseHandler.INSTANCE).txGet(); + TransportRequestOptions.options().withCompress(compress), VoidTransportResponseHandler.INSTANCE).txGet(); readCount += toRead; } indexInput.close(); diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/transport/TransportRequestOptions.java b/modules/elasticsearch/src/main/java/org/elasticsearch/transport/TransportRequestOptions.java index 4ca6c380a74..a21813bdf21 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/transport/TransportRequestOptions.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/transport/TransportRequestOptions.java @@ -45,8 +45,8 @@ public class TransportRequestOptions { return this; } - public TransportRequestOptions withCompress() { - this.compress = true; + public TransportRequestOptions withCompress(boolean compress) { + this.compress = compress; return this; } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/transport/netty/NettyTransport.java b/modules/elasticsearch/src/main/java/org/elasticsearch/transport/netty/NettyTransport.java index 69746c70128..0ddc47828f8 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/transport/netty/NettyTransport.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/transport/netty/NettyTransport.java @@ -385,7 +385,7 @@ public class NettyTransport extends AbstractLifecycleComponent implem Channel targetChannel = nodeChannel(node); if (compress) { - options.withCompress(); + options.withCompress(true); } byte[] data = TransportStreams.buildRequest(requestId, action, message, options); diff --git a/modules/elasticsearch/src/test/java/org/elasticsearch/transport/AbstractSimpleTransportTests.java b/modules/elasticsearch/src/test/java/org/elasticsearch/transport/AbstractSimpleTransportTests.java index e9617b31e66..68e147c7acd 100644 --- a/modules/elasticsearch/src/test/java/org/elasticsearch/transport/AbstractSimpleTransportTests.java +++ b/modules/elasticsearch/src/test/java/org/elasticsearch/transport/AbstractSimpleTransportTests.java @@ -136,7 +136,7 @@ public abstract class AbstractSimpleTransportTests { }); TransportFuture res = serviceB.submitRequest(serviceANode, "sayHello", - new StringMessage("moshe"), TransportRequestOptions.options().withCompress(), new BaseTransportResponseHandler() { + new StringMessage("moshe"), TransportRequestOptions.options().withCompress(true), new BaseTransportResponseHandler() { @Override public StringMessage newInstance() { return new StringMessage(); }