Skip to content

Commit

Permalink
Remove obsolete resolving logic from TRA
Browse files Browse the repository at this point in the history
  • Loading branch information
ywelsch committed Nov 27, 2019
1 parent 815ea92 commit ead8dea
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<PrimaryResult<BulkShardRequest, BulkShardResponse>> listener) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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()) {
Expand All @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<TestResponse> listener = new PlainActionFuture<>();
ReplicationTask task = maybeTask();

Expand All @@ -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<TestResponse> listener = new PlainActionFuture<>();
ReplicationTask task = maybeTask();

Expand All @@ -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<TestResponse> listener = new PlainActionFuture<>();
ReplicationTask task = maybeTask();

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit ead8dea

Please sign in to comment.