Skip to content

Commit 1dc8cb0

Browse files
committed
Trim down usages of ShardOperationFailedException interface (#28312)
In many cases we use the `ShardOperationFailedException` interface to abstract an exception that can only be of one type, namely `DefaultShardOperationException`. There is no need to use the interface in such cases, the concrete type should be used instead. That has the additional advantage of simplifying parsing such exceptions back from rest responses for the high-level REST client
1 parent 00c6e66 commit 1dc8cb0

32 files changed

+87
-89
lines changed

server/src/main/java/org/elasticsearch/action/admin/indices/cache/clear/ClearIndicesCacheResponse.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
package org.elasticsearch.action.admin.indices.cache.clear;
2121

22-
import org.elasticsearch.action.ShardOperationFailedException;
22+
import org.elasticsearch.action.support.DefaultShardOperationFailedException;
2323
import org.elasticsearch.action.support.broadcast.BroadcastResponse;
2424
import org.elasticsearch.common.io.stream.StreamInput;
2525
import org.elasticsearch.common.io.stream.StreamOutput;
@@ -38,7 +38,8 @@ public class ClearIndicesCacheResponse extends BroadcastResponse {
3838

3939
}
4040

41-
ClearIndicesCacheResponse(int totalShards, int successfulShards, int failedShards, List<ShardOperationFailedException> shardFailures) {
41+
ClearIndicesCacheResponse(int totalShards, int successfulShards, int failedShards,
42+
List<DefaultShardOperationFailedException> shardFailures) {
4243
super(totalShards, successfulShards, failedShards, shardFailures);
4344
}
4445

server/src/main/java/org/elasticsearch/action/admin/indices/cache/clear/TransportClearIndicesCacheAction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
package org.elasticsearch.action.admin.indices.cache.clear;
2121

22-
import org.elasticsearch.action.ShardOperationFailedException;
2322
import org.elasticsearch.action.support.ActionFilters;
23+
import org.elasticsearch.action.support.DefaultShardOperationFailedException;
2424
import org.elasticsearch.action.support.broadcast.node.TransportBroadcastByNodeAction;
2525
import org.elasticsearch.cluster.ClusterState;
2626
import org.elasticsearch.cluster.block.ClusterBlockException;
@@ -65,7 +65,7 @@ protected EmptyResult readShardResult(StreamInput in) throws IOException {
6565
@Override
6666
protected ClearIndicesCacheResponse newResponse(ClearIndicesCacheRequest request, int totalShards, int successfulShards,
6767
int failedShards, List<EmptyResult> responses,
68-
List<ShardOperationFailedException> shardFailures, ClusterState clusterState) {
68+
List<DefaultShardOperationFailedException> shardFailures, ClusterState clusterState) {
6969
return new ClearIndicesCacheResponse(totalShards, successfulShards, failedShards, shardFailures);
7070
}
7171

server/src/main/java/org/elasticsearch/action/admin/indices/flush/FlushResponse.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
package org.elasticsearch.action.admin.indices.flush;
2121

22-
import org.elasticsearch.action.ShardOperationFailedException;
22+
import org.elasticsearch.action.support.DefaultShardOperationFailedException;
2323
import org.elasticsearch.action.support.broadcast.BroadcastResponse;
2424

2525
import java.util.List;
@@ -35,7 +35,7 @@ public class FlushResponse extends BroadcastResponse {
3535

3636
}
3737

38-
FlushResponse(int totalShards, int successfulShards, int failedShards, List<ShardOperationFailedException> shardFailures) {
38+
FlushResponse(int totalShards, int successfulShards, int failedShards, List<DefaultShardOperationFailedException> shardFailures) {
3939
super(totalShards, successfulShards, failedShards, shardFailures);
4040
}
4141

server/src/main/java/org/elasticsearch/action/admin/indices/flush/TransportFlushAction.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
package org.elasticsearch.action.admin.indices.flush;
2121

22-
import org.elasticsearch.action.ShardOperationFailedException;
2322
import org.elasticsearch.action.support.ActionFilters;
23+
import org.elasticsearch.action.support.DefaultShardOperationFailedException;
2424
import org.elasticsearch.action.support.replication.ReplicationResponse;
2525
import org.elasticsearch.action.support.replication.TransportBroadcastReplicationAction;
2626
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
@@ -57,7 +57,8 @@ protected ShardFlushRequest newShardRequest(FlushRequest request, ShardId shardI
5757
}
5858

5959
@Override
60-
protected FlushResponse newResponse(int successfulShards, int failedShards, int totalNumCopies, List<ShardOperationFailedException> shardFailures) {
60+
protected FlushResponse newResponse(int successfulShards, int failedShards, int totalNumCopies, List
61+
<DefaultShardOperationFailedException> shardFailures) {
6162
return new FlushResponse(totalNumCopies, successfulShards, failedShards, shardFailures);
6263
}
6364
}

server/src/main/java/org/elasticsearch/action/admin/indices/forcemerge/ForceMergeResponse.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
package org.elasticsearch.action.admin.indices.forcemerge;
2121

22-
import org.elasticsearch.action.ShardOperationFailedException;
22+
import org.elasticsearch.action.support.DefaultShardOperationFailedException;
2323
import org.elasticsearch.action.support.broadcast.BroadcastResponse;
2424

2525
import java.util.List;
@@ -32,7 +32,7 @@ public class ForceMergeResponse extends BroadcastResponse {
3232
ForceMergeResponse() {
3333
}
3434

35-
ForceMergeResponse(int totalShards, int successfulShards, int failedShards, List<ShardOperationFailedException> shardFailures) {
35+
ForceMergeResponse(int totalShards, int successfulShards, int failedShards, List<DefaultShardOperationFailedException> shardFailures) {
3636
super(totalShards, successfulShards, failedShards, shardFailures);
3737
}
3838
}

server/src/main/java/org/elasticsearch/action/admin/indices/forcemerge/TransportForceMergeAction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
package org.elasticsearch.action.admin.indices.forcemerge;
2121

22-
import org.elasticsearch.action.ShardOperationFailedException;
2322
import org.elasticsearch.action.support.ActionFilters;
23+
import org.elasticsearch.action.support.DefaultShardOperationFailedException;
2424
import org.elasticsearch.action.support.broadcast.node.TransportBroadcastByNodeAction;
2525
import org.elasticsearch.cluster.ClusterState;
2626
import org.elasticsearch.cluster.block.ClusterBlockException;
@@ -62,7 +62,7 @@ protected EmptyResult readShardResult(StreamInput in) throws IOException {
6262
}
6363

6464
@Override
65-
protected ForceMergeResponse newResponse(ForceMergeRequest request, int totalShards, int successfulShards, int failedShards, List<EmptyResult> responses, List<ShardOperationFailedException> shardFailures, ClusterState clusterState) {
65+
protected ForceMergeResponse newResponse(ForceMergeRequest request, int totalShards, int successfulShards, int failedShards, List<EmptyResult> responses, List<DefaultShardOperationFailedException> shardFailures, ClusterState clusterState) {
6666
return new ForceMergeResponse(totalShards, successfulShards, failedShards, shardFailures);
6767
}
6868

server/src/main/java/org/elasticsearch/action/admin/indices/recovery/RecoveryResponse.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
package org.elasticsearch.action.admin.indices.recovery;
2121

22-
import org.elasticsearch.action.ShardOperationFailedException;
22+
import org.elasticsearch.action.support.DefaultShardOperationFailedException;
2323
import org.elasticsearch.action.support.broadcast.BroadcastResponse;
2424
import org.elasticsearch.common.Strings;
2525
import org.elasticsearch.common.io.stream.StreamInput;
@@ -56,7 +56,8 @@ public RecoveryResponse() { }
5656
* @param shardFailures List of failures processing shards
5757
*/
5858
public RecoveryResponse(int totalShards, int successfulShards, int failedShards, boolean detailed,
59-
Map<String, List<RecoveryState>> shardRecoveryStates, List<ShardOperationFailedException> shardFailures) {
59+
Map<String, List<RecoveryState>> shardRecoveryStates,
60+
List<DefaultShardOperationFailedException> shardFailures) {
6061
super(totalShards, successfulShards, failedShards, shardFailures);
6162
this.shardRecoveryStates = shardRecoveryStates;
6263
this.detailed = detailed;

server/src/main/java/org/elasticsearch/action/admin/indices/recovery/TransportRecoveryAction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
package org.elasticsearch.action.admin.indices.recovery;
2121

22-
import org.elasticsearch.action.ShardOperationFailedException;
2322
import org.elasticsearch.action.support.ActionFilters;
23+
import org.elasticsearch.action.support.DefaultShardOperationFailedException;
2424
import org.elasticsearch.action.support.broadcast.node.TransportBroadcastByNodeAction;
2525
import org.elasticsearch.cluster.ClusterState;
2626
import org.elasticsearch.cluster.block.ClusterBlockException;
@@ -69,7 +69,7 @@ protected RecoveryState readShardResult(StreamInput in) throws IOException {
6969

7070

7171
@Override
72-
protected RecoveryResponse newResponse(RecoveryRequest request, int totalShards, int successfulShards, int failedShards, List<RecoveryState> responses, List<ShardOperationFailedException> shardFailures, ClusterState clusterState) {
72+
protected RecoveryResponse newResponse(RecoveryRequest request, int totalShards, int successfulShards, int failedShards, List<RecoveryState> responses, List<DefaultShardOperationFailedException> shardFailures, ClusterState clusterState) {
7373
Map<String, List<RecoveryState>> shardResponses = new HashMap<>();
7474
for (RecoveryState recoveryState : responses) {
7575
if (recoveryState == null) {

server/src/main/java/org/elasticsearch/action/admin/indices/refresh/RefreshResponse.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
package org.elasticsearch.action.admin.indices.refresh;
2121

22-
import org.elasticsearch.action.ShardOperationFailedException;
22+
import org.elasticsearch.action.support.DefaultShardOperationFailedException;
2323
import org.elasticsearch.action.support.broadcast.BroadcastResponse;
2424

2525
import java.util.List;
@@ -32,7 +32,7 @@ public class RefreshResponse extends BroadcastResponse {
3232
RefreshResponse() {
3333
}
3434

35-
RefreshResponse(int totalShards, int successfulShards, int failedShards, List<ShardOperationFailedException> shardFailures) {
35+
RefreshResponse(int totalShards, int successfulShards, int failedShards, List<DefaultShardOperationFailedException> shardFailures) {
3636
super(totalShards, successfulShards, failedShards, shardFailures);
3737
}
3838
}

server/src/main/java/org/elasticsearch/action/admin/indices/refresh/TransportRefreshAction.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919

2020
package org.elasticsearch.action.admin.indices.refresh;
2121

22-
import org.elasticsearch.action.ShardOperationFailedException;
2322
import org.elasticsearch.action.support.ActionFilters;
2423
import org.elasticsearch.action.support.ActiveShardCount;
24+
import org.elasticsearch.action.support.DefaultShardOperationFailedException;
2525
import org.elasticsearch.action.support.replication.BasicReplicationRequest;
2626
import org.elasticsearch.action.support.replication.ReplicationResponse;
2727
import org.elasticsearch.action.support.replication.TransportBroadcastReplicationAction;
@@ -61,7 +61,8 @@ protected BasicReplicationRequest newShardRequest(RefreshRequest request, ShardI
6161
}
6262

6363
@Override
64-
protected RefreshResponse newResponse(int successfulShards, int failedShards, int totalNumCopies, List<ShardOperationFailedException> shardFailures) {
64+
protected RefreshResponse newResponse(int successfulShards, int failedShards, int totalNumCopies,
65+
List<DefaultShardOperationFailedException> shardFailures) {
6566
return new RefreshResponse(totalNumCopies, successfulShards, failedShards, shardFailures);
6667
}
6768
}

0 commit comments

Comments
 (0)