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));
}
}
}
}
Aggregations