Search in sources :

Example 6 with ShardOperationFailedException

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.ShardOperationFailedException in project elasticsearch by elastic.

the class BroadcastResponse method writeTo.

@Override
public void writeTo(StreamOutput out) throws IOException {
    super.writeTo(out);
    out.writeVInt(totalShards);
    out.writeVInt(successfulShards);
    out.writeVInt(failedShards);
    out.writeVInt(shardFailures.length);
    for (ShardOperationFailedException exp : shardFailures) {
        exp.writeTo(out);
    }
}
Also used : ShardOperationFailedException(org.elasticsearch.action.ShardOperationFailedException)

Example 7 with ShardOperationFailedException

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.ShardOperationFailedException in project elasticsearch by elastic.

the class TransportBroadcastByNodeAction method newResponse.

private Response newResponse(Request request, AtomicReferenceArray responses, List<NoShardAvailableActionException> unavailableShardExceptions, Map<String, List<ShardRouting>> nodes, ClusterState clusterState) {
    int totalShards = 0;
    int successfulShards = 0;
    List<ShardOperationResult> broadcastByNodeResponses = new ArrayList<>();
    List<ShardOperationFailedException> exceptions = new ArrayList<>();
    for (int i = 0; i < responses.length(); i++) {
        if (responses.get(i) instanceof FailedNodeException) {
            FailedNodeException exception = (FailedNodeException) responses.get(i);
            totalShards += nodes.get(exception.nodeId()).size();
            for (ShardRouting shard : nodes.get(exception.nodeId())) {
                exceptions.add(new DefaultShardOperationFailedException(shard.getIndexName(), shard.getId(), exception));
            }
        } else {
            NodeResponse response = (NodeResponse) responses.get(i);
            broadcastByNodeResponses.addAll(response.results);
            totalShards += response.getTotalShards();
            successfulShards += response.getSuccessfulShards();
            for (BroadcastShardOperationFailedException throwable : response.getExceptions()) {
                if (!TransportActions.isShardNotAvailableException(throwable)) {
                    exceptions.add(new DefaultShardOperationFailedException(throwable.getShardId().getIndexName(), throwable.getShardId().getId(), throwable));
                }
            }
        }
    }
    totalShards += unavailableShardExceptions.size();
    int failedShards = exceptions.size();
    return newResponse(request, totalShards, successfulShards, failedShards, broadcastByNodeResponses, exceptions, clusterState);
}
Also used : ArrayList(java.util.ArrayList) FailedNodeException(org.elasticsearch.action.FailedNodeException) BroadcastShardOperationFailedException(org.elasticsearch.action.support.broadcast.BroadcastShardOperationFailedException) BroadcastShardOperationFailedException(org.elasticsearch.action.support.broadcast.BroadcastShardOperationFailedException) ShardOperationFailedException(org.elasticsearch.action.ShardOperationFailedException) DefaultShardOperationFailedException(org.elasticsearch.action.support.DefaultShardOperationFailedException) ShardRouting(org.elasticsearch.cluster.routing.ShardRouting) DefaultShardOperationFailedException(org.elasticsearch.action.support.DefaultShardOperationFailedException)

Example 8 with ShardOperationFailedException

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.ShardOperationFailedException in project crate by crate.

the class FailedShardsExceptionTest method testShardFailureReasonIsNull.

@Test
public void testShardFailureReasonIsNull() throws Exception {
    FailedShardsException exception = new FailedShardsException(new ShardOperationFailedException[] { new ShardOperationFailedException() {

        @Override
        public String index() {
            return null;
        }

        @Override
        public int shardId() {
            return 0;
        }

        @Override
        public String reason() {
            return null;
        }

        @Override
        public RestStatus status() {
            return null;
        }

        @Override
        public void readFrom(StreamInput in) throws IOException {
        }

        @Override
        public void writeTo(StreamOutput out) throws IOException {
        }

        @Override
        public Throwable getCause() {
            return null;
        }

        @Override
        public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
            return null;
        }
    }, null });
    assertThat(exception.getMessage(), is("query failed on shards 0 ( null )"));
}
Also used : RestStatus(org.elasticsearch.rest.RestStatus) StreamInput(org.elasticsearch.common.io.stream.StreamInput) ShardOperationFailedException(org.elasticsearch.action.ShardOperationFailedException) IOException(java.io.IOException) StreamOutput(org.elasticsearch.common.io.stream.StreamOutput) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 9 with ShardOperationFailedException

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.ShardOperationFailedException in project elasticsearch by elastic.

the class ESIntegTestCase method flush.

/**
     * Flush some or all indices in the cluster.
     */
protected final FlushResponse flush(String... indices) {
    waitForRelocation();
    FlushResponse actionGet = client().admin().indices().prepareFlush(indices).execute().actionGet();
    for (ShardOperationFailedException failure : actionGet.getShardFailures()) {
        assertThat("unexpected flush failure " + failure.reason(), failure.status(), equalTo(RestStatus.SERVICE_UNAVAILABLE));
    }
    return actionGet;
}
Also used : FlushResponse(org.elasticsearch.action.admin.indices.flush.FlushResponse) ShardOperationFailedException(org.elasticsearch.action.ShardOperationFailedException)

Example 10 with ShardOperationFailedException

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.ShardOperationFailedException in project graylog2-server by Graylog2.

the class ElasticsearchBackend method checkForFailedShards.

