From 032184bd5eb63b9f5b4d2539b6d4e06e4716bfb0 Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Tue, 7 Oct 2014 08:56:38 -0700 Subject: [PATCH] Fix missed places referencing optimize force flag from removal in commit 1ae8195. --- .../optimize/OptimizeRequestBuilder.java | 9 ----- .../indices/optimize/RestOptimizeAction.java | 1 - .../InternalEngineIntegrationTest.java | 34 ------------------- .../SharedClusterSnapshotRestoreTests.java | 2 +- .../SnapshotBackwardsCompatibilityTest.java | 2 +- .../test/ElasticsearchIntegrationTest.java | 2 +- 6 files changed, 3 insertions(+), 47 deletions(-) diff --git a/src/main/java/org/elasticsearch/action/admin/indices/optimize/OptimizeRequestBuilder.java b/src/main/java/org/elasticsearch/action/admin/indices/optimize/OptimizeRequestBuilder.java index a294d4cbac4..fe0fbc91ae1 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/optimize/OptimizeRequestBuilder.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/optimize/OptimizeRequestBuilder.java @@ -73,15 +73,6 @@ public class OptimizeRequestBuilder extends BroadcastOperationRequestBuilderfalse. - */ - public OptimizeRequestBuilder setForce(boolean force) { - request.force(force); - return this; - } - @Override protected void doExecute(ActionListener listener) { client.optimize(request, listener); diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/optimize/RestOptimizeAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/optimize/RestOptimizeAction.java index 611f59fc4c5..6077f8ec33a 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/optimize/RestOptimizeAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/optimize/RestOptimizeAction.java @@ -59,7 +59,6 @@ public class RestOptimizeAction extends BaseRestHandler { optimizeRequest.maxNumSegments(request.paramAsInt("max_num_segments", optimizeRequest.maxNumSegments())); optimizeRequest.onlyExpungeDeletes(request.paramAsBoolean("only_expunge_deletes", optimizeRequest.onlyExpungeDeletes())); optimizeRequest.flush(request.paramAsBoolean("flush", optimizeRequest.flush())); - optimizeRequest.force(request.paramAsBoolean("force", optimizeRequest.force())); client.admin().indices().optimize(optimizeRequest, new RestBuilderListener(channel) { @Override public RestResponse buildResponse(OptimizeResponse response, XContentBuilder builder) throws Exception { diff --git a/src/test/java/org/elasticsearch/index/engine/internal/InternalEngineIntegrationTest.java b/src/test/java/org/elasticsearch/index/engine/internal/InternalEngineIntegrationTest.java index aac32de55d2..958a1d12e57 100644 --- a/src/test/java/org/elasticsearch/index/engine/internal/InternalEngineIntegrationTest.java +++ b/src/test/java/org/elasticsearch/index/engine/internal/InternalEngineIntegrationTest.java @@ -137,40 +137,6 @@ public class InternalEngineIntegrationTest extends ElasticsearchIntegrationTest assertTotalCompoundSegments(2, 3, "test"); } - public void testForceOptimize() throws ExecutionException, InterruptedException { - boolean compound = randomBoolean(); - assertAcked(client().admin().indices().prepareCreate("test").setSettings(ImmutableSettings.builder() - .put("number_of_replicas", 0) - .put("number_of_shards", 1) - // this is important otherwise the MP will still trigger a merge even if there is only one segment - .put(InternalEngine.INDEX_COMPOUND_ON_FLUSH, compound) - .put(AbstractMergePolicyProvider.INDEX_COMPOUND_FORMAT, compound) - )); - final int numDocs = randomIntBetween(10, 100); - IndexRequestBuilder[] builders = new IndexRequestBuilder[numDocs]; - for (int i = 0; i < builders.length; i++) { - builders[i] = client().prepareIndex("test", "type").setSource("field", "value"); - } - indexRandom(true, builders); - ensureGreen(); - flushAndRefresh(); - client().admin().indices().prepareOptimize("test").setMaxNumSegments(1).setWaitForMerge(true).get(); - IndexSegments firstSegments = client().admin().indices().prepareSegments("test").get().getIndices().get("test"); - client().admin().indices().prepareOptimize("test").setMaxNumSegments(1).setWaitForMerge(true).get(); - IndexSegments secondsSegments = client().admin().indices().prepareSegments("test").get().getIndices().get("test"); - - assertThat(segments(firstSegments), Matchers.containsInAnyOrder(segments(secondsSegments).toArray())); - assertThat(segments(firstSegments).size(), Matchers.equalTo(1)); - assertThat(segments(secondsSegments), Matchers.containsInAnyOrder(segments(firstSegments).toArray())); - assertThat(segments(secondsSegments).size(), Matchers.equalTo(1)); - client().admin().indices().prepareOptimize("test").setMaxNumSegments(1).setWaitForMerge(true).setForce(true).get(); - IndexSegments thirdSegments = client().admin().indices().prepareSegments("test").get().getIndices().get("test"); - assertThat(segments(firstSegments).size(), Matchers.equalTo(1)); - assertThat(segments(thirdSegments).size(), Matchers.equalTo(1)); - assertThat(segments(firstSegments), Matchers.not(Matchers.containsInAnyOrder(segments(thirdSegments).toArray()))); - assertThat(segments(thirdSegments), Matchers.not(Matchers.containsInAnyOrder(segments(firstSegments).toArray()))); - } - private void assertTotalCompoundSegments(int i, int t, String index) { IndicesSegmentResponse indicesSegmentResponse = client().admin().indices().prepareSegments(index).get(); IndexSegments indexSegments = indicesSegmentResponse.getIndices().get(index); diff --git a/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreTests.java b/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreTests.java index f3cf56f51b4..d72e8e78b8d 100644 --- a/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreTests.java +++ b/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreTests.java @@ -1358,7 +1358,7 @@ public class SharedClusterSnapshotRestoreTests extends AbstractSnapshotTests { } indexRandom(true, builders); flushAndRefresh(); - assertNoFailures(client().admin().indices().prepareOptimize("test").setForce(true).setFlush(true).setWaitForMerge(true).setMaxNumSegments(1).get()); + assertNoFailures(client().admin().indices().prepareOptimize("test").setFlush(true).setWaitForMerge(true).setMaxNumSegments(1).get()); CreateSnapshotResponse createSnapshotResponseFirst = client.admin().cluster().prepareCreateSnapshot("test-repo", "test").setWaitForCompletion(true).setIndices("test").get(); assertThat(createSnapshotResponseFirst.getSnapshotInfo().successfulShards(), greaterThan(0)); diff --git a/src/test/java/org/elasticsearch/snapshots/SnapshotBackwardsCompatibilityTest.java b/src/test/java/org/elasticsearch/snapshots/SnapshotBackwardsCompatibilityTest.java index 5a5e5bb3df4..11298b188e5 100644 --- a/src/test/java/org/elasticsearch/snapshots/SnapshotBackwardsCompatibilityTest.java +++ b/src/test/java/org/elasticsearch/snapshots/SnapshotBackwardsCompatibilityTest.java @@ -185,7 +185,7 @@ public class SnapshotBackwardsCompatibilityTest extends ElasticsearchBackwardsCo } indexRandom(true, builders); flushAndRefresh(); - assertNoFailures(client().admin().indices().prepareOptimize("test").setForce(true).setFlush(true).setWaitForMerge(true).setMaxNumSegments(1).get()); + assertNoFailures(client().admin().indices().prepareOptimize("test").setFlush(true).setWaitForMerge(true).setMaxNumSegments(1).get()); CreateSnapshotResponse createSnapshotResponseFirst = client.admin().cluster().prepareCreateSnapshot("test-repo", "test").setWaitForCompletion(true).setIndices("test").get(); assertThat(createSnapshotResponseFirst.getSnapshotInfo().successfulShards(), greaterThan(0)); diff --git a/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java b/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java index c3c6f84648e..08b92aaa27f 100644 --- a/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java +++ b/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java @@ -1194,7 +1194,7 @@ public abstract class ElasticsearchIntegrationTest extends ElasticsearchTestCase */ protected OptimizeResponse optimize() { waitForRelocation(); - OptimizeResponse actionGet = client().admin().indices().prepareOptimize().setForce(randomBoolean()).execute().actionGet(); + OptimizeResponse actionGet = client().admin().indices().prepareOptimize().execute().actionGet(); assertNoFailures(actionGet); return actionGet; }