Search in sources :

Example 11 with TransactionsLockWatchUpdate

use of com.palantir.lock.watch.TransactionsLockWatchUpdate in project atlasdb by palantir.

the class LockWatchEventCacheIntegrationTest method getEventsForTransactionsNoCondensing.

@Test
public void getEventsForTransactionsNoCondensing() {
    setupInitialState();
    eventCache.processStartTransactionsUpdate(ImmutableSet.of(), SUCCESS);
    eventCache.processStartTransactionsUpdate(TIMESTAMPS_2, SUCCESS_2);
    verifyStage();
    // Client is behind and needs a snapshot, but no compression can be done as the first transaction is at the
    // first version
    TransactionsLockWatchUpdate results = eventCache.getUpdateForTransactions(Sets.union(TIMESTAMPS, TIMESTAMPS_2), Optional.empty());
    assertThat(results.clearCache()).isTrue();
    assertThat(results.startTsToSequence()).containsExactlyInAnyOrderEntriesOf(ImmutableMap.of(START_TS_1, LockWatchVersion.of(LEADER, 3L), START_TS_2, LockWatchVersion.of(LEADER, 7L)));
    assertThat(results.events()).containsExactly(LockWatchCreatedEvent.builder(ImmutableSet.of(), ImmutableSet.of(DESCRIPTOR_2)).build(3L), WATCH_EVENT, UNLOCK_EVENT, LOCK_EVENT, LOCK_EVENT_2);
}
Also used : TransactionsLockWatchUpdate(com.palantir.lock.watch.TransactionsLockWatchUpdate) Test(org.junit.Test)

Example 12 with TransactionsLockWatchUpdate

use of com.palantir.lock.watch.TransactionsLockWatchUpdate in project atlasdb by palantir.

the class LockWatchEventCacheIntegrationTest method getEventsForTransactionsMaxCondensing.

@Test
public void getEventsForTransactionsMaxCondensing() {
    setupInitialState();
    eventCache.processStartTransactionsUpdate(ImmutableSet.of(), SUCCESS);
    eventCache.processStartTransactionsUpdate(TIMESTAMPS_2, SUCCESS_2);
    verifyStage();
    // Client is behind, and all events will be condensed into a single snapshot and no other events
    TransactionsLockWatchUpdate results = eventCache.getUpdateForTransactions(TIMESTAMPS_2, Optional.empty());
    assertThat(results.clearCache()).isTrue();
    assertThat(results.startTsToSequence()).containsExactlyInAnyOrderEntriesOf(ImmutableMap.of(START_TS_2, LockWatchVersion.of(LEADER, 7L)));
    assertThat(results.events()).containsExactly(LockWatchCreatedEvent.builder(ImmutableSet.of(REFERENCE), ImmutableSet.of(DESCRIPTOR, DESCRIPTOR_3)).build(7L));
}
Also used : TransactionsLockWatchUpdate(com.palantir.lock.watch.TransactionsLockWatchUpdate) Test(org.junit.Test)

Example 13 with TransactionsLockWatchUpdate

use of com.palantir.lock.watch.TransactionsLockWatchUpdate in project atlasdb by palantir.

the class LockWatchEventCacheIntegrationTest method leaderChangeWhenGettingUpdateForTransactionsDoesNotThrow.

@Test
public void leaderChangeWhenGettingUpdateForTransactionsDoesNotThrow() {
    setupInitialState();
    UUID newLeader = UUID.randomUUID();
    LockWatchVersion spuriousVersion = LockWatchVersion.of(newLeader, 99999L);
    TransactionsLockWatchUpdate results = eventCache.getUpdateForTransactions(TIMESTAMPS, Optional.of(spuriousVersion));
    assertThat(results.clearCache()).isTrue();
    assertThat(results.startTsToSequence()).containsExactlyEntriesOf(ImmutableMap.of(START_TS_1, LockWatchVersion.of(LEADER, 3L)));
    assertThat(results.events()).containsExactly(LockWatchCreatedEvent.fromSnapshot((LockWatchStateUpdate.Snapshot) SNAPSHOT));
}
Also used : TransactionsLockWatchUpdate(com.palantir.lock.watch.TransactionsLockWatchUpdate) LockWatchVersion(com.palantir.lock.watch.LockWatchVersion) UUID(java.util.UUID) Test(org.junit.Test)

Example 14 with TransactionsLockWatchUpdate

use of com.palantir.lock.watch.TransactionsLockWatchUpdate in project atlasdb by palantir.

the class ClientLogEventsTest method toTransactionsWithClientVersionEqualToEarliestTransaction.

@Test
public void toTransactionsWithClientVersionEqualToEarliestTransaction() {
    TimestampMapping mapping = createTimestampMappingWithSequences(SEQUENCE_1, SEQUENCE_4);
    TransactionsLockWatchUpdate update = CLIENT_EVENTS_2_TO_4_NO_CLEAR_CACHE.toTransactionsLockWatchUpdate(mapping, Optional.of(VERSION_1));
    assertThat(update.events()).containsExactly(LOCK_DESCRIPTOR_2_VERSION_2, UNLOCK_DESCRIPTOR_2_VERSION_3, LOCK_DESCRIPTOR_1_VERSION_4);
}
Also used : TransactionsLockWatchUpdate(com.palantir.lock.watch.TransactionsLockWatchUpdate) Test(org.junit.Test)

Example 15 with TransactionsLockWatchUpdate

use of com.palantir.lock.watch.TransactionsLockWatchUpdate in project atlasdb by palantir.

the class ClientLogEventsTest method toTransactionsWithClientVersionAbsent.

@Test
public void toTransactionsWithClientVersionAbsent() {
    TimestampMapping mapping = createTimestampMappingWithSequences(SEQUENCE_2, SEQUENCE_4);
    TransactionsLockWatchUpdate update = CLIENT_EVENTS_2_TO_4_NO_CLEAR_CACHE.toTransactionsLockWatchUpdate(mapping, Optional.empty());
    assertThat(update.events()).containsExactly(LOCK_DESCRIPTOR_2_VERSION_2, UNLOCK_DESCRIPTOR_2_VERSION_3, LOCK_DESCRIPTOR_1_VERSION_4);
}
Also used : TransactionsLockWatchUpdate(com.palantir.lock.watch.TransactionsLockWatchUpdate) Test(org.junit.Test)

Aggregations

TransactionsLockWatchUpdate (com.palantir.lock.watch.TransactionsLockWatchUpdate)19 Test (org.junit.Test)18 LockWatchVersion (com.palantir.lock.watch.LockWatchVersion)5 OpenTransaction (com.palantir.atlasdb.transaction.api.OpenTransaction)2 LockWatchEvent (com.palantir.lock.watch.LockWatchEvent)1 LockWatchStateUpdate (com.palantir.lock.watch.LockWatchStateUpdate)1 UUID (java.util.UUID)1