From 13446937a53393975ae6ba19039b78cc5026aa5f Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Fri, 10 Feb 2017 14:04:40 -0700 Subject: [PATCH] Remove action.allow_id_generation setting (#23120) This was an undocumented and unsettable setting that allowed id generation. Resolves #23088 --- .../elasticsearch/action/bulk/TransportBulkAction.java | 4 +--- .../action/bulk/TransportShardBulkAction.java | 4 +--- .../java/org/elasticsearch/action/index/IndexRequest.java | 8 ++++---- .../org/elasticsearch/action/index/IndexRequestTests.java | 4 ++-- .../replication/ESIndexLevelReplicationTestCase.java | 2 +- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java b/core/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java index e7c2018ad31..ec529e59ae7 100644 --- a/core/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java +++ b/core/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java @@ -82,7 +82,6 @@ import java.util.stream.Collectors; public class TransportBulkAction extends HandledTransportAction { private final AutoCreateIndex autoCreateIndex; - private final boolean allowIdGeneration; private final ClusterService clusterService; private final IngestService ingestService; private final TransportShardBulkAction shardBulkAction; @@ -115,7 +114,6 @@ public class TransportBulkAction extends HandledTransportAction implement } - public void process(@Nullable MappingMetaData mappingMd, boolean allowIdGeneration, String concreteIndex) { + public void process(@Nullable MappingMetaData mappingMd, String concreteIndex) { if (mappingMd != null) { // might as well check for routing here if (mappingMd.routing().required() && routing == null) { @@ -542,9 +542,9 @@ public class IndexRequest extends ReplicatedWriteRequest implement } } - // generate id if not already provided and id generation is allowed - if (allowIdGeneration && id == null) { - assert autoGeneratedTimestamp == -1; + // generate id if not already provided + if (id == null) { + assert autoGeneratedTimestamp == -1 : "timestamp has already been generated!"; autoGeneratedTimestamp = Math.max(0, System.currentTimeMillis()); // extra paranoia id(UUIDs.base64UUID()); } diff --git a/core/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java b/core/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java index 034ad915d04..55d51a42677 100644 --- a/core/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java +++ b/core/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java @@ -122,10 +122,10 @@ public class IndexRequestTests extends ESTestCase { public void testAutoGenIdTimestampIsSet() { IndexRequest request = new IndexRequest("index", "type"); - request.process(null, true, "index"); + request.process(null, "index"); assertTrue("expected > 0 but got: " + request.getAutoGeneratedTimestamp(), request.getAutoGeneratedTimestamp() > 0); request = new IndexRequest("index", "type", "1"); - request.process(null, true, "index"); + request.process(null, "index"); assertEquals(IndexRequest.UNSET_AUTO_GENERATED_TIMESTAMP, request.getAutoGeneratedTimestamp()); } diff --git a/core/src/test/java/org/elasticsearch/index/replication/ESIndexLevelReplicationTestCase.java b/core/src/test/java/org/elasticsearch/index/replication/ESIndexLevelReplicationTestCase.java index 681a3758ea7..0a0cddf5d81 100644 --- a/core/src/test/java/org/elasticsearch/index/replication/ESIndexLevelReplicationTestCase.java +++ b/core/src/test/java/org/elasticsearch/index/replication/ESIndexLevelReplicationTestCase.java @@ -490,7 +490,7 @@ public abstract class ESIndexLevelReplicationTestCase extends IndexShardTestCase IndexingAction(IndexRequest request, ActionListener listener, ReplicationGroup replicationGroup) { super(request, listener, replicationGroup, "indexing"); - request.process(null, true, request.index()); + request.process(null, request.index()); } @Override