Search in sources :

Example 6 with SiteFailureMessage

use of org.voltcore.agreement.maker.SiteFailureMessageMaker.SiteFailureMessage 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));
}
Also used : VoltMessage(org.voltcore.messaging.VoltMessage) FaultMessage(org.voltcore.messaging.FaultMessage) Matchers.anyLong(org.mockito.Matchers.anyLong) SiteFailureForwardMessage(org.voltcore.messaging.SiteFailureForwardMessage) SiteFailureMessage(org.voltcore.messaging.SiteFailureMessage) SiteFailureMessage(org.voltcore.agreement.maker.SiteFailureMessageMaker.SiteFailureMessage) Test(org.junit.Test)

Example 7 with SiteFailureMessage

use of org.voltcore.agreement.maker.SiteFailureMessageMaker.SiteFailureMessage in project voltdb by VoltDB.

the class TestMeshArbiter method testMixOfWitnessedAndNon.

@Test
public void testMixOfWitnessedAndNon() throws Exception {
    Maker<SiteFailureMessage> um = a(SiteFailureMessage, with(sfmSurvivors, Longs.asList(0, 2, 3)), with(sfmFailures, sfmFailed(1)), with(sfmSafeTxns, sfmSafe(0, 10, 1, 11, 2, 22, 3, 33)));
    when(aide.getNewestSafeTransactionForInitiator(1L)).thenReturn(11L);
    when(mbox.recvBlocking(any(Subject[].class), eq(5L))).thenReturn(make(um.but(with(sfmSource, 2L)))).thenReturn(new FaultMessage(0, 1));
    Map<Long, Long> decision = arbiter.reconfigureOnFault(hsids, new FaultMessage(2, 1, ImmutableSet.of(0L, 2L, 3L)));
    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, 1, 2, 3))));
    assertEquals(decision, ImmutableMap.<Long, Long>of());
    reset(mbox);
    when(mbox.recvBlocking(any(Subject[].class), eq(5L))).thenReturn(make(um.but(with(sfmSource, 0L)))).thenReturn(make(um.but(with(sfmSource, 3L))));
    decision = arbiter.reconfigureOnFault(hsids, new FaultMessage(0, 1));
    verify(mbox, never()).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));
}
Also used : VoltMessage(org.voltcore.messaging.VoltMessage) FaultMessage(org.voltcore.messaging.FaultMessage) Matchers.anyLong(org.mockito.Matchers.anyLong) SiteFailureMessage(org.voltcore.messaging.SiteFailureMessage) SiteFailureMessage(org.voltcore.agreement.maker.SiteFailureMessageMaker.SiteFailureMessage) Subject(org.voltcore.messaging.Subject) Test(org.junit.Test)

Example 8 with SiteFailureMessage

use of org.voltcore.agreement.maker.SiteFailureMessageMaker.SiteFailureMessage in project voltdb by VoltDB.

the class TestMeshArbiter method testOverlappingFailures.

@Test
public void testOverlappingFailures() throws Exception {
    Maker<SiteFailureMessage> site12Sfm = 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.recv(any(Subject[].class))).thenReturn(new FaultMessage(0, 2)).thenReturn((VoltMessage) null);
    when(mbox.recvBlocking(any(Subject[].class), eq(5L))).thenReturn(make(site12Sfm.but(with(sfmSource, 0L)))).thenReturn(make(site12Sfm.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, 2), sfmSurvived(0, 3))));
    assertEquals(decision, ImmutableMap.<Long, Long>of(1L, 11L, 2L, 22L));
}
Also used : FaultMessage(org.voltcore.messaging.FaultMessage) Matchers.anyLong(org.mockito.Matchers.anyLong) SiteFailureMessage(org.voltcore.messaging.SiteFailureMessage) SiteFailureMessage(org.voltcore.agreement.maker.SiteFailureMessageMaker.SiteFailureMessage) Subject(org.voltcore.messaging.Subject) Test(org.junit.Test)

Example 9 with SiteFailureMessage

use of org.voltcore.agreement.maker.SiteFailureMessageMaker.SiteFailureMessage in project voltdb by VoltDB.

the class TestMeshArbiter method testPingsOnLongReceives.

