Search in sources :

Example 6 with Determination

use of org.voltdb.probe.MeshProber.Determination in project voltdb by VoltDB.

the class TestHostMessenger method testMultiHostProbedRecover.

@Test
public void testMultiHostProbedRecover() throws Exception {
    MeshProber.Builder jc = MeshProber.builder().coordinators(coordinators(3)).startAction(StartAction.PROBE).nodeState(NodeState.INITIALIZING).bare(false);
    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.RECOVER, 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));
}
Also used : AtomicReference(java.util.concurrent.atomic.AtomicReference) MeshProber(org.voltdb.probe.MeshProber) Determination(org.voltdb.probe.MeshProber.Determination) Test(org.junit.Test)

Example 7 with Determination

use of org.voltdb.probe.MeshProber.Determination in project voltdb by VoltDB.

the class TestHostMessenger method testSingleProbedCreateHost.

@Test
public void testSingleProbedCreateHost() throws Exception {
    MeshProber jc = MeshProber.builder().coordinators(coordinators(1)).startAction(StartAction.PROBE).nodeState(NodeState.INITIALIZING).bare(true).build();
    HostMessenger hm = createHostMessenger(0, jc, true);
    Determination dtm = prober(hm).waitForDetermination();
    assertEquals(StartAction.CREATE, dtm.startAction);
    assertEquals(1, dtm.hostCount);
    Mailbox m1 = hm.createMailbox();
    SiteMailbox sm = new SiteMailbox(hm, (-2L << 32));
    hm.createMailbox(sm.getHSId(), sm);
    sm.send(m1.getHSId(), new LocalObjectMessage(null));
    m1.send(sm.getHSId(), new LocalObjectMessage(null));
    LocalObjectMessage lom = (LocalObjectMessage) m1.recv();
    assertEquals(lom.m_sourceHSId, sm.getHSId());
    lom = (LocalObjectMessage) sm.recv();
    assertEquals(lom.m_sourceHSId, m1.getHSId());
}
Also used : MeshProber(org.voltdb.probe.MeshProber) Determination(org.voltdb.probe.MeshProber.Determination) Test(org.junit.Test)

Example 8 with Determination

use of org.voltdb.probe.MeshProber.Determination in project voltdb by VoltDB.

the class TestHostMessenger method testProbedRejoinWithMismatchedStartAction.

@Test
public void testProbedRejoinWithMismatchedStartAction() throws Exception {
    VoltDB.ignoreCrash = true;
    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 hm2Start = new HostMessengerThread(hm2, exception);
    HostMessengerThread hm3Start = new HostMessengerThread(hm3, exception);
    hm1Start.start();
    hm2Start.start();
    hm3Start.start();
    hm1Start.join();
    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));
    hm2.shutdown();
    jcb.nodeState(NodeState.INITIALIZING).startAction(StartAction.REJOIN).bare(true);
    HostMessenger hm4 = createHostMessenger(1, jcb.build(), false);
    try {
        hm4.start();
        fail("did not crash on mismatched start actions");
    } catch (AssertionError pass) {
        assertTrue(VoltDB.wasCrashCalled);
        assertTrue(VoltDB.crashMessage.contains("use init and start to join this cluster"));
    }
}
Also used : AtomicReference(java.util.concurrent.atomic.AtomicReference) MeshProber(org.voltdb.probe.MeshProber) Determination(org.voltdb.probe.MeshProber.Determination) Test(org.junit.Test)

Example 9 with Determination

use of org.voltdb.probe.MeshProber.Determination in project voltdb by VoltDB.

the class TestHostMessenger method testProbedJoinOnWholeCluster.

@Test
public void testProbedJoinOnWholeCluster() 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 hm2Start = new HostMessengerThread(hm2, exception);
    HostMessengerThread hm3Start = new HostMessengerThread(hm3, exception);
    hm1Start.start();
    hm2Start.start();
    hm3Start.start();
    hm1Start.join();
    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));
    jcb.nodeState(NodeState.INITIALIZING).bare(true).addAllowed(true).hostCount(5);
    HostMessenger hm4 = createHostMessenger(3, jcb.build(), false);
    hm4.start();
    dtm = prober(hm4).waitForDetermination();
    assertEquals(StartAction.JOIN, dtm.startAction);
    assertEquals(5, dtm.hostCount);
    List<String> root1 = hm1.getZK().getChildren("/", false);
    List<String> root2 = hm2.getZK().getChildren("/", false);
    List<String> root3 = hm3.getZK().getChildren("/", false);
    List<String> root4 = hm4.getZK().getChildren("/", false);
    assertTrue(root1.equals(root2));
    assertTrue(root2.equals(root3));
    assertTrue(root3.equals(root4));
    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);
    List<String> hostids4 = hm4.getZK().getChildren(CoreZK.hostids, false);
    assertTrue(hostids1.equals(hostids2));
    assertTrue(hostids2.equals(hostids3));
    assertTrue(hostids3.equals(hostids4));
}
Also used : AtomicReference(java.util.concurrent.atomic.AtomicReference) MeshProber(org.voltdb.probe.MeshProber) Determination(org.voltdb.probe.MeshProber.Determination) Test(org.junit.Test)

Example 10 with Determination

use of org.voltdb.probe.MeshProber.Determination in project voltdb by VoltDB.

the class TestHostMessenger method testSingleProbedRecoverHost.

@Test
public void testSingleProbedRecoverHost() throws Exception {
    MeshProber jc = MeshProber.builder().coordinators(coordinators(1)).startAction(StartAction.PROBE).nodeState(NodeState.INITIALIZING).bare(false).build();
    HostMessenger hm = createHostMessenger(0, jc, true);
    Determination dtm = prober(hm).waitForDetermination();
    assertEquals(StartAction.RECOVER, dtm.startAction);
    assertEquals(1, dtm.hostCount);
    Mailbox m1 = hm.createMailbox();
    SiteMailbox sm = new SiteMailbox(hm, (-2L << 32));
    hm.createMailbox(sm.getHSId(), sm);
    sm.send(m1.getHSId(), new LocalObjectMessage(null));
    m1.send(sm.getHSId(), new LocalObjectMessage(null));
    LocalObjectMessage lom = (LocalObjectMessage) m1.recv();
    assertEquals(lom.m_sourceHSId, sm.getHSId());
    lom = (LocalObjectMessage) sm.recv();
    assertEquals(lom.m_sourceHSId, m1.getHSId());
}
Also used : MeshProber(org.voltdb.probe.MeshProber) Determination(org.voltdb.probe.MeshProber.Determination) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)16 MeshProber (org.voltdb.probe.MeshProber)16 Determination (org.voltdb.probe.MeshProber.Determination)16 AtomicReference (java.util.concurrent.atomic.AtomicReference)14