@Test void nextModSeqShouldGenerateUniqueValuesWhenParallelCalls() throws ExecutionException, InterruptedException { int nbEntries = 10; ConcurrentSkipListSet<ModSeq> modSeqs = new ConcurrentSkipListSet<>(); ConcurrentTestRunner.builder() .operation( (threadNumber, step) -> modSeqs.add(modSeqProvider.nextModSeq(mailbox))) .threadCount(10) .operationCount(nbEntries) .runSuccessfullyWithin(Duration.ofMinutes(1)); assertThat(modSeqs).hasSize(100); }
@Override public ModSeq nextModSeq(Mailbox mailbox) throws MailboxException { CassandraId mailboxId = (CassandraId) mailbox.getMailboxId(); return nextModSeq(mailboxId) .blockOptional() .orElseThrow(() -> new MailboxException("Can not retrieve modseq for " + mailboxId)); }
CassandraModSeqProvider implements ModSeqProvider { @Override public ModSeq nextModSeq(Mailbox mailbox) throws MailboxException { CassandraId mailboxId = (CassandraId) mailbox.getMailboxId(); return nextModSeq(mailboxId) .blockOptional() .orElseThrow(() -> new MailboxException("Can not retrieve modseq for " + mailboxId)); } }
CassandraModSeqProvider implements ModSeqProvider { @Override public ModSeq nextModSeq(Mailbox mailbox) throws MailboxException { CassandraId mailboxId = (CassandraId) mailbox.getMailboxId(); return nextModSeq(mailboxId) .blockOptional() .orElseThrow(() -> new MailboxException("Can not retrieve modseq for " + mailboxId)); } @Inject  CassandraModSeqProvider(Session session, CassandraConfiguration cassandraConfiguration,
                                   CassandraConsistenciesConfiguration consistenciesConfiguration); }
CassandraModSeqProvider implements ModSeqProvider { @Override public ModSeq nextModSeq(Mailbox mailbox) throws MailboxException { CassandraId mailboxId = (CassandraId) mailbox.getMailboxId(); return nextModSeq(mailboxId) .blockOptional() .orElseThrow(() -> new MailboxException("Can not retrieve modseq for " + mailboxId)); } @Inject  CassandraModSeqProvider(Session session, CassandraConfiguration cassandraConfiguration,
                                   CassandraConsistenciesConfiguration consistenciesConfiguration); @Override ModSeq nextModSeq(Mailbox mailbox); @Override ModSeq nextModSeq(MailboxId mailboxId); @Override ModSeq highestModSeq(Mailbox mailbox); @Override ModSeq highestModSeq(MailboxId mailboxId); Mono<ModSeq> nextModSeq(CassandraId mailboxId); }
CassandraModSeqProvider implements ModSeqProvider { @Override public ModSeq nextModSeq(Mailbox mailbox) throws MailboxException { CassandraId mailboxId = (CassandraId) mailbox.getMailboxId(); return nextModSeq(mailboxId) .blockOptional() .orElseThrow(() -> new MailboxException("Can not retrieve modseq for " + mailboxId)); } @Inject  CassandraModSeqProvider(Session session, CassandraConfiguration cassandraConfiguration,
                                   CassandraConsistenciesConfiguration consistenciesConfiguration); @Override ModSeq nextModSeq(Mailbox mailbox); @Override ModSeq nextModSeq(MailboxId mailboxId); @Override ModSeq highestModSeq(Mailbox mailbox); @Override ModSeq highestModSeq(MailboxId mailboxId); Mono<ModSeq> nextModSeq(CassandraId mailboxId); static final String MOD_SEQ_CONDITION; }