@Test
public void testPingsOnLongReceives() 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)));
    when(aide.getNewestSafeTransactionForInitiator(1L)).thenReturn(11L);
    when(mbox.recvBlocking(any(Subject[].class), eq(5L))).thenReturn((VoltMessage) null).thenReturn((VoltMessage) null).thenReturn((VoltMessage) null).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))));
    verify(aide, atLeast(2)).sendHeartbeats(destinationCaptor.capture());
    assertEquals(destinationCaptor.getValue(), sfmSurvived(0, 2, 3));
    assertEquals(decision, ImmutableMap.<Long, Long>of(1L, 11L));
}
Also used : VoltMessage(org.voltcore.messaging.VoltMessage) FaultMessage(org.voltcore.messaging.FaultMessage) Matchers.anyLong(org.mockito.Matchers.anyLong) SiteFailureMessage(org.voltcore.messaging.SiteFailureMessage) SiteFailureMessage(org.voltcore.agreement.maker.SiteFailureMessageMaker.SiteFailureMessage) Subject(org.voltcore.messaging.Subject) Test(org.junit.Test)

Example 10 with SiteFailureMessage

use of org.voltcore.agreement.maker.SiteFailureMessageMaker.SiteFailureMessage in project voltdb by VoltDB.

the class TestMeshArbiter method testOneLinkDownFromThePerspectiveOfNonWitness.

@Test
public void testOneLinkDownFromThePerspectiveOfNonWitness() 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> s2f = a(SiteFailureMessage, with(sfmSurvivors, Longs.asList(0, 1, 3)), with(sfmFailures, sfmFailed(2)), with(sfmSafeTxns, sfmSafe(0, 10, 1, 11, 2, 22, 3, 33)));
    Maker<SiteFailureMessage> s03f = a(SiteFailureMessage, with(sfmSurvivors, Longs.asList(0, 1, 2, 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(s2f.but(with(sfmSource, 1L)))).thenReturn(make(s03f.but(with(sfmSource, 3L), with(sfmFailures, sfmFailed(1))))).thenReturn(new FaultMessage(1, 2, ImmutableSet.of(0L, 1L, 3L)));
    Map<Long, Long> decision = arbiter.reconfigureOnFault(hsids, new FaultMessage(2, 1, ImmutableSet.of(0L, 2L, 3L)));
    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, 1, 2, 3))));
    assertEquals(decision, ImmutableMap.<Long, Long>of());
    reset(mbox);
    when(mbox.recvBlocking(any(Subject[].class), eq(5L))).thenReturn(make(s1f.but(with(sfmSource, 2L)))).thenReturn(make(s03f.but(with(sfmSource, 0L)))).thenReturn(make(s03f.but(with(sfmSource, 3L))));
    decision = arbiter.reconfigureOnFault(hsids, new FaultMessage(1, 2, ImmutableSet.of(0L, 1L, 3L)));
    // promotion from un to witnessed
    verify(mbox, atLeast(2)).send(any(long[].class), any(VoltMessage.class));
    verify(mbox).send(any(long[].class), argThat(siteFailureIs(sfmFailed(1, 2), sfmSurvived(0, 1, 2, 3))));
    verify(mbox).send(eq(new long[] { 1 }), argThat(failureForwardMsgIs(2, sfmFailed(1), sfmSurvived(0, 2, 3))));
    assertEquals(decision, ImmutableMap.<Long, Long>of(2L, 22L));
}
Also used : VoltMessage(org.voltcore.messaging.VoltMessage) FaultMessage(org.voltcore.messaging.FaultMessage) Matchers.anyLong(org.mockito.Matchers.anyLong) SiteFailureMessage(org.voltcore.messaging.SiteFailureMessage) SiteFailureMessage(org.voltcore.agreement.maker.SiteFailureMessageMaker.SiteFailureMessage) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)11 SiteFailureMessage (org.voltcore.agreement.maker.SiteFailureMessageMaker.SiteFailureMessage)11 Matchers.anyLong (org.mockito.Matchers.anyLong)8 FaultMessage (org.voltcore.messaging.FaultMessage)8 SiteFailureMessage (org.voltcore.messaging.SiteFailureMessage)8 VoltMessage (org.voltcore.messaging.VoltMessage)6 Subject (org.voltcore.messaging.Subject)5 ByteBuffer (java.nio.ByteBuffer)3 SiteFailureForwardMessage (org.voltcore.messaging.SiteFailureForwardMessage)1