use of com.palantir.lock.watch.TransactionsLockWatchUpdate in project atlasdb by palantir.
the class LockWatchEventCacheImplTest method getUpdateForTransactionsReturnsOnlyRelevantEventsForBatch.
@Test
public void getUpdateForTransactionsReturnsOnlyRelevantEventsForBatch() {
eventCache.processStartTransactionsUpdate(ImmutableSet.of(TIMESTAMP_1), SNAPSHOT_VERSION_1);
eventCache.processStartTransactionsUpdate(ImmutableSet.of(TIMESTAMP_2), SUCCESS_VERSION_2);
eventCache.processStartTransactionsUpdate(ImmutableSet.of(TIMESTAMP_3), SUCCESS_VERSION_3);
verify(eventLog).processUpdate(SNAPSHOT_VERSION_1);
verify(eventLog).processUpdate(SUCCESS_VERSION_2);
verify(eventLog).processUpdate(SUCCESS_VERSION_3);
TransactionsLockWatchUpdate update = eventCache.getUpdateForTransactions(ImmutableSet.of(TIMESTAMP_1, TIMESTAMP_2), Optional.empty());
// This event is effectively a snapshot, and is used as such by the event cache
LockWatchEvent snapshotEventAtSequence1 = LockWatchCreatedEvent.builder(ImmutableSet.of(REFERENCE_1), ImmutableSet.of(DESCRIPTOR_1)).build(SEQUENCE_1);
assertThat(update.clearCache()).as("must clear cache due to no past user version").isTrue();
assertThat(update.events()).as("snapshot up to earliest sequence corresponding to a timestamp, then events up to latest known" + " version").containsExactly(snapshotEventAtSequence1, LOCK_DESCRIPTOR_2_VERSION_2);
assertThat(update.startTsToSequence()).containsExactlyInAnyOrderEntriesOf(ImmutableMap.of(TIMESTAMP_1, VERSION_1, TIMESTAMP_2, VERSION_2));
}
use of com.palantir.lock.watch.TransactionsLockWatchUpdate in project atlasdb by palantir.
the class LockWatchEventCacheIntegrationTest method clientPartiallyUpToDateDoesNotThrow.
@Test
public void clientPartiallyUpToDateDoesNotThrow() {
setupInitialState();
eventCache.processStartTransactionsUpdate(TIMESTAMPS_2, SUCCESS);
TransactionsLockWatchUpdate update = eventCache.getUpdateForTransactions(Sets.union(TIMESTAMPS, TIMESTAMPS_2), Optional.of(LockWatchVersion.of(LEADER, 5L)));
assertThat(update.clearCache()).isFalse();
assertThat(update.events().size()).isEqualTo(1);
assertThat(update.startTsToSequence()).containsExactlyInAnyOrderEntriesOf(ImmutableMap.of(START_TS_1, LockWatchVersion.of(LEADER, 3L), START_TS_2, LockWatchVersion.of(LEADER, 6L)));
}
use of com.palantir.lock.watch.TransactionsLockWatchUpdate in project atlasdb by palantir.
the class ClientLogEventsTest method toTransactionsWithVeryOldClientVersion.
@Test
public void toTransactionsWithVeryOldClientVersion() {
ClientLogEvents clientLogEvents = ClientLogEvents.builder().clearCache(true).events(EVENTS_2_TO_4).build();
TimestampMapping mapping = createTimestampMappingWithSequences(SEQUENCE_2, SEQUENCE_4);
TransactionsLockWatchUpdate update = clientLogEvents.toTransactionsLockWatchUpdate(mapping, Optional.of(VERSION_0));
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 toTransactionsWithOldClientVersion.
@Test
public void toTransactionsWithOldClientVersion() {
TimestampMapping mapping = createTimestampMappingWithSequences(SEQUENCE_2, 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 LockWatchValueScopingCacheImpl method processStartTransactions.
@Override
public synchronized void processStartTransactions(Set<Long> startTimestamps) {
TransactionsLockWatchUpdate updateForTransactions = eventCache.getUpdateForTransactions(startTimestamps, currentVersion);
Optional<LockWatchVersion> latestVersionFromUpdate = computeMaxUpdateVersion(updateForTransactions);
if (updateForTransactions.clearCache()) {
clearCache(updateForTransactions, latestVersionFromUpdate);
}
updateStores(updateForTransactions);
updateCurrentVersion(latestVersionFromUpdate);
}
Aggregations