Browse Source

Remove action.allow_id_generation setting (#23120)

This was an undocumented and unsettable setting that allowed id generation.

Resolves #23088
Lee Hinman 8 years ago
parent
commit
13446937a5

+ 1 - 3
core/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java

@@ -82,7 +82,6 @@ import java.util.stream.Collectors;
 public class TransportBulkAction extends HandledTransportAction<BulkRequest, BulkResponse> {
 public class TransportBulkAction extends HandledTransportAction<BulkRequest, BulkResponse> {
 
 
     private final AutoCreateIndex autoCreateIndex;
     private final AutoCreateIndex autoCreateIndex;
-    private final boolean allowIdGeneration;
     private final ClusterService clusterService;
     private final ClusterService clusterService;
     private final IngestService ingestService;
     private final IngestService ingestService;
     private final TransportShardBulkAction shardBulkAction;
     private final TransportShardBulkAction shardBulkAction;
@@ -115,7 +114,6 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
         this.shardBulkAction = shardBulkAction;
         this.shardBulkAction = shardBulkAction;
         this.createIndexAction = createIndexAction;
         this.createIndexAction = createIndexAction;
         this.autoCreateIndex = autoCreateIndex;
         this.autoCreateIndex = autoCreateIndex;
-        this.allowIdGeneration = this.settings.getAsBoolean("action.bulk.action.allow_id_generation", true);
         this.relativeTimeProvider = relativeTimeProvider;
         this.relativeTimeProvider = relativeTimeProvider;
         this.ingestForwarder = new IngestActionForwarder(transportService);
         this.ingestForwarder = new IngestActionForwarder(transportService);
         clusterService.addStateApplier(this.ingestForwarder);
         clusterService.addStateApplier(this.ingestForwarder);
@@ -267,7 +265,7 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
                                 mappingMd = indexMetaData.mappingOrDefault(indexRequest.type());
                                 mappingMd = indexMetaData.mappingOrDefault(indexRequest.type());
                             }
                             }
                             indexRequest.resolveRouting(metaData);
                             indexRequest.resolveRouting(metaData);
-                            indexRequest.process(mappingMd, allowIdGeneration, concreteIndex.getName());
+                            indexRequest.process(mappingMd, concreteIndex.getName());
                             break;
                             break;
                         case UPDATE:
                         case UPDATE:
                             TransportUpdateAction.resolveAndValidateRouting(metaData, concreteIndex.getName(), (UpdateRequest) docWriteRequest);
                             TransportUpdateAction.resolveAndValidateRouting(metaData, concreteIndex.getName(), (UpdateRequest) docWriteRequest);

+ 1 - 3
core/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java

@@ -72,7 +72,6 @@ public class TransportShardBulkAction extends TransportWriteAction<BulkShardRequ
     public static final String ACTION_NAME = BulkAction.NAME + "[s]";
     public static final String ACTION_NAME = BulkAction.NAME + "[s]";
 
 
     private final UpdateHelper updateHelper;
     private final UpdateHelper updateHelper;
-    private final boolean allowIdGeneration;
     private final MappingUpdatedAction mappingUpdatedAction;
     private final MappingUpdatedAction mappingUpdatedAction;
 
 
     @Inject
     @Inject
@@ -83,7 +82,6 @@ public class TransportShardBulkAction extends TransportWriteAction<BulkShardRequ
         super(settings, ACTION_NAME, transportService, clusterService, indicesService, threadPool, shardStateAction, actionFilters,
         super(settings, ACTION_NAME, transportService, clusterService, indicesService, threadPool, shardStateAction, actionFilters,
             indexNameExpressionResolver, BulkShardRequest::new, BulkShardRequest::new, ThreadPool.Names.BULK);
             indexNameExpressionResolver, BulkShardRequest::new, BulkShardRequest::new, ThreadPool.Names.BULK);
         this.updateHelper = updateHelper;
         this.updateHelper = updateHelper;
-        this.allowIdGeneration = settings.getAsBoolean("action.allow_id_generation", true);
         this.mappingUpdatedAction = mappingUpdatedAction;
         this.mappingUpdatedAction = mappingUpdatedAction;
     }
     }
 
 
