use of io.vertx.core.spi.cluster.NodeListener in project vert.x by eclipse.
the class HAManager method init.
/**
* Initialize the ha manager, i.e register the node listener to propagates the node events and
* start the quorum timer. The quorum will be checked as well.
*/
void init() {
synchronized (haInfo) {
clusterMap.put(nodeID, haInfo.encode());
}
clusterManager.nodeListener(new NodeListener() {
@Override
public void nodeAdded(String nodeID) {
HAManager.this.nodeAdded(nodeID);
}
@Override
public void nodeLeft(String leftNodeID) {
HAManager.this.nodeLeft(leftNodeID);
}
});
quorumTimerID = vertx.setPeriodic(QUORUM_CHECK_PERIOD, tid -> checkHADeployments());
// Call check quorum to compute whether we have an initial quorum
synchronized (this) {
checkQuorum();
}
}
use of io.vertx.core.spi.cluster.NodeListener in project vert.x by eclipse.
the class VertxStartFailureTest method testHAManagerInitFailure.
@Test
public void testHAManagerInitFailure() throws Exception {
RuntimeException expected = new RuntimeException();
FakeClusterManager clusterManager = new FakeClusterManager() {
@Override
public void nodeListener(NodeListener listener) {
// Triggers HAManager init failure
throw expected;
}
};
VertxOptions options = new VertxOptions().setClusterManager(clusterManager).setHAEnabled(true);
Throwable failure = failStart(options);
assertSame(expected, failure);
}
Aggregations