blob: ca7a46b2350efaafb064a96590011fadc2c44b6f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core;
import com.yahoo.vdslib.state.ClusterState;
import com.yahoo.vespa.clustercontroller.core.listeners.NodeAddedOrRemovedListener;
import com.yahoo.vespa.clustercontroller.core.listeners.NodeStateOrHostInfoChangeHandler;
public abstract class RemoteClusterControllerTask {
public static class Context {
public ContentCluster cluster;
public ClusterState currentState;
public MasterInterface masterInfo;
public NodeStateOrHostInfoChangeHandler nodeStateOrHostInfoChangeHandler;
public NodeAddedOrRemovedListener nodeAddedOrRemovedListener;
}
private final Object monitor = new Object();
private boolean completed = false;
public abstract void doRemoteFleetControllerTask(Context context);
public boolean isCompleted() {
synchronized (monitor) {
return completed;
}
}
/** This is called by the fleet controller. */
public void notifyCompleted() {
synchronized (monitor) {
completed = true;
monitor.notifyAll();
}
}
public void waitForCompletion() {
synchronized (monitor) {
while (!completed) {
try{
monitor.wait();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
}
}
|