From ead8dea220598d2833f9b60e638ed8cfffb7e030 Mon Sep 17 00:00:00 2001 From: Yannick Welsch Date: Wed, 27 Nov 2019 14:54:33 +0100 Subject: [PATCH] Remove obsolete resolving logic from TRA Closes #20279 --- .../action/bulk/TransportShardBulkAction.java | 5 ----- .../replication/TransportReplicationAction.java | 14 +------------- .../TransportReplicationActionTests.java | 13 +++++-------- 3 files changed, 6 insertions(+), 26 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java b/server/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java index c322af9a9d3e5..4ad83447c500a 100644 --- a/server/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java +++ b/server/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java @@ -111,11 +111,6 @@ protected BulkShardResponse newResponseInstance(StreamInput in) throws IOExcepti return new BulkShardResponse(in); } - @Override - protected boolean resolveIndex() { - return false; - } - @Override protected void shardOperationOnPrimary(BulkShardRequest request, IndexShard primary, ActionListener> listener) { diff --git a/server/src/main/java/org/elasticsearch/action/support/replication/TransportReplicationAction.java b/server/src/main/java/org/elasticsearch/action/support/replication/TransportReplicationAction.java index 1fe2abf6698bd..306ba58dc0dcb 100644 --- a/server/src/main/java/org/elasticsearch/action/support/replication/TransportReplicationAction.java +++ b/server/src/main/java/org/elasticsearch/action/support/replication/TransportReplicationAction.java @@ -219,21 +219,10 @@ public ClusterBlockLevel indexBlockLevel() { return null; } - /** - * True if provided index should be resolved when resolving request - */ - protected boolean resolveIndex() { - return true; - } - protected TransportRequestOptions transportOptions(Settings settings) { return TransportRequestOptions.EMPTY; } - private String concreteIndex(final ClusterState state, final ReplicationRequest request) { - return resolveIndex() ? indexNameExpressionResolver.concreteSingleIndex(state, request).getName() : request.index(); - } - private ClusterBlockException blockExceptions(final ClusterState state, final String indexName) { ClusterBlockLevel globalBlockLevel = globalBlockLevel(); if (globalBlockLevel != null) { @@ -648,7 +637,7 @@ public void onFailure(Exception e) { protected void doRun() { setPhase(task, "routing"); final ClusterState state = observer.setAndGetObservedState(); - final String concreteIndex = concreteIndex(state, request); + final String concreteIndex = request.shardId().getIndexName(); final ClusterBlockException blockException = blockExceptions(state, concreteIndex); if (blockException != null) { if (blockException.retryable()) { @@ -658,7 +647,6 @@ protected void doRun() { finishAsFailed(blockException); } } else { - // request does not have a shardId yet, we need to pass the concrete index to resolve shardId final IndexMetaData indexMetaData = state.metaData().index(concreteIndex); if (indexMetaData == null) { retry(new IndexNotFoundException(concreteIndex)); diff --git a/server/src/test/java/org/elasticsearch/action/support/replication/TransportReplicationActionTests.java b/server/src/test/java/org/elasticsearch/action/support/replication/TransportReplicationActionTests.java index 462bec274d78c..30cb7128147d5 100644 --- a/server/src/test/java/org/elasticsearch/action/support/replication/TransportReplicationActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/support/replication/TransportReplicationActionTests.java @@ -235,10 +235,12 @@ public ClusterBlockLevel indexBlockLevel() { setState(clusterService, ClusterStateCreationUtils.stateWithActivePrimary("index", true, 0)); + ShardId shardId = new ShardId(clusterService.state().metaData().index("index").getIndex(), 0); + { setStateWithBlock(clusterService, nonRetryableBlock, globalBlock); - Request request = globalBlock ? new Request(NO_SHARD_ID) : new Request(NO_SHARD_ID).index("index"); + Request request = new Request(shardId); PlainActionFuture listener = new PlainActionFuture<>(); ReplicationTask task = maybeTask(); @@ -253,7 +255,7 @@ public ClusterBlockLevel indexBlockLevel() { { setStateWithBlock(clusterService, retryableBlock, globalBlock); - Request requestWithTimeout = (globalBlock ? new Request(NO_SHARD_ID) : new Request(NO_SHARD_ID).index("index")).timeout("5ms"); + Request requestWithTimeout = (globalBlock ? new Request(shardId) : new Request(shardId)).timeout("5ms"); PlainActionFuture listener = new PlainActionFuture<>(); ReplicationTask task = maybeTask(); @@ -269,7 +271,7 @@ public ClusterBlockLevel indexBlockLevel() { { setStateWithBlock(clusterService, retryableBlock, globalBlock); - Request request = globalBlock ? new Request(NO_SHARD_ID) : new Request(NO_SHARD_ID).index("index"); + Request request = new Request(shardId); PlainActionFuture listener = new PlainActionFuture<>(); ReplicationTask task = maybeTask(); @@ -1267,11 +1269,6 @@ protected ReplicaResult shardOperationOnReplica(Request request, IndexShard repl request.processedOnReplicas.incrementAndGet(); return new ReplicaResult(); } - - @Override - protected boolean resolveIndex() { - return false; - } } private IndicesService mockIndicesService(ClusterService clusterService) {