Trim down usages of `ShardOperationFailedException` interface (elastic/x-pack-elasticsearch#3662)
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. Original commit: elastic/x-pack-elasticsearch@b2259afcbf
This commit is contained in:
parent
8ee5b608e0
commit
d9eb4c049f
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
package org.elasticsearch.action.admin.indices.stats;
|
||||
|
||||
import org.elasticsearch.action.ShardOperationFailedException;
|
||||
import org.elasticsearch.action.support.DefaultShardOperationFailedException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -14,8 +14,8 @@ public class IndicesStatsResponseTestUtils {
|
|||
/**
|
||||
* Gives access to package private IndicesStatsResponse constructor for test purpose.
|
||||
**/
|
||||
public static IndicesStatsResponse newIndicesStatsResponse(ShardStats[] shards, int totalShards, int successfulShards,
|
||||
int failedShards, List<ShardOperationFailedException> shardFailures) {
|
||||
public static IndicesStatsResponse newIndicesStatsResponse(ShardStats[] shards, int totalShards, int successfulShards, int failedShards,
|
||||
List<DefaultShardOperationFailedException> shardFailures) {
|
||||
return new IndicesStatsResponse(shards, totalShards, successfulShards, failedShards, shardFailures);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -759,10 +759,6 @@ public class TransportGraphExploreAction extends HandledTransportAction<GraphExp
|
|||
return (startTime + request.timeout().millis()) - threadPool.relativeTimeInMillis();
|
||||
}
|
||||
|
||||
void addShardFailure(ShardOperationFailedException failure) {
|
||||
addShardFailures(new ShardOperationFailedException[]{failure});
|
||||
}
|
||||
|
||||
void addShardFailures(ShardOperationFailedException[] failures) {
|
||||
if (!CollectionUtils.isEmpty(failures)) {
|
||||
ShardOperationFailedException[] duplicates = new ShardOperationFailedException[shardFailures.length + failures.length];
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
package org.elasticsearch.xpack.monitoring.collector.indices;
|
||||
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.action.ShardOperationFailedException;
|
||||
import org.elasticsearch.action.admin.indices.recovery.RecoveryResponse;
|
||||
import org.elasticsearch.action.admin.indices.shards.IndicesShardStoresResponse;
|
||||
import org.elasticsearch.action.support.DefaultShardOperationFailedException;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.cluster.routing.RecoverySource;
|
||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||
|
@ -104,7 +104,7 @@ public class IndexRecoveryMonitoringDocTests extends BaseMonitoringDocTestCase<I
|
|||
final RecoveryState.Timer timer = recoveryState.getTimer();
|
||||
timer.stop();
|
||||
|
||||
final List<ShardOperationFailedException> shardFailures = new ArrayList<>();
|
||||
final List<DefaultShardOperationFailedException> shardFailures = new ArrayList<>();
|
||||
final Throwable reason = new NodeDisconnectedException(discoveryNodeZero, "");
|
||||
shardFailures.add(new IndicesShardStoresResponse.Failure("_failed_node_id", "_failed_index", 1, reason));
|
||||
|
||||
|
|
Loading…
Reference in New Issue