Search in sources :

Example 1 with ProcessClusterEventTimeoutException

use of org.elasticsearch.cluster.metadata.ProcessClusterEventTimeoutException in project elasticsearch by elastic.

the class ClusterService method onTimeout.

private void onTimeout(List<UpdateTask> updateTasks, String source, TimeValue timeout) {
    threadPool.generic().execute(() -> {
        final ArrayList<UpdateTask> toRemove = new ArrayList<>();
        for (UpdateTask task : updateTasks) {
            if (task.processed.getAndSet(true) == false) {
                logger.debug("cluster state update task [{}] timed out after [{}]", source, timeout);
                toRemove.add(task);
            }
        }
        if (toRemove.isEmpty() == false) {
            ClusterStateTaskExecutor<Object> clusterStateTaskExecutor = toRemove.get(0).executor;
            synchronized (updateTasksPerExecutor) {
                LinkedHashSet<UpdateTask> existingTasks = updateTasksPerExecutor.get(clusterStateTaskExecutor);
                if (existingTasks != null) {
                    existingTasks.removeAll(toRemove);
                    if (existingTasks.isEmpty()) {
                        updateTasksPerExecutor.remove(clusterStateTaskExecutor);
                    }
                }
            }
            for (UpdateTask task : toRemove) {
                task.listener.onFailure(source, new ProcessClusterEventTimeoutException(timeout, source));
            }
        }
    });
}
Also used : CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) ProcessClusterEventTimeoutException(org.elasticsearch.cluster.metadata.ProcessClusterEventTimeoutException)

Aggregations

ArrayList (java.util.ArrayList)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 ProcessClusterEventTimeoutException (org.elasticsearch.cluster.metadata.ProcessClusterEventTimeoutException)1