Search in sources :

Example 21 with ElasticsearchTimeoutException

use of org.elasticsearch.ElasticsearchTimeoutException in project crate by crate.

the class AsyncShardFetch method processAsyncFetch.

/**
 * Called by the response handler of the async action to fetch data. Verifies that its still working
 * on the same cache generation, otherwise the results are discarded. It then goes and fills the relevant data for
 * the shard (response + failures), issuing a reroute at the end of it to make sure there will be another round
 * of allocations taking this new data into account.
 */
protected synchronized void processAsyncFetch(List<T> responses, List<FailedNodeException> failures, long fetchingRound) {
    if (closed) {
        // we are closed, no need to process this async fetch at all
        logger.trace("{} ignoring fetched [{}] results, already closed", shardId, type);
        return;
    }
    logger.trace("{} processing fetched [{}] results", shardId, type);
    if (responses != null) {
        for (T response : responses) {
            NodeEntry<T> nodeEntry = cache.get(response.getNode().getId());
            if (nodeEntry != null) {
                if (nodeEntry.getFetchingRound() != fetchingRound) {
                    assert nodeEntry.getFetchingRound() > fetchingRound : "node entries only replaced by newer rounds";
                    logger.trace("{} received response for [{}] from node {} for an older fetching round (expected: {} but was: {})", shardId, nodeEntry.getNodeId(), type, nodeEntry.getFetchingRound(), fetchingRound);
                } else if (nodeEntry.isFailed()) {
                    logger.trace("{} node {} has failed for [{}] (failure [{}])", shardId, nodeEntry.getNodeId(), type, nodeEntry.getFailure());
                } else {
                    // if the entry is there, for the right fetching round and not marked as failed already, process it
                    logger.trace("{} marking {} as done for [{}], result is [{}]", shardId, nodeEntry.getNodeId(), type, response);
                    nodeEntry.doneFetching(response);
                }
            }
        }
    }
    if (failures != null) {
        for (FailedNodeException failure : failures) {
            logger.trace("{} processing failure {} for [{}]", shardId, failure, type);
            NodeEntry<T> nodeEntry = cache.get(failure.nodeId());
            if (nodeEntry != null) {
                if (nodeEntry.getFetchingRound() != fetchingRound) {
                    assert nodeEntry.getFetchingRound() > fetchingRound : "node entries only replaced by newer rounds";
                    logger.trace("{} received failure for [{}] from node {} for an older fetching round (expected: {} but was: {})", shardId, nodeEntry.getNodeId(), type, nodeEntry.getFetchingRound(), fetchingRound);
                } else if (nodeEntry.isFailed() == false) {
                    // if the entry is there, for the right fetching round and not marked as failed already, process it
                    Throwable unwrappedCause = SQLExceptions.unwrap(failure.getCause());
                    // if the request got rejected or timed out, we need to try it again next time...
                    if (unwrappedCause instanceof EsRejectedExecutionException || unwrappedCause instanceof ReceiveTimeoutTransportException || unwrappedCause instanceof ElasticsearchTimeoutException) {
                        nodeEntry.restartFetching();
                    } else {
                        logger.warn(() -> new ParameterizedMessage("{}: failed to list shard for {} on node [{}]", shardId, type, failure.nodeId()), failure);
                        nodeEntry.doneFetching(failure.getCause());
                    }
                }
            }
        }
    }
    reroute(shardId, "post_response");
}
Also used : ReceiveTimeoutTransportException(org.elasticsearch.transport.ReceiveTimeoutTransportException) ElasticsearchTimeoutException(org.elasticsearch.ElasticsearchTimeoutException) FailedNodeException(org.elasticsearch.action.FailedNodeException) ParameterizedMessage(org.apache.logging.log4j.message.ParameterizedMessage) EsRejectedExecutionException(org.elasticsearch.common.util.concurrent.EsRejectedExecutionException)

Example 22 with ElasticsearchTimeoutException

use of org.elasticsearch.ElasticsearchTimeoutException in project crate by crate.

the class SQLIntegrationTestCase method execute.

/**
 * Execute an SQL Statement on a random node of the cluster
 *
 * @param stmt the SQL Statement
 * @param args the arguments to replace placeholders ("?") in the statement
 * @return the SQLResponse
 */
public SQLResponse execute(String stmt, Object[] args) {
    try {
        SQLResponse response = sqlExecutor.exec(new TestExecutionConfig(isJdbcEnabled(), isHashJoinEnabled()), stmt, args);
        this.response = response;
        return response;
    } catch (ElasticsearchTimeoutException e) {
        LOGGER.error("Timeout on SQL statement: {} {}", stmt, e);
        dumpActiveTasks();
        throw e;
    }
}
Also used : ElasticsearchTimeoutException(org.elasticsearch.ElasticsearchTimeoutException) TestExecutionConfig(io.crate.testing.TestExecutionConfig) SQLResponse(io.crate.testing.SQLResponse)

Aggregations

ElasticsearchTimeoutException (org.elasticsearch.ElasticsearchTimeoutException)22 ReceiveTimeoutTransportException (org.elasticsearch.transport.ReceiveTimeoutTransportException)11 IOException (java.io.IOException)10 NoNodeAvailableException (org.elasticsearch.client.transport.NoNodeAvailableException)10 NodeClosedException (org.elasticsearch.node.NodeClosedException)8 FlowFile (org.apache.nifi.flowfile.FlowFile)5 ComponentLog (org.apache.nifi.logging.ComponentLog)5 ProcessException (org.apache.nifi.processor.exception.ProcessException)5 Test (org.junit.Test)5 TimeValue (io.crate.common.unit.TimeValue)4 Charset (java.nio.charset.Charset)4 ClusterState (org.elasticsearch.cluster.ClusterState)4 ClusterStateObserver (org.elasticsearch.cluster.ClusterStateObserver)4 HashMap (java.util.HashMap)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 ElasticsearchParseException (org.elasticsearch.ElasticsearchParseException)3 BulkResponse (org.elasticsearch.action.bulk.BulkResponse)3 Matchers.anyString (org.mockito.Matchers.anyString)3 InputStream (java.io.InputStream)2 OutputStream (java.io.OutputStream)2