use of com.palantir.lock.watch.CommitUpdate in project atlasdb by palantir.
the class ClientLogEventsTest method toCommitUpdateAlsoIncludesDescriptorsFromWatchEvents.
@Test
public void toCommitUpdateAlsoIncludesDescriptorsFromWatchEvents() {
LockWatchEvents events = LockWatchEvents.builder().addEvents(LOCK_WATCH_EVENT_VERSION_1, LOCK_DESCRIPTOR_2_VERSION_2, UNLOCK_DESCRIPTOR_2_VERSION_3, LOCK_DESCRIPTOR_1_VERSION_4).build();
ClientLogEvents clientLogEvents = ClientLogEvents.builder().clearCache(false).events(events).build();
CommitUpdate commitUpdate = clientLogEvents.toCommitUpdate(VERSION_0, VERSION_4, Optional.empty());
Set<LockDescriptor> lockDescriptors = extractLockDescriptors(commitUpdate);
assertThat(lockDescriptors).containsExactlyInAnyOrder(DESCRIPTOR_1, DESCRIPTOR_2, DESCRIPTOR_3);
}
use of com.palantir.lock.watch.CommitUpdate in project atlasdb by palantir.
the class ClientLogEventsTest method toCommitUpdateFiltersOutUnlockEvents.
@Test
public void toCommitUpdateFiltersOutUnlockEvents() {
LockWatchVersion startVersion = LockWatchVersion.of(LEADER, SEQUENCE_1);
LockWatchVersion endVersion = LockWatchVersion.of(LEADER, SEQUENCE_4);
CommitUpdate commitUpdate = CLIENT_EVENTS_2_TO_4_NO_CLEAR_CACHE.toCommitUpdate(startVersion, endVersion, Optional.empty());
Set<LockDescriptor> lockDescriptors = extractLockDescriptors(commitUpdate);
assertThat(lockDescriptors).containsExactlyInAnyOrder(DESCRIPTOR_1, DESCRIPTOR_2);
}
use of com.palantir.lock.watch.CommitUpdate in project atlasdb by palantir.
the class LockWatchEventIntegrationTest method commitUpdatesDoNotContainTheirOwnCommitLocks.
@Test
public void commitUpdatesDoNotContainTheirOwnCommitLocks() {
CommitUpdateExtractingCondition firstCondition = new CommitUpdateExtractingCondition();
CommitUpdateExtractingCondition secondCondition = new CommitUpdateExtractingCondition();
txnManager.runTaskWithConditionThrowOnConflict(firstCondition, (outerTxn, _unused1) -> {
firstCondition.initialiseWithStartTimestamp(outerTxn.getTimestamp());
outerTxn.put(TABLE_REF, ImmutableMap.of(CELL_1, DATA_1));
txnManager.runTaskWithConditionThrowOnConflict(secondCondition, (innerTxn, _unused2) -> {
secondCondition.initialiseWithStartTimestamp(innerTxn.getTimestamp());
innerTxn.put(TABLE_REF, ImmutableMap.of(CELL_2, DATA_2));
return null;
});
return null;
});
CommitUpdate firstUpdate = firstCondition.getCommitStageResult();
CommitUpdate secondUpdate = secondCondition.getCommitStageResult();
assertThat(extractDescriptorsFromUpdate(firstUpdate)).containsExactlyInAnyOrderElementsOf(getDescriptors(CELL_2));
assertThat(extractDescriptorsFromUpdate(secondUpdate)).isEmpty();
}
Aggregations