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