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);
}
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);
}
Aggregations