use of com.palantir.atlasdb.timelock.api.LockWatchRequest 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.api.LockWatchRequest in project atlasdb by palantir.
the class LockWatchingServiceImplTest method exactCellWatchMatchesExactDescriptorOnly.
@Test
public void exactCellWatchMatchesExactDescriptorOnly() {
LockDescriptor cellSuffixDescriptor = AtlasCellLockDescriptor.of(TABLE.getQualifiedName(), CELL.getRowName(), PtBytes.toBytes("col2"));
LockWatchRequest request = LockWatchRequest.of(ImmutableSet.of(LockWatchReferenceUtils.exactCell(TABLE, CELL)));
lockWatcher.startWatching(request);
ImmutableSet<LockDescriptor> locks = ImmutableSet.of(CELL_DESCRIPTOR, cellSuffixDescriptor);
lockWatcher.registerLock(locks, TOKEN);
List<LockWatchEvent> expectedEvents = ImmutableList.of(createdEvent(request.getReferences(), ImmutableSet.of()), lockEvent(ImmutableSet.of(CELL_DESCRIPTOR)));
assertLoggedEvents(expectedEvents);
}
use of com.palantir.atlasdb.timelock.api.LockWatchRequest in project atlasdb by palantir.
the class LockWatchingServiceImplTest method unlockWithoutLockTest.
@Test
public void unlockWithoutLockTest() {
LockWatchRequest tableRequest = tableRequest();
lockWatcher.startWatching(tableRequest);
lockWatcher.registerUnlock(ImmutableSet.of(CELL_DESCRIPTOR));
List<LockWatchEvent> expectedEvents = ImmutableList.of(createdEvent(tableRequest.getReferences(), ImmutableSet.of(ROW_DESCRIPTOR)), unlockEvent(ImmutableSet.of(CELL_DESCRIPTOR)));
assertLoggedEvents(expectedEvents);
}
use of com.palantir.atlasdb.timelock.api.LockWatchRequest in project atlasdb by palantir.
the class LockWatchingServiceImplTest method registeringWatchWithNarrowerScopeIsNoop.
@Test
public void registeringWatchWithNarrowerScopeIsNoop() {
LockWatchRequest request = tableRequest();
lockWatcher.startWatching(request);
LockWatchRequest prefixRequest = prefixRequest(ROW);
lockWatcher.startWatching(prefixRequest);
List<LockWatchEvent> expectedEvents = ImmutableList.of(createdEvent(request.getReferences(), ImmutableSet.of(ROW_DESCRIPTOR)));
assertLoggedEvents(expectedEvents);
}
use of com.palantir.atlasdb.timelock.api.LockWatchRequest in project atlasdb by palantir.
the class LockWatchingServiceImplTest method watchNewLockWatchLogsHeldLocksInRange.
@Test
public void watchNewLockWatchLogsHeldLocksInRange() {
LockWatchRequest request = tableRequest();
lockWatcher.startWatching(request);
List<LockWatchEvent> expectedEvents = ImmutableList.of(createdEvent(request.getReferences(), ImmutableSet.of(ROW_DESCRIPTOR)));
assertLoggedEvents(expectedEvents);
}
Aggregations