Search in sources :

Example 1 with ExclusiveLock

use of com.palantir.atlasdb.timelock.lock.ExclusiveLock in project atlasdb by palantir.

the class LockWatchingServiceImplTest method registeringWatchWithWiderScopeLogsAlreadyWatchedLocksAgain.

@Test
public void registeringWatchWithWiderScopeLogsAlreadyWatchedLocksAgain() {
    LockDescriptor secondRow = AtlasRowLockDescriptor.of(TABLE.getQualifiedName(), PtBytes.toBytes("other_row"));
    when(heldLocks.getLocks()).thenReturn(ImmutableList.of(LOCK, new ExclusiveLock(secondRow)));
    LockWatchRequest prefixRequest = prefixRequest(ROW);
    lockWatcher.startWatching(prefixRequest);
    LockWatchRequest entireTableRequest = tableRequest();
    lockWatcher.startWatching(entireTableRequest);
    List<LockWatchEvent> expectedEvents = ImmutableList.of(createdEvent(prefixRequest.getReferences(), ImmutableSet.of(ROW_DESCRIPTOR)), createdEvent(entireTableRequest.getReferences(), ImmutableSet.of(ROW_DESCRIPTOR, secondRow)));
    assertLoggedEvents(expectedEvents);
}
Also used : LockDescriptor(com.palantir.lock.LockDescriptor) AtlasCellLockDescriptor(com.palantir.lock.AtlasCellLockDescriptor) AtlasRowLockDescriptor(com.palantir.lock.AtlasRowLockDescriptor) ExclusiveLock(com.palantir.atlasdb.timelock.lock.ExclusiveLock) LockWatchEvent(com.palantir.lock.watch.LockWatchEvent) LockWatchRequest(com.palantir.atlasdb.timelock.api.LockWatchRequest) Test(org.junit.Test)

Example 2 with ExclusiveLock

use of com.palantir.atlasdb.timelock.lock.ExclusiveLock in project atlasdb by palantir.

the class LockWatchingServiceImplTest method registeringWatchWithOverlappingScopeLogsAlreadyWatchedLocksInScopeAgain.

@Test
public void registeringWatchWithOverlappingScopeLogsAlreadyWatchedLocksInScopeAgain() {
    LockDescriptor ab = AtlasRowLockDescriptor.of(TABLE.getQualifiedName(), PtBytes.toBytes("ab"));
    LockDescriptor bc = AtlasRowLockDescriptor.of(TABLE.getQualifiedName(), PtBytes.toBytes("bc"));
    LockDescriptor cd = AtlasRowLockDescriptor.of(TABLE.getQualifiedName(), PtBytes.toBytes("cd"));
    when(heldLocks.getLocks()).thenReturn(ImmutableList.of(LOCK, new ExclusiveLock(ab), new ExclusiveLock(bc), new ExclusiveLock(cd)));
    LockWatchReference acRange = LockWatchReferenceUtils.rowRange(TABLE, PtBytes.toBytes("a"), PtBytes.toBytes("c"));
    LockWatchReference bdRange = LockWatchReferenceUtils.rowRange(TABLE, PtBytes.toBytes("b"), PtBytes.toBytes("d"));
    lockWatcher.startWatching(LockWatchRequest.of(ImmutableSet.of(acRange)));
    lockWatcher.startWatching(LockWatchRequest.of(ImmutableSet.of(bdRange)));
    List<LockWatchEvent> expectedEvents = ImmutableList.of(createdEvent(ImmutableSet.of(acRange), ImmutableSet.of(ab, bc)), createdEvent(ImmutableSet.of(bdRange), ImmutableSet.of(bc, cd)));
    assertLoggedEvents(expectedEvents);
}
Also used : LockDescriptor(com.palantir.lock.LockDescriptor) AtlasCellLockDescriptor(com.palantir.lock.AtlasCellLockDescriptor) AtlasRowLockDescriptor(com.palantir.lock.AtlasRowLockDescriptor) ExclusiveLock(com.palantir.atlasdb.timelock.lock.ExclusiveLock) LockWatchEvent(com.palantir.lock.watch.LockWatchEvent) LockWatchReference(com.palantir.lock.watch.LockWatchReferences.LockWatchReference) Test(org.junit.Test)

Aggregations

ExclusiveLock (com.palantir.atlasdb.timelock.lock.ExclusiveLock)2 AtlasCellLockDescriptor (com.palantir.lock.AtlasCellLockDescriptor)2 AtlasRowLockDescriptor (com.palantir.lock.AtlasRowLockDescriptor)2 LockDescriptor (com.palantir.lock.LockDescriptor)2 LockWatchEvent (com.palantir.lock.watch.LockWatchEvent)2 Test (org.junit.Test)2 LockWatchRequest (com.palantir.atlasdb.timelock.api.LockWatchRequest)1 LockWatchReference (com.palantir.lock.watch.LockWatchReferences.LockWatchReference)1