@Override
    public void completeAllExceptionally(Throwable exception) {
        for (CompletableFuture<Long> completion : thresholdMap.values()) {
            completion.completeExceptionally(exception);
        }
    }
@Test
    public void testCompleteAllExceptionally() {
        CompletableFuture<Long> future1 = purgatory.await(3L, 500);
        CompletableFuture<Long> future2 = purgatory.await(1L, 500);
        CompletableFuture<Long> future3 = purgatory.await(5L, 500);
        assertEquals(3, purgatory.numWaiting());

        purgatory.completeAllExceptionally(new NotLeaderOrFollowerException());
        assertFutureThrows(future1, NotLeaderOrFollowerException.class);
        assertFutureThrows(future2, NotLeaderOrFollowerException.class);
        assertFutureThrows(future3, NotLeaderOrFollowerException.class);
        assertEquals(0, purgatory.numWaiting());
    }