use of org.voltdb.probe.MeshProber.Determination in project voltdb by VoltDB.
the class TestHostMessenger method testMultiHostProbedCreate.
@Test
public void testMultiHostProbedCreate() throws Exception {
MeshProber.Builder jc = MeshProber.builder().coordinators(coordinators(3)).startAction(StartAction.PROBE).nodeState(NodeState.INITIALIZING).bare(true);
HostMessenger hm1 = createHostMessenger(0, jc.build(), true);
HostMessenger hm2 = createHostMessenger(1, jc.build(), false);
HostMessenger hm3 = createHostMessenger(2, jc.build(), false);
final AtomicReference<Exception> exception = new AtomicReference<Exception>();
HostMessengerThread hm2Start = new HostMessengerThread(hm2, exception);
HostMessengerThread hm3Start = new HostMessengerThread(hm3, exception);
hm2Start.start();
hm3Start.start();
hm2Start.join();
hm3Start.join();
if (exception.get() != null) {
fail(exception.get().toString());
}
Determination dtm = prober(hm1).waitForDetermination();
assertEquals(StartAction.CREATE, dtm.startAction);
assertEquals(3, dtm.hostCount);
assertEquals(dtm, prober(hm2).waitForDetermination());
assertEquals(dtm, prober(hm3).waitForDetermination());
List<String> root1 = hm1.getZK().getChildren("/", false);
List<String> root2 = hm2.getZK().getChildren("/", false);
List<String> root3 = hm3.getZK().getChildren("/", false);
assertTrue(root1.equals(root2));
assertTrue(root2.equals(root3));
List<String> hostids1 = hm1.getZK().getChildren(CoreZK.hostids, false);
List<String> hostids2 = hm2.getZK().getChildren(CoreZK.hostids, false);
List<String> hostids3 = hm3.getZK().getChildren(CoreZK.hostids, false);
assertTrue(hostids1.equals(hostids2));
assertTrue(hostids2.equals(hostids3));
}
use of org.voltdb.probe.MeshProber.Determination in project voltdb by VoltDB.
the class TestHostMessenger method testTwoProbedConcuncurrentRejoins.
@Test
public void testTwoProbedConcuncurrentRejoins() throws Exception {
NodeStateRef hmns1 = new NodeStateRef(NodeState.INITIALIZING);
MeshProber.Builder jcb = MeshProber.builder().coordinators(coordinators(2)).hostCount(5).startAction(StartAction.PROBE).nodeStateSupplier(hmns1).kfactor(2).paused(false).bare(true);
HostMessenger hm1 = createHostMessenger(0, jcb.build(), false);
HostMessenger hm2 = createHostMessenger(1, jcb.build(), false);
HostMessenger hm3 = createHostMessenger(2, jcb.build(), false);
HostMessenger hm4 = createHostMessenger(3, jcb.build(), false);
HostMessenger hm5 = createHostMessenger(4, jcb.build(), false);
final AtomicReference<Exception> exception = new AtomicReference<Exception>();
HostMessengerThread hm1Start = new HostMessengerThread(hm1, exception);
HostMessengerThread hm2Start = new HostMessengerThread(hm2, exception);
HostMessengerThread hm3Start = new HostMessengerThread(hm3, exception);
HostMessengerThread hm4Start = new HostMessengerThread(hm4, exception);
HostMessengerThread hm5Start = new HostMessengerThread(hm5, exception);
hm1Start.start();
hm2Start.start();
hm3Start.start();
hm4Start.start();
hm5Start.start();
hm1Start.join();
hm2Start.join();
hm3Start.join();
hm4Start.join();
hm5Start.join();
if (exception.get() != null) {
fail(exception.get().toString());
}
Determination dtm = prober(hm1).waitForDetermination();
assertEquals(StartAction.CREATE, dtm.startAction);
assertEquals(5, dtm.hostCount);
assertEquals(dtm, prober(hm2).waitForDetermination());
assertEquals(dtm, prober(hm3).waitForDetermination());
assertEquals(dtm, prober(hm4).waitForDetermination());
assertEquals(dtm, prober(hm5).waitForDetermination());
assertTrue(hmns1.compareAndSet(NodeState.INITIALIZING, NodeState.UP));
hm1.shutdown();
hm3.shutdown();
jcb.nodeState(NodeState.INITIALIZING).bare(true);
HostMessenger hm6 = createHostMessenger(0, jcb.build(), false);
HostMessenger hm7 = createHostMessenger(2, jcb.build(), false);
HostMessengerThread hm6Start = new HostMessengerThread(hm6, exception);
HostMessengerThread hm7Start = new HostMessengerThread(hm7, exception);
hm6Start.start();
hm7Start.start();
Thread.sleep(2_000);
CoreZK.removeRejoinNodeIndicatorForHost(hm2.getZK(), 5);
hm6Start.join();
hm7Start.join();
if (exception.get() != null) {
fail(exception.get().toString());
}
dtm = prober(hm6).waitForDetermination();
assertEquals(StartAction.LIVE_REJOIN, dtm.startAction);
assertEquals(5, dtm.hostCount);
assertEquals(dtm, prober(hm6).waitForDetermination());
assertTrue(Math.max(hm6.getHostId(), hm7.getHostId()) > 6);
List<String> root1 = hm6.getZK().getChildren("/", false);
List<String> root2 = hm2.getZK().getChildren("/", false);
List<String> root3 = hm7.getZK().getChildren("/", false);
List<String> root4 = hm4.getZK().getChildren("/", false);
List<String> root5 = hm5.getZK().getChildren("/", false);
assertTrue(root1.equals(root2));
assertTrue(root2.equals(root3));
assertTrue(root3.equals(root4));
assertTrue(root4.equals(root5));
List<String> hostids1 = hm6.getZK().getChildren(CoreZK.hostids, false);
List<String> hostids2 = hm2.getZK().getChildren(CoreZK.hostids, false);
List<String> hostids3 = hm7.getZK().getChildren(CoreZK.hostids, false);
List<String> hostids4 = hm4.getZK().getChildren(CoreZK.hostids, false);
List<String> hostids5 = hm5.getZK().getChildren(CoreZK.hostids, false);
assertTrue(hostids1.equals(hostids2));
assertTrue(hostids2.equals(hostids3));
assertTrue(hostids3.equals(hostids4));
assertTrue(hostids4.equals(hostids5));
}
use of org.voltdb.probe.MeshProber.Determination in project voltdb by VoltDB.
the class TestHostMessenger method testProbedRejoinForNonLeader.
@Test
public void testProbedRejoinForNonLeader() throws Exception {
NodeStateRef upNodesState = new NodeStateRef(NodeState.INITIALIZING);
MeshProber.Builder jcb = MeshProber.builder().coordinators(coordinators(2)).hostCount(3).startAction(StartAction.PROBE).nodeStateSupplier(upNodesState).kfactor(1).paused(false).bare(true);
HostMessenger hm1 = createHostMessenger(0, jcb.build(), false);
HostMessenger hm2 = createHostMessenger(1, jcb.build(), false);
HostMessenger hm3 = createHostMessenger(2, jcb.build(), false);
final AtomicReference<Exception> exception = new AtomicReference<Exception>();
HostMessengerThread hm1Start = new HostMessengerThread(hm1, exception);
HostMessengerThread hm3Start = new HostMessengerThread(hm3, exception);
hm1Start.start();
hm3Start.start();
hm2.start();
hm1Start.join();
hm3Start.join();
if (exception.get() != null) {
fail(exception.get().toString());
}
Determination dtm = prober(hm1).waitForDetermination();
assertEquals(StartAction.CREATE, dtm.startAction);
assertEquals(3, dtm.hostCount);
assertEquals(dtm, prober(hm2).waitForDetermination());
assertEquals(dtm, prober(hm3).waitForDetermination());
assertTrue(upNodesState.compareAndSet(NodeState.INITIALIZING, NodeState.UP));
hm2.shutdown();
jcb.nodeState(NodeState.INITIALIZING).bare(false).paused(true);
hm2 = createHostMessenger(1, jcb.build(), true);
dtm = prober(hm2).waitForDetermination();
assertEquals(StartAction.LIVE_REJOIN, dtm.startAction);
assertEquals(3, dtm.hostCount);
assertFalse(hm2.isPaused());
List<String> root1 = hm1.getZK().getChildren("/", false);
List<String> root2 = hm2.getZK().getChildren("/", false);
List<String> root3 = hm3.getZK().getChildren("/", false);
assertTrue(root1.equals(root2));
assertTrue(root2.equals(root3));
List<String> hostids1 = hm1.getZK().getChildren(CoreZK.hostids, false);
List<String> hostids2 = hm2.getZK().getChildren(CoreZK.hostids, false);
List<String> hostids3 = hm3.getZK().getChildren(CoreZK.hostids, false);
assertTrue(hostids1.equals(hostids2));
assertTrue(hostids2.equals(hostids3));
}
use of org.voltdb.probe.MeshProber.Determination in project voltdb by VoltDB.
the class TestHostMessenger method testNotEnoughTerminusPropagation.
@Test
public void testNotEnoughTerminusPropagation() throws Exception {
MeshProber.Builder jcb = MeshProber.builder().coordinators(coordinators(3)).startAction(StartAction.PROBE).nodeState(NodeState.INITIALIZING).bare(true).kfactor(1);
MeshProber without = jcb.build();
MeshProber with = jcb.terminusNonce("nonce-uno").build();
HostMessenger hm1 = createHostMessenger(0, jcb.prober(without).build(), true);
HostMessenger hm2 = createHostMessenger(1, with, false);
HostMessenger hm3 = createHostMessenger(2, jcb.prober(without).build(), false);
final AtomicReference<Exception> exception = new AtomicReference<Exception>();
HostMessengerThread hm2Start = new HostMessengerThread(hm2, exception);
HostMessengerThread hm3Start = new HostMessengerThread(hm3, exception);
hm2Start.start();
hm3Start.start();
hm2Start.join();
hm3Start.join();
if (exception.get() != null) {
fail(exception.get().toString());
}
Determination dtm = prober(hm1).waitForDetermination();
assertNull(dtm.terminusNonce);
assertEquals(3, dtm.hostCount);
assertEquals(dtm, prober(hm2).waitForDetermination());
assertEquals(dtm, prober(hm3).waitForDetermination());
List<String> root1 = hm1.getZK().getChildren("/", false);
List<String> root2 = hm2.getZK().getChildren("/", false);
List<String> root3 = hm3.getZK().getChildren("/", false);
assertTrue(root1.equals(root2));
assertTrue(root2.equals(root3));
List<String> hostids1 = hm1.getZK().getChildren(CoreZK.hostids, false);
List<String> hostids2 = hm2.getZK().getChildren(CoreZK.hostids, false);
List<String> hostids3 = hm3.getZK().getChildren(CoreZK.hostids, false);
assertTrue(hostids1.equals(hostids2));
assertTrue(hostids2.equals(hostids3));
}
use of org.voltdb.probe.MeshProber.Determination in project voltdb by VoltDB.
the class TestHostMessenger method testProbedRejoinForPreviousLeader.
@Test
public void testProbedRejoinForPreviousLeader() throws Exception {
NodeStateRef upNodesState = new NodeStateRef(NodeState.INITIALIZING);
MeshProber.Builder jcb = MeshProber.builder().coordinators(coordinators(2)).hostCount(3).startAction(StartAction.PROBE).nodeStateSupplier(upNodesState).kfactor(1).paused(false).bare(true);
HostMessenger hm1 = createHostMessenger(0, jcb.build(), true);
HostMessenger hm2 = createHostMessenger(1, jcb.build(), false);
HostMessenger hm3 = createHostMessenger(2, jcb.build(), false);
final AtomicReference<Exception> exception = new AtomicReference<Exception>();
HostMessengerThread hm2Start = new HostMessengerThread(hm2, exception);
HostMessengerThread hm3Start = new HostMessengerThread(hm3, exception);
hm2Start.start();
hm3Start.start();
hm2Start.join();
hm3Start.join();
if (exception.get() != null) {
fail(exception.get().toString());
}
Determination dtm = prober(hm1).waitForDetermination();
assertEquals(StartAction.CREATE, dtm.startAction);
assertEquals(3, dtm.hostCount);
assertEquals(dtm, prober(hm2).waitForDetermination());
assertEquals(dtm, prober(hm3).waitForDetermination());
assertTrue(upNodesState.compareAndSet(NodeState.INITIALIZING, NodeState.UP));
hm1.shutdown();
// rejoining node cannot propagate its safe mode or paused demand
jcb.nodeState(NodeState.INITIALIZING).bare(false).paused(true).safeMode(true);
hm1 = createHostMessenger(0, jcb.build(), true);
dtm = prober(hm1).waitForDetermination();
assertEquals(StartAction.LIVE_REJOIN, dtm.startAction);
assertEquals(3, dtm.hostCount);
assertFalse(hm1.isPaused());
List<String> root1 = hm1.getZK().getChildren("/", false);
List<String> root2 = hm2.getZK().getChildren("/", false);
List<String> root3 = hm3.getZK().getChildren("/", false);
assertTrue(root1.equals(root2));
assertTrue(root2.equals(root3));
List<String> hostids1 = hm1.getZK().getChildren(CoreZK.hostids, false);
List<String> hostids2 = hm2.getZK().getChildren(CoreZK.hostids, false);
List<String> hostids3 = hm3.getZK().getChildren(CoreZK.hostids, false);
assertTrue(hostids1.equals(hostids2));
assertTrue(hostids2.equals(hostids3));
}
Aggregations