use of com.palantir.lock.client.MultiClientCommitTimestampGetter.NamespacedRequest in project atlasdb by palantir.
the class MultiClientCommitTimestampGetterTest method updatesCacheWhileProcessingResponse.
@Test
public void updatesCacheWhileProcessingResponse() {
Namespace client = Namespace.of("Kitty");
List<BatchElement<NamespacedRequest, Long>> batchElements = IntStream.range(0, COMMIT_TS_LIMIT_PER_REQUEST * 2).mapToObj(ind -> batchElementForNamespace(client)).collect(toList());
setupServiceAndAssertSanityOfResponse(batchElements);
LockWatchCache cache = lockWatchCacheMap.get(client);
verify(cache, times(2)).processCommitTimestampsUpdate(any(), any());
}
use of com.palantir.lock.client.MultiClientCommitTimestampGetter.NamespacedRequest in project atlasdb by palantir.
the class MultiClientCommitTimestampGetterTest method doesNotUpdateCacheIfClientNotServed.
@Test
public void doesNotUpdateCacheIfClientNotServed() {
Namespace alpha = Namespace.of("alpha" + UUID.randomUUID());
Namespace beta = Namespace.of("beta" + UUID.randomUUID());
BatchElement<NamespacedRequest, Long> requestForAlpha = batchElementForNamespace(alpha);
BatchElement<NamespacedRequest, Long> requestForBeta = batchElementForNamespace(beta);
List<BatchElement<NamespacedRequest, Long>> allRequests = ImmutableList.of(requestForAlpha, requestForBeta);
List<BatchElement<NamespacedRequest, Long>> alphaRequestList = ImmutableList.of(requestForAlpha);
Map<Namespace, GetCommitTimestampsResponse> responseMap = getCommitTimestamps(alphaRequestList);
when(timelockService.getCommitTimestamps(any())).thenReturn(responseMap).thenThrow(EXCEPTION);
assertThatThrownBy(() -> consumer.accept(allRequests)).isEqualTo(EXCEPTION);
// assert requests made by client alpha are served
assertSanityOfResponse(alphaRequestList, ImmutableMap.of(alpha, ImmutableList.of(responseMap.get(alpha))));
LockWatchCache alphaCache = lockWatchCacheMap.get(alpha);
verify(alphaCache).processCommitTimestampsUpdate(any(), any());
assertThat(requestForBeta.result().isDone()).as("No requests made by client - beta were successful").isFalse();
LockWatchCache betaCache = lockWatchCacheMap.get(beta);
verify(betaCache, never()).processCommitTimestampsUpdate(any(), any());
}
Aggregations