use of org.voltcore.messaging.FaultMessage in project voltdb by VoltDB.
the class TestMeshArbiter method testBasicScenario.
@Test
public void testBasicScenario() throws Exception {
Maker<SiteFailureMessage> siteOneSfm = a(SiteFailureMessage, with(sfmSurvivors, sfmSurvived(0, 2, 3)), with(sfmFailures, sfmFailed(1)), with(sfmSafeTxns, sfmSafe(0, 10, 1, 11, 2, 22, 3, 33)));
when(aide.getNewestSafeTransactionForInitiator(anyLong())).thenReturn(11L);
when(mbox.recvBlocking(any(Subject[].class), eq(5L))).thenReturn(make(siteOneSfm.but(with(sfmSource, 0L)))).thenReturn(make(siteOneSfm.but(with(sfmSource, 2L)))).thenReturn(make(siteOneSfm.but(with(sfmSource, 3L))));
Map<Long, Long> decision = arbiter.reconfigureOnFault(hsids, new FaultMessage(0, 1));
verify(mbox, times(2)).send(any(long[].class), argThat(siteFailureIs(sfmFailed(1), sfmSurvived(0, 2, 3))));
assertEquals(decision, ImmutableMap.<Long, Long>of(1L, 11L));
}
use of org.voltcore.messaging.FaultMessage in project voltdb by VoltDB.
the class TestMeshArbiter method testInterleavedFailures.
@Test
public void testInterleavedFailures() throws Exception {
Maker<SiteFailureMessage> siteOneSfm = a(SiteFailureMessage, with(sfmSurvivors, Longs.asList(0, 2, 3)), with(sfmFailures, sfmFailed(1)), with(sfmSafeTxns, sfmSafe(0, 10, 1, 11, 2, 22, 3, 33)));
Maker<SiteFailureMessage> siteTwoSfm = a(SiteFailureMessage, with(sfmSurvivors, Longs.asList(0, 3)), with(sfmFailures, sfmFailed(1, 2)), with(sfmSafeTxns, sfmSafe(0, 10, 1, 11, 2, 22, 3, 33)));
when(aide.getNewestSafeTransactionForInitiator(1L)).thenReturn(11L);
when(aide.getNewestSafeTransactionForInitiator(2L)).thenReturn(22L);
when(mbox.recvBlocking(any(Subject[].class), eq(5L))).thenReturn(make(siteOneSfm.but(with(sfmSource, 0L)))).thenReturn(new FaultMessage(0, 2L));
Map<Long, Long> decision = arbiter.reconfigureOnFault(hsids, new FaultMessage(0, 1));
verify(mbox, times(1)).deliverFront(any(VoltMessage.class));
verify(mbox, times(1)).send(any(long[].class), any(VoltMessage.class));
verify(mbox).send(any(long[].class), argThat(siteFailureIs(sfmFailed(1), sfmSurvived(0, 2, 3))));
assertEquals(decision, ImmutableMap.<Long, Long>of());
reset(mbox);
when(mbox.recvBlocking(any(Subject[].class), eq(5L))).thenReturn(make(siteOneSfm.but(with(sfmSource, 3L)))).thenReturn(make(siteTwoSfm.but(with(sfmSource, 0L)))).thenReturn(make(siteTwoSfm.but(with(sfmSource, 3L))));
decision = arbiter.reconfigureOnFault(hsids, new FaultMessage(0, 2));
verify(mbox, never()).deliverFront(any(VoltMessage.class));
verify(mbox, times(2)).send(any(long[].class), any(VoltMessage.class));
verify(mbox, times(2)).send(any(long[].class), argThat(siteFailureIs(sfmFailed(1, 2), sfmSurvived(0, 3))));
assertEquals(decision, ImmutableMap.<Long, Long>of(1L, 11L, 2L, 22L));
}
use of org.voltcore.messaging.FaultMessage in project voltdb by VoltDB.
the class TestMeshArbiter method testOneLinkDownFromThePerspictiveOfWitness.
@Test
public void testOneLinkDownFromThePerspictiveOfWitness() throws Exception {
Maker<SiteFailureMessage> s1f = a(SiteFailureMessage, with(sfmSurvivors, Longs.asList(0, 2, 3)), with(sfmFailures, sfmFailed(1)), with(sfmSafeTxns, sfmSafe(0, 10, 1, 11, 2, 22, 3, 33)));
Maker<SiteFailureMessage> s0f = a(SiteFailureMessage, with(sfmSurvivors, Longs.asList(1, 2, 3)), with(sfmFailures, sfmFailed(0)), with(sfmSafeTxns, sfmSafe(0, 10, 1, 11, 2, 22, 3, 33)));
Maker<SiteFailureMessage> s23f = a(SiteFailureMessage, with(sfmSurvivors, Longs.asList(0, 1, 2, 3)), with(sfmFailures, sfmFailed(0, 1)), with(sfmSafeTxns, sfmSafe(0, 10, 1, 11, 2, 22, 3, 33)));
Maker<SiteFailureForwardMessage> uf = a(FailureSiteForwardMessage);
when(aide.getNewestSafeTransactionForInitiator(0L)).thenReturn(10L);
when(aide.getNewestSafeTransactionForInitiator(1L)).thenReturn(11L);
when(mbox.recvBlocking(any(Subject[].class), eq(5L))).thenReturn(make(s23f.but(with(sfmSource, 2L), with(sfmFailures, sfmFailed(0))))).thenReturn(new FaultMessage(2L, 0L, ImmutableSet.of(1L, 2L, 3L))).thenReturn(make(s1f.but(with(sfmSource, 0L)))).thenReturn(make(s23f.but(with(sfmSource, 2L)))).thenReturn(make(s23f.but(with(sfmSource, 3L)))).thenReturn(make(uf.but(with(fsfmSource, 2L), with(fsfmMsg, s0f)))).thenReturn(make(uf.but(with(fsfmSource, 3L), with(fsfmMsg, s0f))));
Map<Long, Long> decision = arbiter.reconfigureOnFault(hsids, new FaultMessage(0, 1));
verify(mbox, times(0)).deliverFront(any(VoltMessage.class));
verify(mbox, times(2)).send(any(long[].class), argThat(siteFailureIs(sfmFailed(1), sfmSurvived(0, 2, 3))));
assertEquals(decision, ImmutableMap.<Long, Long>of(1L, 11L));
}
use of org.voltcore.messaging.FaultMessage in project voltdb by VoltDB.
the class MiniNode method run.
@Override
public void run() {
m_miniSite.start();
for (long HSId : m_HSIds) {
// Don't track your own death
if (HSId != m_HSId) {
m_deadTracker.startTracking(HSId);
}
}
m_nodeState.set(NodeState.RUN);
while (m_shouldContinue.get()) {
Message msg = m_recvQ.poll();
synchronized (this) {
if (msg != null) {
if (msg.m_close) {
int failedHostId = CoreUtils.getHostIdFromHSId(msg.m_src);
long agreementHSId = CoreUtils.getHSIdFromHostAndSite(failedHostId, HostMessenger.AGREEMENT_SITE_ID);
m_miniSite.reportFault(agreementHSId);
m_deadTracker.stopTracking(msg.m_src);
} else {
m_deadTracker.updateHSId(msg.m_src);
// inject actual message into mailbox
VoltMessage message = msg.m_msg;
// snoop for SiteFailureMessage, inject into MiniSite's mailbox
if (message instanceof SiteFailureMessage && !(message instanceof SiteFailureForwardMessage)) {
SiteFailureMessage sfm = (SiteFailureMessage) message;
for (FaultMessage fm : sfm.asFaultMessages()) {
m_miniSite.reportFault(fm);
}
}
m_mailbox.deliver(message);
}
}
// Do dead host detection. Need to keep track of receive gaps from the remaining set
// of live hosts.
Set<Long> deadHosts = m_deadTracker.checkTimeouts();
for (long HSId : deadHosts) {
int failedHostId = CoreUtils.getHostIdFromHSId(HSId);
long agreementHSId = CoreUtils.getHSIdFromHostAndSite(failedHostId, HostMessenger.AGREEMENT_SITE_ID);
m_miniSite.reportFault(agreementHSId);
m_deadTracker.stopTracking(HSId);
}
}
}
}
use of org.voltcore.messaging.FaultMessage in project voltdb by VoltDB.
the class MiniSite method reportFault.
public void reportFault(long faultingSite) {
if (m_siteLog.isDebugEnabled()) {
m_siteLog.debug("Reported fault: " + faultingSite + ", witnessed?: true");
}
FaultMessage fm = new FaultMessage(m_mailbox.getHSId(), faultingSite);
fm.m_sourceHSId = m_mailbox.getHSId();
m_mailbox.deliver(fm);
}
Aggregations