use of com.palantir.atlasdb.timelock.api.Namespace in project atlasdb by palantir.
the class MultiClientTransactionStarterTest method shouldNotFreeResourcesIfRequestIsServed.
@Test
public void shouldNotFreeResourcesIfRequestIsServed() {
Namespace alpha = Namespace.of("alpha" + UUID.randomUUID());
Namespace beta = Namespace.of("beta" + UUID.randomUUID());
BatchElement<NamespaceAndRequestParams, List<StartIdentifiedAtlasDbTransactionResponse>> requestForAlpha = batchElementForNamespace(alpha, PARTITIONED_TIMESTAMPS_LIMIT_PER_SERVER_CALL - 1);
BatchElement<NamespaceAndRequestParams, List<StartIdentifiedAtlasDbTransactionResponse>> requestForBeta = batchElementForNamespace(beta, PARTITIONED_TIMESTAMPS_LIMIT_PER_SERVER_CALL * 5);
UUID requestorId = UUID.randomUUID();
List<BatchElement<NamespaceAndRequestParams, List<StartIdentifiedAtlasDbTransactionResponse>>> requests = ImmutableList.of(requestForAlpha, requestForBeta);
Map<Namespace, ConjureStartTransactionsResponse> responseMap = startTransactionsResponse(requests, requestorId);
when(timelockService.startTransactions(any())).thenReturn(responseMap).thenThrow(EXCEPTION);
assertThatThrownBy(() -> processBatch(timelockService, requestorId, requests)).isEqualTo(EXCEPTION);
// assert requests made by client alpha are served
assertSanityOfRequestBatch(ImmutableList.of(requestForAlpha), ImmutableMap.of(alpha, ImmutableList.of(responseMap.get(alpha))));
verify(LOCK_CLEANUP_SERVICE_MAP.get(alpha), never()).unlock(any());
verify(LOCK_CLEANUP_SERVICE_MAP.get(beta)).refreshLockLeases(any());
verify(LOCK_CLEANUP_SERVICE_MAP.get(beta)).unlock(any());
verify(NAMESPACE_CACHE_MAP.get(alpha), never()).removeTransactionStateFromCache(anyLong());
// The size of each batch is 5 here, and thus for a single batch we need to clean up five times
verify(NAMESPACE_CACHE_MAP.get(beta), times(5)).removeTransactionStateFromCache(anyLong());
}
use of com.palantir.atlasdb.timelock.api.Namespace in project atlasdb by palantir.
the class MultiClientTransactionStarterTest method canServiceOneRequestWithMultipleServerRequests.
@Test
public void canServiceOneRequestWithMultipleServerRequests() {
Namespace namespace = Namespace.of("Test_0");
setupServiceAndAssertSanity(ImmutableList.of(batchElementForNamespace(namespace, 127)));
}
use of com.palantir.atlasdb.timelock.api.Namespace in project atlasdb by palantir.
the class MultiClientTransactionStarter method getResponseHandlers.
private static Map<Namespace, ResponseHandler> getResponseHandlers(List<BatchElement<NamespaceAndRequestParams, List<StartIdentifiedAtlasDbTransactionResponse>>> batch) {
Map<Namespace, ResponseHandler> responseHandlers = new HashMap<>();
for (BatchElement<NamespaceAndRequestParams, List<StartIdentifiedAtlasDbTransactionResponse>> element : batch) {
NamespaceAndRequestParams requestParams = element.argument();
Namespace namespace = requestParams.namespace();
responseHandlers.computeIfAbsent(namespace, _unused -> new ResponseHandler(requestParams.params().lockCleanupService(), requestParams.params().cache())).addPendingFuture(SettableResponse.of(requestParams.params().numTransactions(), element.result()));
}
return responseHandlers;
}
use of com.palantir.atlasdb.timelock.api.Namespace in project atlasdb by palantir.
the class MultiNodePaxosTimeLockServerIntegrationTest method assertSanityAndGetLeaderTimes.
private LeaderTimes assertSanityAndGetLeaderTimes(TestableTimelockServer leader, Set<Namespace> expectedNamespaces) {
MultiClientConjureTimelockService multiClientConjureTimelockService = leader.multiClientService();
LeaderTimes leaderTimes = multiClientConjureTimelockService.leaderTimes(AUTH_HEADER, expectedNamespaces);
Set<Namespace> namespaces = leaderTimes.getLeaderTimes().keySet();
assertThat(namespaces).hasSameElementsAs(expectedNamespaces);
return leaderTimes;
}
use of com.palantir.atlasdb.timelock.api.Namespace in project atlasdb by palantir.
the class MultiNodePaxosTimeLockServerIntegrationTest method sanityCheckMultiClientLeaderTime.
@Test
public void sanityCheckMultiClientLeaderTime() {
TestableTimelockServer leader = cluster.currentLeaderFor(client.namespace());
// Multi client batched TimeLock endpoints do not support multi-leader mode on TimeLock
Assume.assumeFalse(leader.isMultiLeader());
Set<Namespace> expectedNamespaces = ImmutableSet.of(Namespace.of("client1"), Namespace.of("client2"));
LeaderTimes leaderTimes = assertSanityAndGetLeaderTimes(leader, expectedNamespaces);
// leaderTimes for namespaces are computed by their respective underlying AsyncTimelockService instances
Set<UUID> leadershipIds = leaderTimes.getLeaderTimes().values().stream().map(LeaderTime::id).map(LeadershipId::id).collect(Collectors.toSet());
assertThat(leadershipIds).hasSameSizeAs(expectedNamespaces);
}
Aggregations