diff --git a/buildSrc/src/main/resources/checkstyle_suppressions.xml b/buildSrc/src/main/resources/checkstyle_suppressions.xml
index 7c5803e19c3e1..12f1d7b5a6e2c 100644
--- a/buildSrc/src/main/resources/checkstyle_suppressions.xml
+++ b/buildSrc/src/main/resources/checkstyle_suppressions.xml
@@ -681,6 +681,7 @@
+
@@ -799,7 +800,6 @@
-
@@ -1025,7 +1025,6 @@
-
diff --git a/core/src/main/java/org/elasticsearch/action/WriteConsistencyLevel.java b/core/src/main/java/org/elasticsearch/action/WriteConsistencyLevel.java
deleted file mode 100644
index 0813e85960f59..0000000000000
--- a/core/src/main/java/org/elasticsearch/action/WriteConsistencyLevel.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.elasticsearch.action;
-
-
-/**
- * Write Consistency Level control how many replicas should be active for a write operation to occur (a write operation
- * can be index, or delete).
- *
- *
- */
-public enum WriteConsistencyLevel {
- DEFAULT((byte) 0),
- ONE((byte) 1),
- QUORUM((byte) 2),
- ALL((byte) 3);
-
- private final byte id;
-
- WriteConsistencyLevel(byte id) {
- this.id = id;
- }
-
- public byte id() {
- return id;
- }
-
- public static WriteConsistencyLevel fromId(byte value) {
- if (value == 0) {
- return DEFAULT;
- } else if (value == 1) {
- return ONE;
- } else if (value == 2) {
- return QUORUM;
- } else if (value == 3) {
- return ALL;
- }
- throw new IllegalArgumentException("No write consistency match [" + value + "]");
- }
-
- public static WriteConsistencyLevel fromString(String value) {
- if (value.equals("default")) {
- return DEFAULT;
- } else if (value.equals("one")) {
- return ONE;
- } else if (value.equals("quorum")) {
- return QUORUM;
- } else if (value.equals("all")) {
- return ALL;
- }
- throw new IllegalArgumentException("No write consistency match [" + value + "]");
- }
-}
diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequest.java b/core/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequest.java
index 38401fef18126..17df06dbf4b84 100644
--- a/core/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequest.java
+++ b/core/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequest.java
@@ -466,6 +466,15 @@ public CreateIndexRequest waitForActiveShards(ActiveShardCount waitForActiveShar
return this;
}
+ /**
+ * A shortcut for {@link #waitForActiveShards(ActiveShardCount)} where the numerical
+ * shard count is passed in, instead of having to first call {@link ActiveShardCount#from(int)}
+ * to get the ActiveShardCount.
+ */
+ public CreateIndexRequest waitForActiveShards(final int waitForActiveShards) {
+ return waitForActiveShards(ActiveShardCount.from(waitForActiveShards));
+ }
+
@Override
public void readFrom(StreamInput in) throws IOException {
diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequestBuilder.java b/core/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequestBuilder.java
index 1c930b8951065..eaae4d53b73fd 100644
--- a/core/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequestBuilder.java
+++ b/core/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequestBuilder.java
@@ -269,4 +269,13 @@ public CreateIndexRequestBuilder setWaitForActiveShards(ActiveShardCount waitFor
request.waitForActiveShards(waitForActiveShards);
return this;
}
+
+ /**
+ * A shortcut for {@link #setWaitForActiveShards(ActiveShardCount)} where the numerical
+ * shard count is passed in, instead of having to first call {@link ActiveShardCount#from(int)}
+ * to get the ActiveShardCount.
+ */
+ public CreateIndexRequestBuilder setWaitForActiveShards(final int waitForActiveShards) {
+ return setWaitForActiveShards(ActiveShardCount.from(waitForActiveShards));
+ }
}
diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/flush/ShardFlushRequest.java b/core/src/main/java/org/elasticsearch/action/admin/indices/flush/ShardFlushRequest.java
index 3a9ec89db5da5..83eaf11ca3a9e 100644
--- a/core/src/main/java/org/elasticsearch/action/admin/indices/flush/ShardFlushRequest.java
+++ b/core/src/main/java/org/elasticsearch/action/admin/indices/flush/ShardFlushRequest.java
@@ -19,6 +19,7 @@
package org.elasticsearch.action.admin.indices.flush;
+import org.elasticsearch.action.support.ActiveShardCount;
import org.elasticsearch.action.support.replication.ReplicationRequest;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
@@ -33,6 +34,7 @@ public class ShardFlushRequest extends ReplicationRequest {
public ShardFlushRequest(FlushRequest request, ShardId shardId) {
super(shardId);
this.request = request;
+ this.waitForActiveShards = ActiveShardCount.NONE; // don't wait for any active shards before proceeding, by default
}
public ShardFlushRequest() {
diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/flush/TransportShardFlushAction.java b/core/src/main/java/org/elasticsearch/action/admin/indices/flush/TransportShardFlushAction.java
index 82fb6d70ca441..570307a717da2 100644
--- a/core/src/main/java/org/elasticsearch/action/admin/indices/flush/TransportShardFlushAction.java
+++ b/core/src/main/java/org/elasticsearch/action/admin/indices/flush/TransportShardFlushAction.java
@@ -69,11 +69,6 @@ protected ReplicaResult shardOperationOnReplica(ShardFlushRequest request) {
return new ReplicaResult();
}
- @Override
- protected boolean checkWriteConsistency() {
- return false;
- }
-
@Override
protected ClusterBlockLevel globalBlockLevel() {
return ClusterBlockLevel.METADATA_WRITE;
diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/refresh/TransportRefreshAction.java b/core/src/main/java/org/elasticsearch/action/admin/indices/refresh/TransportRefreshAction.java
index ac64e276778f6..9752e68517e15 100644
--- a/core/src/main/java/org/elasticsearch/action/admin/indices/refresh/TransportRefreshAction.java
+++ b/core/src/main/java/org/elasticsearch/action/admin/indices/refresh/TransportRefreshAction.java
@@ -21,6 +21,7 @@
import org.elasticsearch.action.ShardOperationFailedException;
import org.elasticsearch.action.support.ActionFilters;
+import org.elasticsearch.action.support.ActiveShardCount;
import org.elasticsearch.action.support.replication.BasicReplicationRequest;
import org.elasticsearch.action.support.replication.ReplicationResponse;
import org.elasticsearch.action.support.replication.TransportBroadcastReplicationAction;
@@ -54,7 +55,9 @@ protected ReplicationResponse newShardResponse() {
@Override
protected BasicReplicationRequest newShardRequest(RefreshRequest request, ShardId shardId) {
- return new BasicReplicationRequest(shardId);
+ BasicReplicationRequest replicationRequest = new BasicReplicationRequest(shardId);
+ replicationRequest.waitForActiveShards(ActiveShardCount.NONE);
+ return replicationRequest;
}
@Override
diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/refresh/TransportShardRefreshAction.java b/core/src/main/java/org/elasticsearch/action/admin/indices/refresh/TransportShardRefreshAction.java
index d7d0c289953a4..cf9f568195382 100644
--- a/core/src/main/java/org/elasticsearch/action/admin/indices/refresh/TransportShardRefreshAction.java
+++ b/core/src/main/java/org/elasticsearch/action/admin/indices/refresh/TransportShardRefreshAction.java
@@ -35,6 +35,7 @@
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
+
public class TransportShardRefreshAction
extends TransportReplicationAction {
@@ -70,11 +71,6 @@ protected ReplicaResult shardOperationOnReplica(BasicReplicationRequest request)
return new ReplicaResult();
}
- @Override
- protected boolean checkWriteConsistency() {
- return false;
- }
-
@Override
protected ClusterBlockLevel globalBlockLevel() {
return ClusterBlockLevel.METADATA_WRITE;
diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/rollover/RolloverRequest.java b/core/src/main/java/org/elasticsearch/action/admin/indices/rollover/RolloverRequest.java
index 481a375492a8c..854611658dfe5 100644
--- a/core/src/main/java/org/elasticsearch/action/admin/indices/rollover/RolloverRequest.java
+++ b/core/src/main/java/org/elasticsearch/action/admin/indices/rollover/RolloverRequest.java
@@ -225,4 +225,13 @@ public void setWaitForActiveShards(ActiveShardCount waitForActiveShards) {
this.createIndexRequest.waitForActiveShards(waitForActiveShards);
}
+ /**
+ * A shortcut for {@link #setWaitForActiveShards(ActiveShardCount)} where the numerical
+ * shard count is passed in, instead of having to first call {@link ActiveShardCount#from(int)}
+ * to get the ActiveShardCount.
+ */
+ public void setWaitForActiveShards(final int waitForActiveShards) {
+ setWaitForActiveShards(ActiveShardCount.from(waitForActiveShards));
+ }
+
}
diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/rollover/RolloverRequestBuilder.java b/core/src/main/java/org/elasticsearch/action/admin/indices/rollover/RolloverRequestBuilder.java
index edc7aaa92d6b9..35890d1d3a6fd 100644
--- a/core/src/main/java/org/elasticsearch/action/admin/indices/rollover/RolloverRequestBuilder.java
+++ b/core/src/main/java/org/elasticsearch/action/admin/indices/rollover/RolloverRequestBuilder.java
@@ -90,4 +90,13 @@ public RolloverRequestBuilder waitForActiveShards(ActiveShardCount waitForActive
this.request.setWaitForActiveShards(waitForActiveShards);
return this;
}
+
+ /**
+ * A shortcut for {@link #waitForActiveShards(ActiveShardCount)} where the numerical
+ * shard count is passed in, instead of having to first call {@link ActiveShardCount#from(int)}
+ * to get the ActiveShardCount.
+ */
+ public RolloverRequestBuilder waitForActiveShards(final int waitForActiveShards) {
+ return waitForActiveShards(ActiveShardCount.from(waitForActiveShards));
+ }
}
diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/shrink/ShrinkRequest.java b/core/src/main/java/org/elasticsearch/action/admin/indices/shrink/ShrinkRequest.java
index 9ba4acdefc60f..9cb60415a12cc 100644
--- a/core/src/main/java/org/elasticsearch/action/admin/indices/shrink/ShrinkRequest.java
+++ b/core/src/main/java/org/elasticsearch/action/admin/indices/shrink/ShrinkRequest.java
@@ -144,6 +144,15 @@ public void setWaitForActiveShards(ActiveShardCount waitForActiveShards) {
this.getShrinkIndexRequest().waitForActiveShards(waitForActiveShards);
}
+ /**
+ * A shortcut for {@link #setWaitForActiveShards(ActiveShardCount)} where the numerical
+ * shard count is passed in, instead of having to first call {@link ActiveShardCount#from(int)}
+ * to get the ActiveShardCount.
+ */
+ public void setWaitForActiveShards(final int waitForActiveShards) {
+ setWaitForActiveShards(ActiveShardCount.from(waitForActiveShards));
+ }
+
public void source(BytesReference source) {
XContentType xContentType = XContentFactory.xContentType(source);
if (xContentType != null) {
diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/shrink/ShrinkRequestBuilder.java b/core/src/main/java/org/elasticsearch/action/admin/indices/shrink/ShrinkRequestBuilder.java
index 5ec1a5066ebdc..2bd10397193d5 100644
--- a/core/src/main/java/org/elasticsearch/action/admin/indices/shrink/ShrinkRequestBuilder.java
+++ b/core/src/main/java/org/elasticsearch/action/admin/indices/shrink/ShrinkRequestBuilder.java
@@ -64,4 +64,13 @@ public ShrinkRequestBuilder setWaitForActiveShards(ActiveShardCount waitForActiv
this.request.setWaitForActiveShards(waitForActiveShards);
return this;
}
+
+ /**
+ * A shortcut for {@link #setWaitForActiveShards(ActiveShardCount)} where the numerical
+ * shard count is passed in, instead of having to first call {@link ActiveShardCount#from(int)}
+ * to get the ActiveShardCount.
+ */
+ public ShrinkRequestBuilder setWaitForActiveShards(final int waitForActiveShards) {
+ return setWaitForActiveShards(ActiveShardCount.from(waitForActiveShards));
+ }
}
diff --git a/core/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java b/core/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java
index e0572344656b8..7e7aa4ce603be 100644
--- a/core/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java
+++ b/core/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java
@@ -23,10 +23,11 @@
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.CompositeIndicesRequest;
import org.elasticsearch.action.IndicesRequest;
-import org.elasticsearch.action.WriteConsistencyLevel;
import org.elasticsearch.action.delete.DeleteRequest;
import org.elasticsearch.action.index.IndexRequest;
+import org.elasticsearch.action.support.ActiveShardCount;
import org.elasticsearch.action.support.WriteRequest;
+import org.elasticsearch.action.support.replication.ReplicationRequest;
import org.elasticsearch.action.update.UpdateRequest;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.Strings;
@@ -68,7 +69,7 @@ public class BulkRequest extends ActionRequest implements Composite
List