Search in sources :

Example 1 with MeshProber

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

the class TestHostMessenger method testProbedMeshMismatchCrash.

@Test
public void testProbedMeshMismatchCrash() throws Exception {
    VoltDB.ignoreCrash = true;
    MeshProber.Builder jcb = MeshProber.builder().coordinators(coordinators(2)).hostCount(3).startAction(StartAction.PROBE).nodeState(NodeState.INITIALIZING).kfactor(1).paused(false).bare(true);
    MeshProber jc1 = jcb.build();
    MeshProber jc2 = jcb.coordinators(coordinators(3)).build();
    assertNotSame(jc1.getMeshHash(), jc2.getMeshHash());
    HostMessenger hm1 = createHostMessenger(0, jcb.prober(jc1).build(), false);
    HostMessenger hm2 = createHostMessenger(1, jcb.prober(jc1).build(), false);
    HostMessenger hm3 = createHostMessenger(2, jcb.prober(jc2).build(), false);
    final AtomicReference<Exception> exception = new AtomicReference<Exception>();
    HostMessengerThread hm1Start = new HostMessengerThread(hm1, exception);
    HostMessengerThread hm2Start = new HostMessengerThread(hm2, exception);
    hm1Start.start();
    hm2Start.start();
    hm1Start.join();
    hm2Start.join();
    if (exception.get() != null) {
        fail(exception.get().toString());
    }
    try {
        hm3.start();
        fail("did not crash on whole cluster rejoin attempt");
    } catch (AssertionError pass) {
        assertTrue(VoltDB.wasCrashCalled);
        assertTrue(VoltDB.crashMessage.contains("Mismatched list of hosts"));
    }
}
Also used : AtomicReference(java.util.concurrent.atomic.AtomicReference) MeshProber(org.voltdb.probe.MeshProber) Test(org.junit.Test)

Example 2 with MeshProber

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

the class TestHostMessenger method testProbedJoinerAcceptorMismatchCrash.

@Test
public void testProbedJoinerAcceptorMismatchCrash() throws Exception {
    VoltDB.ignoreCrash = true;
    MeshProber.Builder jcb = MeshProber.builder().coordinators(coordinators(2)).hostCount(3).startAction(StartAction.PROBE).nodeState(NodeState.INITIALIZING).kfactor(1).paused(false).bare(true);
    MeshProber jc1 = jcb.build();
    JoinAcceptor jc2 = new JoinAcceptor() {

        @Override
        public void detract(Set<Integer> hostIds) {
        }

        @Override
        public void detract(int hostId) {
        }

        @Override
        public void accrue(Map<Integer, JSONObject> jos) {
        }

        @Override
        public void accrue(int hostId, JSONObject jo) {
        }
    };
    HostMessenger hm1 = createHostMessenger(0, jcb.prober(jc1).build(), false);
    HostMessenger hm2 = createHostMessenger(1, jcb.prober(jc1).build(), false);
    HostMessenger hm3 = createHostMessenger(2, jc2, false);
    final AtomicReference<Exception> exception = new AtomicReference<Exception>();
    HostMessengerThread hm1Start = new HostMessengerThread(hm1, exception);
    HostMessengerThread hm2Start = new HostMessengerThread(hm2, exception);
    hm1Start.start();
    hm2Start.start();
    hm1Start.join();
    hm2Start.join();
    if (exception.get() != null) {
        fail(exception.get().toString());
    }
    try {
        hm3.start();
        fail("did not crash on whole cluster rejoin attempt");
    } catch (AssertionError pass) {
        assertTrue(VoltDB.wasCrashCalled);
        assertTrue(VoltDB.crashMessage.contains("is incompatible with this node verion"));
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) JSONObject(org.json_voltpatches.JSONObject) AtomicReference(java.util.concurrent.atomic.AtomicReference) MeshProber(org.voltdb.probe.MeshProber) Map(java.util.Map) Test(org.junit.Test)

Example 3 with MeshProber

use of org.voltdb.probe.MeshProber 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));
}
Also used : AtomicReference(java.util.concurrent.atomic.AtomicReference) MeshProber(org.voltdb.probe.MeshProber) Determination(org.voltdb.probe.MeshProber.Determination) Test(org.junit.Test)

Example 4 with MeshProber

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

the class TestHostMessenger method testProbedHostCountMismatchCrash.

