Search in sources :

Example 6 with FaultMessage

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));
}
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) Test(org.junit.Test)

Example 7 with FaultMessage

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));
}
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 FaultMessage

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));
}
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 9 with FaultMessage

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);
            }
        }
    }
}
Also used : VoltMessage(org.voltcore.messaging.VoltMessage) FaultMessage(org.voltcore.messaging.FaultMessage) SiteFailureForwardMessage(org.voltcore.messaging.SiteFailureForwardMessage) FaultMessage(org.voltcore.messaging.FaultMessage) VoltMessage(org.voltcore.messaging.VoltMessage) SiteFailureMessage(org.voltcore.messaging.SiteFailureMessage) Message(org.voltcore.agreement.FakeMesh.Message) SiteFailureForwardMessage(org.voltcore.messaging.SiteFailureForwardMessage) SiteFailureMessage(org.voltcore.messaging.SiteFailureMessage)

Example 10 with FaultMessage

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);
}
Also used : FaultMessage(org.voltcore.messaging.FaultMessage)

Aggregations

FaultMessage (org.voltcore.messaging.FaultMessage)15 SiteFailureMessage (org.voltcore.messaging.SiteFailureMessage)11 VoltMessage (org.voltcore.messaging.VoltMessage)9 Test (org.junit.Test)8 Matchers.anyLong (org.mockito.Matchers.anyLong)8 SiteFailureMessage (org.voltcore.agreement.maker.SiteFailureMessageMaker.SiteFailureMessage)8 Subject (org.voltcore.messaging.Subject)5 SiteFailureForwardMessage (org.voltcore.messaging.SiteFailureForwardMessage)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ImmutableMap (com.google_voltpatches.common.collect.ImmutableMap)1 IOException (java.io.IOException)1 ByteBuffer (java.nio.ByteBuffer)1 Request (org.apache.zookeeper_voltpatches.server.Request)1 JSONObject (org.json_voltpatches.JSONObject)1 Message (org.voltcore.agreement.FakeMesh.Message)1 AgreementTaskMessage (org.voltcore.messaging.AgreementTaskMessage)1 BinaryPayloadMessage (org.voltcore.messaging.BinaryPayloadMessage)1 HeartbeatMessage (org.voltcore.messaging.HeartbeatMessage)1 HeartbeatResponseMessage (org.voltcore.messaging.HeartbeatResponseMessage)1