@Test public void ordinal_is_assigned_by_publish() throws InterruptedException { final CountDownLatch firstInsertDone = new CountDownLatch(1); final CountDownLatch secondInsertDone = new CountDownLatch(1); final CountDownLatch firstInsertCommitted = new CountDownLatch(1); final String docId = randomUUID().toString(); final Revision r1 = new Revision(); final Revision r2 = new Revision(); new Thread(() -> { transactionTemplate.execute(status -> { ObjectVersion<String> version1 = ObjectVersion.<String>builder(r1) .changeset(mapOf(ROOT.property("concurrency"), " slow")) .build(); documentStore.append(docId, ObjectVersionGraph.init(version1).getTip()); firstInsertDone.countDown(); try { secondInsertDone.await(); } catch (InterruptedException e) { throw new RuntimeException(e); } return null; }); firstInsertCommitted.countDown(); }).start(); firstInsertDone.await(); ObjectVersion<String> version2 = ObjectVersion.<String>builder(r2) .changeset(mapOf("concurrency", "fast")) .build(); documentStore.append(docId, ObjectVersionGraph.init(version2).getTip()); documentStore.publish(); long count = queryFactory.from(documentVersion) .where(documentVersion.docId.eq(docId)) .fetchCount(); assertThat(count).isEqualTo(1); secondInsertDone.countDown(); firstInsertCommitted.await(); count = queryFactory.from(documentVersion) .where(documentVersion.docId.eq(docId)) .fetchCount(); assertThat(count).isEqualTo(2); Map<Revision, Long> ordinals = findOrdinals(docId); assertThat(ordinals.get(r1)).isNull(); assertThat(ordinals.get(r2)).isNotNull(); documentStore.publish(); ordinals = findOrdinals(docId); assertThat(ordinals.get(r1)).isGreaterThan(ordinals.get(r2)); }
public void append(Id docId, VersionNode<PropertyPath, Object, M> version) { options.transactions.writeRequired(() -> { doAppend(ImmutableMultimap.of(docId, version)); return null; }); }
DocumentVersionStoreJdbc extends AbstractVersionStoreJdbc<Id, M, V, DocumentUpdateBatch<Id, M, V>, DocumentStoreOptions<Id, M, V>> { public void append(Id docId, VersionNode<PropertyPath, Object, M> version) { options.transactions.writeRequired(() -> { doAppend(ImmutableMultimap.of(docId, version)); return null; }); } }
DocumentVersionStoreJdbc extends AbstractVersionStoreJdbc<Id, M, V, DocumentUpdateBatch<Id, M, V>, DocumentStoreOptions<Id, M, V>> { public void append(Id docId, VersionNode<PropertyPath, Object, M> version) { options.transactions.writeRequired(() -> { doAppend(ImmutableMultimap.of(docId, version)); return null; }); } @SuppressWarnings("unused")  DocumentVersionStoreJdbc();  DocumentVersionStoreJdbc(DocumentStoreOptions<Id, M, V> options); }
DocumentVersionStoreJdbc extends AbstractVersionStoreJdbc<Id, M, V, DocumentUpdateBatch<Id, M, V>, DocumentStoreOptions<Id, M, V>> { public void append(Id docId, VersionNode<PropertyPath, Object, M> version) { options.transactions.writeRequired(() -> { doAppend(ImmutableMultimap.of(docId, version)); return null; }); } @SuppressWarnings("unused")  DocumentVersionStoreJdbc();  DocumentVersionStoreJdbc(DocumentStoreOptions<Id, M, V> options); void append(Id docId, VersionNode<PropertyPath, Object, M> version); void append(Id docId, Iterable<VersionNode<PropertyPath, Object, M>> versions); void append(Multimap<Id, VersionNode<PropertyPath, Object, M>> versionsByDocId); @Override DocumentUpdateBatch<Id, M, V> updateBatch(Collection<Id> ids); }
DocumentVersionStoreJdbc extends AbstractVersionStoreJdbc<Id, M, V, DocumentUpdateBatch<Id, M, V>, DocumentStoreOptions<Id, M, V>> { public void append(Id docId, VersionNode<PropertyPath, Object, M> version) { options.transactions.writeRequired(() -> { doAppend(ImmutableMultimap.of(docId, version)); return null; }); } @SuppressWarnings("unused")  DocumentVersionStoreJdbc();  DocumentVersionStoreJdbc(DocumentStoreOptions<Id, M, V> options); void append(Id docId, VersionNode<PropertyPath, Object, M> version); void append(Id docId, Iterable<VersionNode<PropertyPath, Object, M>> versions); void append(Multimap<Id, VersionNode<PropertyPath, Object, M>> versionsByDocId); @Override DocumentUpdateBatch<Id, M, V> updateBatch(Collection<Id> ids);  }