private Optional<ElasticsearchException> checkForFailedShards(MultiSearchResponse.Item multiSearchResponse) {
    if (multiSearchResponse.isFailure()) {
        return Optional.of(new ElasticsearchException(multiSearchResponse.getFailureMessage(), multiSearchResponse.getFailure()));
    }
    final SearchResponse searchResponse = multiSearchResponse.getResponse();
    if (searchResponse != null && searchResponse.getFailedShards() > 0) {
        final List<Throwable> shardFailures = Arrays.stream(searchResponse.getShardFailures()).map(ShardOperationFailedException::getCause).collect(Collectors.toList());
        final List<String> nonNumericFieldErrors = shardFailures.stream().filter(shardFailure -> shardFailure.getMessage().contains("Expected numeric type on field")).map(Throwable::getMessage).distinct().collect(Collectors.toList());
        if (!nonNumericFieldErrors.isEmpty()) {
            return Optional.of(new FieldTypeException("Unable to perform search query: ", nonNumericFieldErrors));
        }
        final List<String> errors = shardFailures.stream().map(Throwable::getMessage).distinct().collect(Collectors.toList());
        return Optional.of(new ElasticsearchException("Unable to perform search query: ", errors));
    }
    return Optional.empty();
}
Also used : ESSearchTypeHandler(org.graylog.storage.elasticsearch7.views.searchtypes.ESSearchTypeHandler) AndFilter(org.graylog.plugins.views.search.filter.AndFilter) ElasticsearchClient(org.graylog.storage.elasticsearch7.ElasticsearchClient) Arrays(java.util.Arrays) BackendQuery(org.graylog.plugins.views.search.engine.BackendQuery) QueryBackend(org.graylog.plugins.views.search.engine.QueryBackend) Provider(javax.inject.Provider) LoggerFactory(org.slf4j.LoggerFactory) FieldTypeException(org.graylog2.indexer.FieldTypeException) MultiSearchResponse(org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.MultiSearchResponse) StreamFilter(org.graylog.plugins.views.search.filter.StreamFilter) Map(java.util.Map) IndicesOptions(org.graylog.shaded.elasticsearch7.org.elasticsearch.action.support.IndicesOptions) SearchConfig(org.graylog.plugins.views.search.engine.SearchConfig) Set(java.util.Set) Collectors(java.util.stream.Collectors) BoolQueryBuilder(org.graylog.shaded.elasticsearch7.org.elasticsearch.index.query.BoolQueryBuilder) Objects(java.util.Objects) List(java.util.List) Filter(org.graylog.plugins.views.search.Filter) Optional(java.util.Optional) SearchResponse(org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.SearchResponse) Query(org.graylog.plugins.views.search.Query) SearchTypeErrorParser(org.graylog.plugins.views.search.errors.SearchTypeErrorParser) HashMap(java.util.HashMap) ElasticsearchException(org.graylog2.indexer.ElasticsearchException) ShardOperationFailedException(org.graylog.shaded.elasticsearch7.org.elasticsearch.action.ShardOperationFailedException) ArrayList(java.util.ArrayList) GlobalOverride(org.graylog.plugins.views.search.GlobalOverride) Inject(javax.inject.Inject) HashSet(java.util.HashSet) OrFilter(org.graylog.plugins.views.search.filter.OrFilter) SearchType(org.graylog.plugins.views.search.SearchType) QueryStringFilter(org.graylog.plugins.views.search.filter.QueryStringFilter) SearchTypeError(org.graylog.plugins.views.search.errors.SearchTypeError) QueryResult(org.graylog.plugins.views.search.QueryResult) TimeRangeQueryFactory(org.graylog.storage.elasticsearch7.TimeRangeQueryFactory) SearchJob(org.graylog.plugins.views.search.SearchJob) QueryBuilder(org.graylog.shaded.elasticsearch7.org.elasticsearch.index.query.QueryBuilder) SearchSourceBuilder(org.graylog.shaded.elasticsearch7.org.elasticsearch.search.builder.SearchSourceBuilder) Logger(org.slf4j.Logger) SearchRequest(org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.SearchRequest) Maps(com.google.common.collect.Maps) QueryStringDecorators(org.graylog.plugins.views.search.elasticsearch.QueryStringDecorators) Named(com.google.inject.name.Named) IndexLookup(org.graylog.plugins.views.search.elasticsearch.IndexLookup) QueryBuilders(org.graylog.shaded.elasticsearch7.org.elasticsearch.index.query.QueryBuilders) Message(org.graylog2.plugin.Message) Collections(java.util.Collections) FieldTypeException(org.graylog2.indexer.FieldTypeException) ElasticsearchException(org.graylog2.indexer.ElasticsearchException) MultiSearchResponse(org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.MultiSearchResponse) SearchResponse(org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.SearchResponse)

Aggregations

ShardOperationFailedException (org.elasticsearch.action.ShardOperationFailedException)17 ArrayList (java.util.ArrayList)9 List (java.util.List)5 DefaultShardOperationFailedException (org.elasticsearch.action.support.DefaultShardOperationFailedException)4 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 ElasticsearchException (org.elasticsearch.ElasticsearchException)2 FlushResponse (org.elasticsearch.action.admin.indices.flush.FlushResponse)2 StoreStatus.readStoreStatus (org.elasticsearch.action.admin.indices.shards.IndicesShardStoresResponse.StoreStatus.readStoreStatus)2 BroadcastShardOperationFailedException (org.elasticsearch.action.support.broadcast.BroadcastShardOperationFailedException)2 ImmutableOpenIntMap (org.elasticsearch.common.collect.ImmutableOpenIntMap)2 Maps (com.google.common.collect.Maps)1 Named (com.google.inject.name.Named)1 CrateUnitTest (io.crate.test.integration.CrateUnitTest)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1