Search in sources :

Example 6 with Delayed

use of java.util.concurrent.Delayed in project otter by alibaba.

the class DeadNodeListener method processChanged.

public synchronized void processChanged(List<Long> nodes) {
    Set<Long> deadNodes = new HashSet<Long>();
    for (Long node : currentNodes) {
        if (!nodes.contains(node)) {
            deadNodes.add(node);
        }
    }
    // 切换引用,需设置为volatile保证线程安全&可见性
    currentNodes = nodes;
    // 处理下dead node
    if (deadNodes.size() > 0) {
        for (Long nid : deadNodes) {
            Delayed delayed = new DeadNodeDelayed(nid, checkTime);
            if (!queue.contains(delayed)) {
                // 不重复添加
                queue.add(new DeadNodeDelayed(nid, checkTime));
            }
        }
    }
}
Also used : Delayed(java.util.concurrent.Delayed) HashSet(java.util.HashSet)

Aggregations

Delayed (java.util.concurrent.Delayed)6 TimeUnit (java.util.concurrent.TimeUnit)3 ScheduledFuture (java.util.concurrent.ScheduledFuture)2 ThreadPool (org.elasticsearch.threadpool.ThreadPool)2 JRTServerConfigRequest (com.yahoo.vespa.config.protocol.JRTServerConfigRequest)1 TimeValue (io.crate.common.unit.TimeValue)1 IOException (java.io.IOException)1 Method (java.lang.reflect.Method)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 Callable (java.util.concurrent.Callable)1 DelayQueue (java.util.concurrent.DelayQueue)1 ExecutionException (java.util.concurrent.ExecutionException)1 Future (java.util.concurrent.Future)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 TimeoutException (java.util.concurrent.TimeoutException)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 AssertionFailedError (junit.framework.AssertionFailedError)1 TimeValue (org.elasticsearch.common.unit.TimeValue)1 AbstractRunnable (org.elasticsearch.common.util.concurrent.AbstractRunnable)1