use of org.voltdb.probe.MeshProber in project voltdb by VoltDB.
the class TestHostMessenger method testProbedConfigMismatchCrash.
@Test
public void testProbedConfigMismatchCrash() 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.configHash(new UUID(-2L, -2L)).build();
assertNotSame(jc1.getConfigHash(), jc2.getConfigHash());
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("deployment options that do not match"));
}
}
use of org.voltdb.probe.MeshProber in project voltdb by VoltDB.
the class TestHostMessenger method testMultipleMismatchesCrash.
@Test
public void testMultipleMismatchesCrash() 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).configHash(new UUID(-2L, -2L)).hostCount(4).build();
assertNotSame(jc1.getStartAction(), jc2.getStartAction());
assertNotSame(jc1.getHostCount(), jc2.getHostCount());
assertNotSame(jc1.getConfigHash(), jc2.getConfigHash());
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"));
assertTrue(VoltDB.crashMessage.contains("Mismatched host count"));
assertTrue(VoltDB.crashMessage.contains("deployment options that do not match"));
}
}
use of org.voltdb.probe.MeshProber in project voltdb by VoltDB.
the class TestHostMessenger method testProbedTerminusNonceMismatchCrash.
@Test
public void testProbedTerminusNonceMismatchCrash() 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).terminusNonce("uno");
MeshProber jc1 = jcb.build();
MeshProber jc2 = jcb.terminusNonce("due").build();
assertNotSame(jc1.getTerminusNonce(), jc2.getTerminusNonce());
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("have different startup snapshots nonces"));
}
}
use of org.voltdb.probe.MeshProber 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());
}
use of org.voltdb.probe.MeshProber in project voltdb by VoltDB.
the class RealVoltDB method buildClusterMesh.
/**
* Start the voltcore HostMessenger. This joins the node
* to the existing cluster. In the non rejoin case, this
* function will return when the mesh is complete. If
* rejoining, it will return when the node and agreement
* site are synched to the existing cluster.
*/
MeshProber.Determination buildClusterMesh(ReadDeploymentResults readDepl) {
final boolean bareAtStartup = m_config.m_forceVoltdbCreate || pathsWithRecoverableArtifacts(readDepl.deployment).isEmpty();
setBare(bareAtStartup);
final Supplier<Integer> hostCountSupplier = new Supplier<Integer>() {
@Override
public Integer get() {
return m_clusterSettings.get().hostcount();
}
};
ClusterType clusterType = readDepl.deployment.getCluster();
MeshProber criteria = MeshProber.builder().coordinators(m_config.m_coordinators).versionChecker(m_versionChecker).enterprise(m_config.m_isEnterprise).startAction(m_config.m_startAction).bare(bareAtStartup).configHash(CatalogUtil.makeDeploymentHashForConfig(readDepl.deploymentBytes)).hostCountSupplier(hostCountSupplier).kfactor(clusterType.getKfactor()).paused(m_config.m_isPaused).nodeStateSupplier(m_statusTracker.getNodeStateSupplier()).addAllowed(m_config.m_enableAdd).safeMode(m_config.m_safeMode).terminusNonce(getTerminusNonce()).missingHostCount(m_config.m_missingHostCount).build();
HostAndPort hostAndPort = criteria.getLeader();
String hostname = hostAndPort.getHostText();
int port = hostAndPort.getPort();
org.voltcore.messaging.HostMessenger.Config hmconfig;
hmconfig = new org.voltcore.messaging.HostMessenger.Config(hostname, port);
if (m_config.m_placementGroup != null) {
hmconfig.group = m_config.m_placementGroup;
}
hmconfig.internalPort = m_config.m_internalPort;
hmconfig.internalInterface = m_config.m_internalInterface;
hmconfig.zkInterface = m_config.m_zkInterface;
hmconfig.deadHostTimeout = m_config.m_deadHostTimeoutMS;
hmconfig.factory = new VoltDbMessageFactory();
hmconfig.coreBindIds = m_config.m_networkCoreBindings;
hmconfig.acceptor = criteria;
hmconfig.localSitesCount = m_config.m_sitesperhost;
m_messenger = new org.voltcore.messaging.HostMessenger(hmconfig, this);
hostLog.info(String.format("Beginning inter-node communication on port %d.", m_config.m_internalPort));
try {
m_messenger.start();
} catch (Exception e) {
VoltDB.crashLocalVoltDB(e.getMessage(), true, e);
}
VoltZK.createPersistentZKNodes(m_messenger.getZK());
// Use the host messenger's hostId.
m_myHostId = m_messenger.getHostId();
hostLog.info(String.format("Host id of this node is: %d", m_myHostId));
consoleLog.info(String.format("Host id of this node is: %d", m_myHostId));
MeshProber.Determination determination = criteria.waitForDetermination();
// paused is determined in the mesh formation exchanged
if (determination.paused) {
m_messenger.pause();
} else {
m_messenger.unpause();
}
// leader and we're rejoining, this is clearly bad.
if (m_myHostId == 0 && determination.startAction.doesJoin()) {
VoltDB.crashLocalVoltDB("Unable to rejoin a node to itself. " + "Please check your command line and start action and try again.", false, null);
}
// load or store settings form/to zookeeper
if (determination.startAction.doesJoin()) {
m_clusterSettings.load(m_messenger.getZK());
m_clusterSettings.get().store();
} else if (m_myHostId == 0) {
m_clusterSettings.store(m_messenger.getZK());
}
m_clusterCreateTime = m_messenger.getInstanceId().getTimestamp();
return determination;
}
Aggregations