Search in sources :

Example 6 with CommitUpdate

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);
}
Also used : LockDescriptor(com.palantir.lock.LockDescriptor) StringLockDescriptor(com.palantir.lock.StringLockDescriptor) CommitUpdate(com.palantir.lock.watch.CommitUpdate) Test(org.junit.Test)

Example 7 with CommitUpdate

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);
}
Also used : LockWatchVersion(com.palantir.lock.watch.LockWatchVersion) LockDescriptor(com.palantir.lock.LockDescriptor) StringLockDescriptor(com.palantir.lock.StringLockDescriptor) CommitUpdate(com.palantir.lock.watch.CommitUpdate) Test(org.junit.Test)

Example 8 with CommitUpdate

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();
}
Also used : CommitUpdate(com.palantir.lock.watch.CommitUpdate) Test(org.junit.Test)

Aggregations

CommitUpdate (com.palantir.lock.watch.CommitUpdate)8 Test (org.junit.Test)6 LockDescriptor (com.palantir.lock.LockDescriptor)5 StringLockDescriptor (com.palantir.lock.StringLockDescriptor)4 StartTimestamp (com.palantir.atlasdb.keyvalue.api.watch.StartTimestamp)2 CellReference (com.palantir.atlasdb.keyvalue.api.CellReference)1 LeasedLockToken (com.palantir.lock.client.LeasedLockToken)1 LockWatchVersion (com.palantir.lock.watch.LockWatchVersion)1 List (java.util.List)1 Set (java.util.Set)1