public static DefaultShardOperationFailedException readShardOperationFailed(StreamInput in) throws IOException { DefaultShardOperationFailedException exp = new DefaultShardOperationFailedException(); exp.readFrom(in); return exp; }
totalShards += nodes.get(exception.nodeId()).size(); for (ShardRouting shard : nodes.get(exception.nodeId())) { exceptions.add(new DefaultShardOperationFailedException(shard.getIndexName(), shard.getId(), exception)); for (BroadcastShardOperationFailedException throwable : response.getExceptions()) { if (!TransportActions.isShardNotAvailableException(throwable)) { exceptions.add(new DefaultShardOperationFailedException(throwable.getShardId().getIndexName(), throwable.getShardId().getId(), throwable));
shardFailures = new ArrayList<>(); shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse)); } else { ShardValidateQueryResponse validateQueryResponse = (ShardValidateQueryResponse) shardResponse;
private void finishAndNotifyListener(ActionListener listener, CopyOnWriteArrayList<ShardResponse> shardsResponses) { logger.trace("{}: got all shard responses", actionName); int successfulShards = 0; int failedShards = 0; int totalNumCopies = 0; List<DefaultShardOperationFailedException> shardFailures = null; for (int i = 0; i < shardsResponses.size(); i++) { ReplicationResponse shardResponse = shardsResponses.get(i); if (shardResponse == null) { // non active shard, ignore } else { failedShards += shardResponse.getShardInfo().getFailed(); successfulShards += shardResponse.getShardInfo().getSuccessful(); totalNumCopies += shardResponse.getShardInfo().getTotal(); if (shardFailures == null) { shardFailures = new ArrayList<>(); } for (ReplicationResponse.ShardInfo.Failure failure : shardResponse.getShardInfo().getFailures()) { shardFailures.add(new DefaultShardOperationFailedException( new BroadcastShardOperationFailedException(failure.fullShardId(), failure.getCause()))); } } } listener.onResponse(newResponse(successfulShards, failedShards, totalNumCopies, shardFailures)); }
public static DefaultShardOperationFailedException readShardOperationFailed(StreamInput in) throws IOException { DefaultShardOperationFailedException exp = new DefaultShardOperationFailedException(); exp.readFrom(in); return exp; }
public static DefaultShardOperationFailedException readShardOperationFailed(StreamInput in) throws IOException { DefaultShardOperationFailedException exp = new DefaultShardOperationFailedException(); exp.readFrom(in); return exp; }
public static DefaultShardOperationFailedException readShardOperationFailed(StreamInput in) throws IOException { DefaultShardOperationFailedException exp = new DefaultShardOperationFailedException(); exp.readFrom(in); return exp; }
@Override protected SuggestRefreshResponse newResponse(SuggestRefreshRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) { int successfulShards = 0; int failedShards = 0; List<ShardOperationFailedException> shardFailures = Lists.newArrayList(); for (int i = 0; i < shardsResponses.length(); i++) { Object shardResponse = shardsResponses.get(i); if (shardResponse == null) { failedShards++; } else if (shardResponse instanceof BroadcastShardOperationFailedException) { failedShards++; shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse)); } else { successfulShards++; } } return new SuggestRefreshResponse(shardsResponses.length(), successfulShards, failedShards, shardFailures); }
@Override protected ExportResponse newResponse(ExportRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) { int successfulShards = 0; int failedShards = 0; List<ShardOperationFailedException> shardFailures = null; List<ShardExportResponse> responses = new ArrayList<ShardExportResponse>(); for (int i = 0; i < shardsResponses.length(); i++) { Object shardResponse = shardsResponses.get(i); if (shardResponse == null) { failedShards++; } else if (shardResponse instanceof BroadcastShardOperationFailedException) { failedShards++; if (shardFailures == null) { shardFailures = newArrayList(); } shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse)); } else { responses.add((ShardExportResponse) shardResponse); successfulShards++; } } return new ExportResponse(responses, shardsResponses.length(), successfulShards, failedShards, shardFailures); }
@Override protected SuggestStatisticsResponse newResponse(SuggestStatisticsRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) { int successfulShards = 0; int failedShards = 0; List<ShardOperationFailedException> shardFailures = Lists.newArrayList(); List<ShardSuggestStatisticsResponse> successfulStatistics = Lists.newArrayList(); for (int i = 0; i < shardsResponses.length(); i++) { Object shardResponse = shardsResponses.get(i); if (shardResponse == null) { failedShards++; } else if (shardResponse instanceof BroadcastShardOperationFailedException) { failedShards++; shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse)); } else { successfulShards++; successfulStatistics.add((ShardSuggestStatisticsResponse)shardResponse); } } return new SuggestStatisticsResponse(shardsResponses.length(), successfulShards, failedShards, successfulStatistics, shardFailures); }
@Override protected ExistsResponse newResponse(ExistsRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) { int successfulShards = 0; int failedShards = 0; boolean exists = false; List<ShardOperationFailedException> shardFailures = null; // if docs do exist, the last response will have exists = true (since we early terminate the shard requests) for (int i = shardsResponses.length() - 1; i >= 0 ; i--) { Object shardResponse = shardsResponses.get(i); if (shardResponse == null) { // simply ignore non active shards } else if (shardResponse instanceof BroadcastShardOperationFailedException) { failedShards++; if (shardFailures == null) { shardFailures = new ArrayList<>(); } shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse)); } else { successfulShards++; if ((exists = ((ShardExistsResponse) shardResponse).exists())) { successfulShards = shardsResponses.length() - failedShards; break; } } } return new ExistsResponse(exists, shardsResponses.length(), successfulShards, failedShards, shardFailures); }
@Override protected SearchIntoResponse newResponse(SearchIntoRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) { int successfulShards = 0; int failedShards = 0; List<ShardOperationFailedException> shardFailures = null; List<ShardSearchIntoResponse> responses = new ArrayList<ShardSearchIntoResponse>(); for (int i = 0; i < shardsResponses.length(); i++) { Object shardResponse = shardsResponses.get(i); if (shardResponse == null) { failedShards++; } else if (shardResponse instanceof BroadcastShardOperationFailedException) { failedShards++; if (shardFailures == null) { shardFailures = newArrayList(); } shardFailures.add(new DefaultShardOperationFailedException( (BroadcastShardOperationFailedException) shardResponse)); } else { responses.add((ShardSearchIntoResponse) shardResponse); successfulShards++; } } return new SearchIntoResponse(responses, shardsResponses.length(), successfulShards, failedShards, shardFailures); }
@Override protected ReconstructIndexResponse newResponse(ReconstructIndexRequest reconstructIndexRequest, AtomicReferenceArray shardsResponses, ClusterState clusterState) { int successfulShards = 0; int failedShards = 0; List<ShardOperationFailedException> shardFailures = null; final List<ShardReconstructIndexResponse> shards = newArrayList(); for (int i = 0; i < shardsResponses.length(); i++) { Object shardResponse = shardsResponses.get(i); if (shardResponse == null) { // a non active shard, ignore... } else if (shardResponse instanceof BroadcastShardOperationFailedException) { failedShards++; if (shardFailures == null) { shardFailures = newArrayList(); } shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse)); } else { shards.add((ShardReconstructIndexResponse)shardResponse); successfulShards++; } } return new ReconstructIndexResponse(shards, shardsResponses.length(), successfulShards, failedShards, shardFailures); }
@Override protected DfsOnlyResponse newResponse(DfsOnlyRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) { int successfulShards = 0; int failedShards = 0; List<ShardOperationFailedException> shardFailures = null; AtomicArray<DfsSearchResult> dfsResults = new AtomicArray<>(shardsResponses.length()); for (int i = 0; i < shardsResponses.length(); i++) { Object shardResponse = shardsResponses.get(i); if (shardResponse == null) { // simply ignore non active shards } else if (shardResponse instanceof BroadcastShardOperationFailedException) { failedShards++; if (shardFailures == null) { shardFailures = new ArrayList<>(); } shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse)); } else { dfsResults.set(i, ((ShardDfsOnlyResponse) shardResponse).getDfsSearchResult()); successfulShards++; } } AggregatedDfs dfs = searchPhaseController.aggregateDfs(dfsResults); return new DfsOnlyResponse(dfs, shardsResponses.length(), successfulShards, failedShards, shardFailures, buildTookInMillis(request)); }
@Override protected SuggestResponse newResponse(SuggestRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) { int successfulShards = 0; int failedShards = 0; final Map<String, List<Suggest.Suggestion>> groupedSuggestions = new HashMap<>(); List<ShardOperationFailedException> shardFailures = null; for (int i = 0; i < shardsResponses.length(); i++) { Object shardResponse = shardsResponses.get(i); if (shardResponse == null) { // simply ignore non active shards } else if (shardResponse instanceof BroadcastShardOperationFailedException) { failedShards++; if (shardFailures == null) { shardFailures = new ArrayList<>(); } shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse)); } else { Suggest suggest = ((ShardSuggestResponse) shardResponse).getSuggest(); Suggest.group(groupedSuggestions, suggest); successfulShards++; } } return new SuggestResponse(new Suggest(Suggest.reduce(groupedSuggestions)), shardsResponses.length(), successfulShards, failedShards, shardFailures); }
shardFailures = newArrayList(); shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse)); } else if (shardResponse instanceof ShardSuggestResponse) { ShardSuggestResponse shardSuggestResponse = (ShardSuggestResponse) shardResponse;
private void finishAndNotifyListener(ActionListener listener, CopyOnWriteArrayList<ShardResponse> shardsResponses) { logger.trace("{}: got all shard responses", actionName); int successfulShards = 0; int failedShards = 0; int totalNumCopies = 0; List<DefaultShardOperationFailedException> shardFailures = null; for (int i = 0; i < shardsResponses.size(); i++) { ReplicationResponse shardResponse = shardsResponses.get(i); if (shardResponse == null) { // non active shard, ignore } else { failedShards += shardResponse.getShardInfo().getFailed(); successfulShards += shardResponse.getShardInfo().getSuccessful(); totalNumCopies += shardResponse.getShardInfo().getTotal(); if (shardFailures == null) { shardFailures = new ArrayList<>(); } for (ReplicationResponse.ShardInfo.Failure failure : shardResponse.getShardInfo().getFailures()) { shardFailures.add(new DefaultShardOperationFailedException(new BroadcastShardOperationFailedException(failure.fullShardId(), failure.getCause()))); } } } listener.onResponse(newResponse(successfulShards, failedShards, totalNumCopies, shardFailures)); }
private void finishAndNotifyListener(ActionListener listener, CopyOnWriteArrayList<ShardResponse> shardsResponses) { logger.trace("{}: got all shard responses", actionName); int successfulShards = 0; int failedShards = 0; int totalNumCopies = 0; List<ShardOperationFailedException> shardFailures = null; for (int i = 0; i < shardsResponses.size(); i++) { ReplicationResponse shardResponse = shardsResponses.get(i); if (shardResponse == null) { // non active shard, ignore } else { failedShards += shardResponse.getShardInfo().getFailed(); successfulShards += shardResponse.getShardInfo().getSuccessful(); totalNumCopies += shardResponse.getShardInfo().getTotal(); if (shardFailures == null) { shardFailures = new ArrayList<>(); } for (ReplicationResponse.ShardInfo.Failure failure : shardResponse.getShardInfo().getFailures()) { shardFailures.add(new DefaultShardOperationFailedException(new BroadcastShardOperationFailedException(failure.fullShardId(), failure.getCause()))); } } } listener.onResponse(newResponse(successfulShards, failedShards, totalNumCopies, shardFailures)); }
private void finishAndNotifyListener(ActionListener listener, CopyOnWriteArrayList<ShardResponse> shardsResponses) { logger.trace("{}: got all shard responses", actionName); int successfulShards = 0; int failedShards = 0; int totalNumCopies = 0; List<DefaultShardOperationFailedException> shardFailures = null; for (int i = 0; i < shardsResponses.size(); i++) { ReplicationResponse shardResponse = shardsResponses.get(i); if (shardResponse == null) { // non active shard, ignore } else { failedShards += shardResponse.getShardInfo().getFailed(); successfulShards += shardResponse.getShardInfo().getSuccessful(); totalNumCopies += shardResponse.getShardInfo().getTotal(); if (shardFailures == null) { shardFailures = new ArrayList<>(); } for (ReplicationResponse.ShardInfo.Failure failure : shardResponse.getShardInfo().getFailures()) { shardFailures.add(new DefaultShardOperationFailedException(new BroadcastShardOperationFailedException(failure.fullShardId(), failure.getCause()))); } } } listener.onResponse(newResponse(successfulShards, failedShards, totalNumCopies, shardFailures)); }
private void finishAndNotifyListener(ActionListener listener, CopyOnWriteArrayList<ShardResponse> shardsResponses) { logger.trace("{}: got all shard responses", actionName); int successfulShards = 0; int failedShards = 0; int totalNumCopies = 0; List<ShardOperationFailedException> shardFailures = null; for (int i = 0; i < shardsResponses.size(); i++) { ActionWriteResponse shardResponse = shardsResponses.get(i); if (shardResponse == null) { // non active shard, ignore } else { failedShards += shardResponse.getShardInfo().getFailed(); successfulShards += shardResponse.getShardInfo().getSuccessful(); totalNumCopies += shardResponse.getShardInfo().getTotal(); if (shardFailures == null) { shardFailures = new ArrayList<>(); } for (ActionWriteResponse.ShardInfo.Failure failure : shardResponse.getShardInfo().getFailures()) { shardFailures.add(new DefaultShardOperationFailedException(new BroadcastShardOperationFailedException(new ShardId(failure.index(), failure.shardId()), failure.getCause()))); } } } listener.onResponse(newResponse(successfulShards, failedShards, totalNumCopies, shardFailures)); }