@@ -281,7 +279,7 @@ public class TransportShardBulkAction extends TransportWriteAction<BulkShardRequ
                 case UPDATED:
                 case UPDATED:
                     IndexRequest indexRequest = translate.action();
                     IndexRequest indexRequest = translate.action();
                     MappingMetaData mappingMd = metaData.mappingOrDefault(indexRequest.type());
                     MappingMetaData mappingMd = metaData.mappingOrDefault(indexRequest.type());
-                    indexRequest.process(mappingMd, allowIdGeneration, request.index());
+                    indexRequest.process(mappingMd, request.index());
                     updateOperationResult = executeIndexRequestOnPrimary(indexRequest, primary, mappingUpdatedAction);
                     updateOperationResult = executeIndexRequestOnPrimary(indexRequest, primary, mappingUpdatedAction);
                     if (updateOperationResult.hasFailure() == false) {
                     if (updateOperationResult.hasFailure() == false) {
                         // update the version on request so it will happen on the replicas
                         // update the version on request so it will happen on the replicas

+ 4 - 4
core/src/main/java/org/elasticsearch/action/index/IndexRequest.java

@@ -526,7 +526,7 @@ public class IndexRequest extends ReplicatedWriteRequest<IndexRequest> implement
     }
     }
 
 
 
 
-    public void process(@Nullable MappingMetaData mappingMd, boolean allowIdGeneration, String concreteIndex) {
+    public void process(@Nullable MappingMetaData mappingMd, String concreteIndex) {
         if (mappingMd != null) {
         if (mappingMd != null) {
             // might as well check for routing here
             // might as well check for routing here
             if (mappingMd.routing().required() && routing == null) {
             if (mappingMd.routing().required() && routing == null) {
@@ -542,9 +542,9 @@ public class IndexRequest extends ReplicatedWriteRequest<IndexRequest> 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
             autoGeneratedTimestamp = Math.max(0, System.currentTimeMillis()); // extra paranoia
             id(UUIDs.base64UUID());
             id(UUIDs.base64UUID());
         }
         }

+ 2 - 2
core/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java

@@ -122,10 +122,10 @@ public class IndexRequestTests extends ESTestCase {
 
 
     public void testAutoGenIdTimestampIsSet() {
     public void testAutoGenIdTimestampIsSet() {
         IndexRequest request = new IndexRequest("index", "type");
         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);
         assertTrue("expected > 0 but got: " + request.getAutoGeneratedTimestamp(), request.getAutoGeneratedTimestamp() > 0);
         request = new IndexRequest("index", "type", "1");
         request = new IndexRequest("index", "type", "1");
-        request.process(null, true, "index");
+        request.process(null, "index");
         assertEquals(IndexRequest.UNSET_AUTO_GENERATED_TIMESTAMP, request.getAutoGeneratedTimestamp());
         assertEquals(IndexRequest.UNSET_AUTO_GENERATED_TIMESTAMP, request.getAutoGeneratedTimestamp());
     }
     }
 
 

+ 1 - 1
core/src/test/java/org/elasticsearch/index/replication/ESIndexLevelReplicationTestCase.java

@@ -490,7 +490,7 @@ public abstract class ESIndexLevelReplicationTestCase extends IndexShardTestCase
 
 
         IndexingAction(IndexRequest request, ActionListener<IndexResponse> listener, ReplicationGroup replicationGroup) {
         IndexingAction(IndexRequest request, ActionListener<IndexResponse> listener, ReplicationGroup replicationGroup) {
             super(request, listener, replicationGroup, "indexing");
             super(request, listener, replicationGroup, "indexing");
-            request.process(null, true, request.index());
+            request.process(null, request.index());
         }
         }
 
 
         @Override
         @Override