@Test
public void testProbedHostCountMismatchCrash() throws Exception {
    VoltDB.ignoreCrash = true;
    MeshProber.Builder jcb = MeshProber.builder().coordinators(coordinators(2)).hostCount(3).startAction(StartAction.PROBE).nodeState(NodeState.INITIALIZING).kfactor(1).paused(false).bare(true);
    MeshProber jc1 = jcb.build();
    MeshProber jc2 = jcb.hostCount(4).build();
    assertNotSame(jc1.getHostCount(), jc2.getHostCount());
    HostMessenger hm1 = createHostMessenger(0, jcb.prober(jc1).build(), false);
    HostMessenger hm2 = createHostMessenger(1, jcb.prober(jc1).build(), false);
    HostMessenger hm3 = createHostMessenger(2, jcb.prober(jc2).build(), false);
    final AtomicReference<Exception> exception = new AtomicReference<Exception>();
    HostMessengerThread hm1Start = new HostMessengerThread(hm1, exception);
    HostMessengerThread hm2Start = new HostMessengerThread(hm2, exception);
    hm1Start.start();
    hm2Start.start();
    hm1Start.join();
    hm2Start.join();
    if (exception.get() != null) {
        fail(exception.get().toString());
    }
    try {
        hm3.start();
        fail("did not crash on whole cluster rejoin attempt");
    } catch (AssertionError pass) {
        assertTrue(VoltDB.wasCrashCalled);
        assertTrue(VoltDB.crashMessage.contains("Mismatched host count"));
    }
}
Also used : AtomicReference(java.util.concurrent.atomic.AtomicReference) MeshProber(org.voltdb.probe.MeshProber) Test(org.junit.Test)

Example 5 with MeshProber

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

the class TestHostMessenger method testStartActionMismatchCrash.

@Test
public void testStartActionMismatchCrash() throws Exception {
    VoltDB.ignoreCrash = true;
    MeshProber.Builder jcb = MeshProber.builder().coordinators(coordinators(2)).hostCount(3).startAction(StartAction.PROBE).nodeState(NodeState.INITIALIZING).kfactor(1).paused(false).bare(true);
    MeshProber jc1 = jcb.build();
    MeshProber jc2 = jcb.startAction(StartAction.CREATE).build();
    assertNotSame(jc1.getStartAction(), jc2.getStartAction());
    HostMessenger hm1 = createHostMessenger(0, jcb.prober(jc1).build(), false);
    HostMessenger hm2 = createHostMessenger(1, jcb.prober(jc1).build(), false);
    HostMessenger hm3 = createHostMessenger(2, jcb.prober(jc2).build(), false);
    final AtomicReference<Exception> exception = new AtomicReference<Exception>();
    HostMessengerThread hm1Start = new HostMessengerThread(hm1, exception);
    HostMessengerThread hm2Start = new HostMessengerThread(hm2, exception);
    hm1Start.start();
    hm2Start.start();
    hm1Start.join();
    hm2Start.join();
    if (exception.get() != null) {
        fail(exception.get().toString());
    }
    try {
        hm3.start();
        fail("did not crash on whole cluster rejoin attempt");
    } catch (AssertionError pass) {
        assertTrue(VoltDB.wasCrashCalled);
        assertTrue(VoltDB.crashMessage.contains("Start action CREATE does not match PROBE"));
    }
}
Also used : AtomicReference(java.util.concurrent.atomic.AtomicReference) MeshProber(org.voltdb.probe.MeshProber) Test(org.junit.Test)

Aggregations

MeshProber (org.voltdb.probe.MeshProber)16 Test (org.junit.Test)15 AtomicReference (java.util.concurrent.atomic.AtomicReference)13 Determination (org.voltdb.probe.MeshProber.Determination)7 UUID (java.util.UUID)2 Supplier (com.google_voltpatches.common.base.Supplier)1 HostAndPort (com.google_voltpatches.common.net.HostAndPort)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 SocketException (java.net.SocketException)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1 ExecutionException (java.util.concurrent.ExecutionException)1 KeeperException (org.apache.zookeeper_voltpatches.KeeperException)1 JSONException (org.json_voltpatches.JSONException)1 JSONObject (org.json_voltpatches.JSONObject)1 HostMessenger (org.voltcore.messaging.HostMessenger)1 ClusterType (org.voltdb.compiler.deploymentfile.ClusterType)1 VoltDbMessageFactory (org.voltdb.messaging.VoltDbMessageFactory)1