use of com.palantir.atlasdb.timelock.api.GetCommitTimestampsResponse 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());
}
use of com.palantir.atlasdb.timelock.api.GetCommitTimestampsResponse in project atlasdb by palantir.
the class MultiNodePaxosTimeLockServerIntegrationTest method sanityCheckMultiClientGetCommitTimestampsAgainstConjureTimelockService.
@Test
public void sanityCheckMultiClientGetCommitTimestampsAgainstConjureTimelockService() {
TestableTimelockServer leader = cluster.currentLeaderFor(client.namespace());
// Multi client batched TimeLock endpoints do not support multi-leader mode on TimeLock
Assume.assumeFalse(leader.isMultiLeader());
MultiClientConjureTimelockService multiClientService = leader.multiClientService();
Set<String> expectedNamespaces = ImmutableSet.of("alta", "mp");
Map<Namespace, GetCommitTimestampsResponse> multiClientResponses = multiClientService.getCommitTimestampsForClients(AUTH_HEADER, defaultGetCommitTimestampsRequests(expectedNamespaces));
assertSanityOfNamespacesServed(expectedNamespaces, multiClientResponses);
// Whether we hit the multi client endpoint or conjureTimelockService endpoint(services one client in one
// call), for a namespace, the underlying service to process the request is the same
multiClientResponses.forEach((namespace, responseFromBatchedEndpoint) -> {
GetCommitTimestampsResponse conjureGetCommitTimestampResponse = leader.client(namespace.get()).namespacedConjureTimelockService().getCommitTimestamps(defaultCommitTimestampRequest());
assertThat(conjureGetCommitTimestampResponse.getLockWatchUpdate().logId()).isEqualTo(responseFromBatchedEndpoint.getLockWatchUpdate().logId());
assertThat(conjureGetCommitTimestampResponse.getInclusiveLower()).as("timestamps should contiguously increase per namespace if there are no elections.").isEqualTo(responseFromBatchedEndpoint.getInclusiveUpper() + 1);
});
}
use of com.palantir.atlasdb.timelock.api.GetCommitTimestampsResponse in project atlasdb by palantir.
the class MultiNodePaxosTimeLockServerIntegrationTest method sanityCheckMultiClientGetCommitTimestamps.
@Test
public void sanityCheckMultiClientGetCommitTimestamps() {
TestableTimelockServer leader = cluster.currentLeaderFor(client.namespace());
// Multi client batched TimeLock endpoints do not support multi-leader mode on TimeLock
Assume.assumeFalse(leader.isMultiLeader());
MultiClientConjureTimelockService service = leader.multiClientService();
Set<String> expectedNamespaces = ImmutableSet.of("cli-1", "cli-2");
Map<Namespace, GetCommitTimestampsResponse> multiClientResponses = service.getCommitTimestampsForClients(AUTH_HEADER, defaultGetCommitTimestampsRequests(expectedNamespaces));
assertSanityOfNamespacesServed(expectedNamespaces, multiClientResponses);
Set<UUID> leadershipIds = multiClientResponses.values().stream().map(GetCommitTimestampsResponse::getLockWatchUpdate).map(LockWatchStateUpdate::logId).collect(Collectors.toSet());
assertThat(leadershipIds).hasSameSizeAs(expectedNamespaces);
}
Aggregations