use of org.voltcore.agreement.maker.SiteFailureMessageMaker.SiteFailureMessage in project voltdb by VoltDB.
the class TestSiteFailureMessage method testForwardRoundTripSerialization.
@Test
public void testForwardRoundTripSerialization() throws Exception {
SiteFailureMessage msg = make(sfm);
assertThat(msg, siteFailureIs(sfmSafe(4, 44, 5, 55), sfmFailed(4, 5, 6), sfmSurvived(1, 2, 3)));
ByteBuffer bb = VoltMessage.toBuffer(msg);
VoltMessage vmsg = factory.createMessageFromBuffer(bb, 1L);
assertTrue(vmsg instanceof SiteFailureMessage);
SiteFailureMessage gsm = (SiteFailureMessage) vmsg;
assertThat(gsm, siteFailureIs(sfmSafe(4, 44, 5, 55), sfmFailed(4, 5, 6), sfmSurvived(1, 2, 3)));
SiteFailureForwardMessage fmsg = new SiteFailureForwardMessage(gsm);
assertThat(fmsg, failureForwardMsgIs(1, sfmSafe(4, 44, 5, 55), sfmFailed(4, 5, 6), sfmSurvived(1, 2, 3)));
bb = VoltMessage.toBuffer(fmsg);
vmsg = factory.createMessageFromBuffer(bb, 1L);
assertTrue(vmsg instanceof SiteFailureForwardMessage);
SiteFailureForwardMessage gsmf = (SiteFailureForwardMessage) vmsg;
assertThat(gsmf, failureForwardMsgIs(1, sfmSafe(4, 44, 5, 55), sfmFailed(4, 5, 6), sfmSurvived(1, 2, 3)));
}
use of org.voltcore.agreement.maker.SiteFailureMessageMaker.SiteFailureMessage in project voltdb by VoltDB.
the class TestSiteFailureMessage method testSiteFailureMessageRoundtripSerialization.
@Test
public void testSiteFailureMessageRoundtripSerialization() throws Exception {
SiteFailureMessage msg = make(sfm);
assertThat(msg, siteFailureIs(sfmSafe(4, 44, 5, 55), sfmFailed(4, 5, 6), sfmSurvived(1, 2, 3)));
ByteBuffer bb = VoltMessage.toBuffer(msg);
VoltMessage vmsg = factory.createMessageFromBuffer(bb, 1L);
assertTrue(vmsg instanceof SiteFailureMessage);
SiteFailureMessage gsm = (SiteFailureMessage) vmsg;
assertThat(gsm, siteFailureIs(sfmSafe(4, 44, 5, 55), sfmFailed(4, 5, 6), sfmSurvived(1, 2, 3)));
}
use of org.voltcore.agreement.maker.SiteFailureMessageMaker.SiteFailureMessage in project voltdb by VoltDB.
the class TestSiteFailureMessage method testSiteFailureMessageRoundtripSerializationWithDecision.
@Test
public void testSiteFailureMessageRoundtripSerializationWithDecision() throws Exception {
Set<Long> decision = ImmutableSet.of(1L, 2L);
@SuppressWarnings("unchecked") SiteFailureMessage msg = make(sfm.but(with(sfmDecision, decision)));
assertThat(msg, siteFailureIs(sfmSafe(4, 44, 5, 55), decision, 1, 2, 3));
ByteBuffer bb = VoltMessage.toBuffer(msg);
VoltMessage vmsg = factory.createMessageFromBuffer(bb, 1L);
assertTrue(vmsg instanceof SiteFailureMessage);
SiteFailureMessage gsm = (SiteFailureMessage) vmsg;
assertThat(gsm, siteFailureIs(sfmSafe(4, 44, 5, 55), decision, 1, 2, 3));
}
use of org.voltcore.agreement.maker.SiteFailureMessageMaker.SiteFailureMessage 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.agreement.maker.SiteFailureMessageMaker.SiteFailureMessage 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));
}
Aggregations