@Test public void testParallelTransactions() { testSubject = new SequenceNumberCache(SequenceNumberCacheTest::slowSequenceNumberProvider, clock, 1); boolean[] success = new boolean[2]; IntStream.range(0, 2).parallel().forEach(i -> { try { testSubject.reserveSequenceNumbers(asList( serializedEvent("NEW", "SampleAgg", 0))); success[i] = true; } catch (MessagingPlatformException ex) { Assert.assertEquals(ErrorCode.INVALID_SEQUENCE, ex.getErrorCode()); success[i] = false; } }); assertTrue("Expect one success", success[0] || success[1]); assertFalse("Expect one failure", success[0] && success[1]); testSubject.reserveSequenceNumbers(asList( serializedEvent("NEW", "SampleAgg", 1))); }
public void reserveSequenceNumbers(List<SerializedEvent> events) { reserveSequenceNumbers(events, false); }
SequenceNumberCache { public void reserveSequenceNumbers(List<SerializedEvent> events) { reserveSequenceNumbers(events, false); } }
SequenceNumberCache { public void reserveSequenceNumbers(List<SerializedEvent> events) { reserveSequenceNumbers(events, false); } SequenceNumberCache(
            BiFunction<String, EventStorageEngine.SearchHint[], Optional<Long>> aggregateSequenceNumberProvider);  SequenceNumberCache(
            BiFunction<String, EventStorageEngine.SearchHint[], Optional<Long>> aggregateSequenceNumberProvider,
            Clock clock, int maxSize); }
SequenceNumberCache { public void reserveSequenceNumbers(List<SerializedEvent> events) { reserveSequenceNumbers(events, false); } SequenceNumberCache(
            BiFunction<String, EventStorageEngine.SearchHint[], Optional<Long>> aggregateSequenceNumberProvider);  SequenceNumberCache(
            BiFunction<String, EventStorageEngine.SearchHint[], Optional<Long>> aggregateSequenceNumberProvider,
            Clock clock, int maxSize); void reserveSequenceNumbers(List<SerializedEvent> events); Runnable reserveSequenceNumbers(List<SerializedEvent> events, boolean force); void clear(); void clearOld(long timeout); void close(); }
SequenceNumberCache { public void reserveSequenceNumbers(List<SerializedEvent> events) { reserveSequenceNumbers(events, false); } SequenceNumberCache(
            BiFunction<String, EventStorageEngine.SearchHint[], Optional<Long>> aggregateSequenceNumberProvider);  SequenceNumberCache(
            BiFunction<String, EventStorageEngine.SearchHint[], Optional<Long>> aggregateSequenceNumberProvider,
            Clock clock, int maxSize); void reserveSequenceNumbers(List<SerializedEvent> events); Runnable reserveSequenceNumbers(List<SerializedEvent> events, boolean force); void clear(); void clearOld(long timeout); void close();  }