use of org.voltcore.messaging.Subject 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.Subject 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));
}
use of org.voltcore.messaging.Subject in project voltdb by VoltDB.
the class MiniMailbox method recvBlocking.
@Override
public synchronized VoltMessage recvBlocking(Subject[] subjects) {
VoltMessage message = null;
while (message == null) {
for (Subject s : subjects) {
final Deque<VoltMessage> dq = m_messages.get(s.getId());
message = dq.poll();
if (message != null) {
return message;
}
}
try {
this.wait();
} catch (InterruptedException e) {
return null;
}
}
return null;
}
use of org.voltcore.messaging.Subject in project voltdb by VoltDB.
the class MiniMailbox method recv.
@Override
public synchronized VoltMessage recv(Subject[] subjects) {
for (Subject s : subjects) {
final Deque<VoltMessage> dq = m_messages.get(s.getId());
assert (dq != null);
VoltMessage m = dq.poll();
if (m != null) {
return m;
}
}
return null;
}
use of org.voltcore.messaging.Subject in project voltdb by VoltDB.
the class MiniMailbox method recvBlocking.
@Override
public synchronized VoltMessage recvBlocking(Subject[] subjects, long timeout) {
VoltMessage message = null;
for (Subject s : subjects) {
final Deque<VoltMessage> dq = m_messages.get(s.getId());
message = dq.poll();
if (message != null) {
return message;
}
}
try {
this.wait(timeout);
} catch (InterruptedException e) {
return null;
}
for (Subject s : subjects) {
final Deque<VoltMessage> dq = m_messages.get(s.getId());
message = dq.poll();
if (message != null) {
return message;
}
}
return null;
}
Aggregations