Search in sources :

Example 1 with LockWatchRequest

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

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);
}
Also used : LockDescriptor(com.palantir.lock.LockDescriptor) AtlasCellLockDescriptor(com.palantir.lock.AtlasCellLockDescriptor) AtlasRowLockDescriptor(com.palantir.lock.AtlasRowLockDescriptor) LockWatchEvent(com.palantir.lock.watch.LockWatchEvent) LockWatchRequest(com.palantir.atlasdb.timelock.api.LockWatchRequest) Test(org.junit.Test)

Example 3 with LockWatchRequest

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);
}
Also used : LockWatchEvent(com.palantir.lock.watch.LockWatchEvent) LockWatchRequest(com.palantir.atlasdb.timelock.api.LockWatchRequest) Test(org.junit.Test)

Example 4 with LockWatchRequest

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);
}
Also used : LockWatchEvent(com.palantir.lock.watch.LockWatchEvent) LockWatchRequest(com.palantir.atlasdb.timelock.api.LockWatchRequest) Test(org.junit.Test)

Example 5 with LockWatchRequest

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);
}
Also used : LockWatchEvent(com.palantir.lock.watch.LockWatchEvent) LockWatchRequest(com.palantir.atlasdb.timelock.api.LockWatchRequest) Test(org.junit.Test)

Aggregations

LockWatchRequest (com.palantir.atlasdb.timelock.api.LockWatchRequest)11 Test (org.junit.Test)11 LockWatchEvent (com.palantir.lock.watch.LockWatchEvent)10 AtlasCellLockDescriptor (com.palantir.lock.AtlasCellLockDescriptor)7 AtlasRowLockDescriptor (com.palantir.lock.AtlasRowLockDescriptor)7 LockDescriptor (com.palantir.lock.LockDescriptor)7 ExclusiveLock (com.palantir.atlasdb.timelock.lock.ExclusiveLock)1 LockWatchReference (com.palantir.lock.watch.LockWatchReferences.LockWatchReference)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ExecutorService (java.util.concurrent.ExecutorService)1