use of org.apache.cassandra.repair.CoordinatedRepairResult in project cassandra by apache.
the class CoordinatorMessagingTest method testMockedMessagingPrepareTimeout.
@Test
public void testMockedMessagingPrepareTimeout() throws InterruptedException, ExecutionException, TimeoutException, NoSuchRepairSessionException {
MockMessagingSpy spyPrepare = createPrepareSpy(Collections.emptySet(), Collections.singleton(PARTICIPANT3), new CountDownLatch(0));
MockMessagingSpy sendFailSessionUnexpectedSpy = createFailSessionSpy(Lists.newArrayList(PARTICIPANT1, PARTICIPANT2, PARTICIPANT3));
UUID uuid = registerSession(cfs, true, true);
CoordinatorSession coordinator = ActiveRepairService.instance.consistent.coordinated.registerSession(uuid, PARTICIPANTS, false);
AtomicBoolean repairSubmitted = new AtomicBoolean(false);
Promise<CoordinatedRepairResult> repairFuture = AsyncPromise.uncancellable();
Supplier<Future<CoordinatedRepairResult>> sessionSupplier = () -> {
repairSubmitted.set(true);
return repairFuture;
};
// coordinator sends prepare requests to create local session and perform anticompaction
Assert.assertFalse(repairSubmitted.get());
// execute repair and start prepare phase
Future<CoordinatedRepairResult> sessionResult = coordinator.execute(sessionSupplier);
try {
sessionResult.get(1, TimeUnit.SECONDS);
fail("Completed session without failure after prepare failed");
} catch (ExecutionException e) {
fail("Failed session in prepare failed during timeout from participant");
} catch (TimeoutException e) {
// expected
}
// we won't send out any fail session message in case of timeouts
spyPrepare.expectMockedMessage(2).get(100, TimeUnit.MILLISECONDS);
sendFailSessionUnexpectedSpy.interceptNoMsg(100, TimeUnit.MILLISECONDS);
Assert.assertFalse(repairSubmitted.get());
Assert.assertEquals(ConsistentSession.State.PREPARING, coordinator.getState());
Assert.assertFalse(ActiveRepairService.instance.consistent.local.isSessionInProgress(uuid));
}
use of org.apache.cassandra.repair.CoordinatedRepairResult in project cassandra by apache.
the class CoordinatorMessagingTest method testMockedMessagingPrepareFailure.
private void testMockedMessagingPrepareFailure(CountDownLatch prepareLatch) throws InterruptedException, ExecutionException, TimeoutException, NoSuchRepairSessionException {
// we expect FailSession messages to all participants
MockMessagingSpy sendFailSessionExpectedSpy = createFailSessionSpy(Lists.newArrayList(PARTICIPANT1, PARTICIPANT2, PARTICIPANT3));
UUID uuid = registerSession(cfs, true, true);
CoordinatorSession coordinator = ActiveRepairService.instance.consistent.coordinated.registerSession(uuid, PARTICIPANTS, false);
AtomicBoolean repairSubmitted = new AtomicBoolean(false);
Promise<CoordinatedRepairResult> repairFuture = AsyncPromise.uncancellable();
Supplier<Future<CoordinatedRepairResult>> sessionSupplier = () -> {
repairSubmitted.set(true);
return repairFuture;
};
// coordinator sends prepare requests to create local session and perform anticompaction
Assert.assertFalse(repairSubmitted.get());
// execute repair and start prepare phase
Future<CoordinatedRepairResult> sessionResult = coordinator.execute(sessionSupplier);
prepareLatch.countDown();
// prepare completed
try {
sessionResult.get(1, TimeUnit.SECONDS);
fail("Completed session without failure after prepare failed");
} catch (ExecutionException e) {
}
sendFailSessionExpectedSpy.interceptMessageOut(3).get(1, TimeUnit.SECONDS);
Assert.assertFalse(repairSubmitted.get());
Assert.assertTrue(sessionResult.isDone());
Assert.assertNotNull(sessionResult.cause());
Assert.assertEquals(ConsistentSession.State.FAILED, coordinator.getState());
Assert.assertFalse(ActiveRepairService.instance.consistent.local.isSessionInProgress(uuid));
}
Aggregations