Search in sources :

Example 51 with Namespace

use of com.palantir.atlasdb.timelock.api.Namespace 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);
}
Also used : MultiClientConjureTimelockService(com.palantir.atlasdb.timelock.api.MultiClientConjureTimelockService) UUID(java.util.UUID) Namespace(com.palantir.atlasdb.timelock.api.Namespace) GetCommitTimestampsResponse(com.palantir.atlasdb.timelock.api.GetCommitTimestampsResponse) Test(org.junit.Test)

Example 52 with Namespace

use of com.palantir.atlasdb.timelock.api.Namespace in project atlasdb by palantir.

the class MultiNodePaxosTimeLockServerIntegrationTest method multiClientStartTransactionsReturnsCorrectStartTimestamps.

@Test
public void multiClientStartTransactionsReturnsCorrectStartTimestamps() {
    TestableTimelockServer leader = cluster.currentLeaderFor(client.namespace());
    // Multi client batched TimeLock endpoints do not support multi-leader mode on TimeLock
    Assume.assumeFalse(leader.isMultiLeader());
    Namespace delta = Namespace.of("delta");
    Namespace gamma = Namespace.of("gamma");
    NamespacedClients deltaClient = leader.client(delta.get()).throughWireMockProxy();
    NamespacedClients gammaClient = leader.client(gamma.get()).throughWireMockProxy();
    List<String> expectedNamespaces = ImmutableList.of(delta.get(), gamma.get());
    int deltaFastForwardedTimestamp = 155_200_000;
    int gammaFastForwardedTimestamp = 988_000_000;
    deltaClient.timestampManagementService().fastForwardTimestamp(deltaFastForwardedTimestamp);
    gammaClient.timestampManagementService().fastForwardTimestamp(gammaFastForwardedTimestamp);
    Map<Namespace, ConjureStartTransactionsResponse> startedTransactions = assertSanityAndStartTransactions(leader, expectedNamespaces);
    assertThat(startedTransactions.get(delta).getTimestamps().start()).isGreaterThanOrEqualTo(deltaFastForwardedTimestamp).isLessThan(gammaFastForwardedTimestamp);
    assertThat(startedTransactions.get(gamma).getTimestamps().start()).isGreaterThanOrEqualTo(gammaFastForwardedTimestamp);
}
Also used : ConjureStartTransactionsResponse(com.palantir.atlasdb.timelock.api.ConjureStartTransactionsResponse) Namespace(com.palantir.atlasdb.timelock.api.Namespace) Test(org.junit.Test)

Example 53 with Namespace

use of com.palantir.atlasdb.timelock.api.Namespace in project atlasdb by palantir.

the class MultiNodePaxosTimeLockServerIntegrationTest method sanityCheckMultiClientStartTransactionsAgainstConjureTimelockService.

@Test
public void sanityCheckMultiClientStartTransactionsAgainstConjureTimelockService() {
    TestableTimelockServer leader = cluster.currentLeaderFor(client.namespace());
    // Multi client batched TimeLock endpoints do not support multi-leader mode on TimeLock
    Assume.assumeFalse(leader.isMultiLeader());
    MultiClientConjureTimelockService multiClientConjureTimelockService = leader.multiClientService();
    List<String> expectedNamespaces = ImmutableList.of("alpha", "beta");
    int numTransactions = 7;
    Map<Namespace, ConjureStartTransactionsRequest> namespaceToRequestMap = defaultStartTransactionsRequests(expectedNamespaces, numTransactions);
    Map<Namespace, ConjureStartTransactionsResponse> startedTransactions = multiClientConjureTimelockService.startTransactionsForClients(AUTH_HEADER, namespaceToRequestMap);
    // Whether we hit the multi client endpoint or conjureTimelockService endpoint, for a namespace, the underlying
    // service to process the request is the same
    startedTransactions.forEach((namespace, responseFromBatchedEndpoint) -> {
        ConjureStartTransactionsResponse responseFromLegacyEndpoint = leader.client(namespace.get()).namespacedConjureTimelockService().startTransactions(namespaceToRequestMap.get(namespace));
        assertThat(responseFromLegacyEndpoint.getLockWatchUpdate().logId()).isEqualTo(responseFromBatchedEndpoint.getLockWatchUpdate().logId());
        PartitionedTimestamps batchedEndpointTimestamps = responseFromBatchedEndpoint.getTimestamps();
        long lastTimestamp = batchedEndpointTimestamps.stream().max().orElseThrow(SafeIllegalStateException::new);
        assertThat(responseFromLegacyEndpoint.getTimestamps().start()).isGreaterThan(lastTimestamp);
    });
}
Also used : MultiClientConjureTimelockService(com.palantir.atlasdb.timelock.api.MultiClientConjureTimelockService) ConjureStartTransactionsRequest(com.palantir.atlasdb.timelock.api.ConjureStartTransactionsRequest) PartitionedTimestamps(com.palantir.lock.v2.PartitionedTimestamps) Namespace(com.palantir.atlasdb.timelock.api.Namespace) ConjureStartTransactionsResponse(com.palantir.atlasdb.timelock.api.ConjureStartTransactionsResponse) SafeIllegalStateException(com.palantir.logsafe.exceptions.SafeIllegalStateException) Test(org.junit.Test)

Aggregations

Namespace (com.palantir.atlasdb.timelock.api.Namespace)53 Test (org.junit.Test)39 ImmutableList (com.google.common.collect.ImmutableList)12 List (java.util.List)11 Map (java.util.Map)11 Set (java.util.Set)11 UUID (java.util.UUID)11 AtlasService (com.palantir.atlasdb.backup.api.AtlasService)10 CompletedBackup (com.palantir.atlasdb.backup.api.CompletedBackup)10 ConjureStartTransactionsResponse (com.palantir.atlasdb.timelock.api.ConjureStartTransactionsResponse)10 DisableNamespacesResponse (com.palantir.atlasdb.timelock.api.DisableNamespacesResponse)9 SuccessfulDisableNamespacesResponse (com.palantir.atlasdb.timelock.api.SuccessfulDisableNamespacesResponse)9 UnsuccessfulDisableNamespacesResponse (com.palantir.atlasdb.timelock.api.UnsuccessfulDisableNamespacesResponse)9 KeyedStream (com.palantir.common.streams.KeyedStream)9 ImmutableSet (com.google.common.collect.ImmutableSet)8 SafeIllegalStateException (com.palantir.logsafe.exceptions.SafeIllegalStateException)8 Collectors (java.util.stream.Collectors)8 BatchElement (com.palantir.atlasdb.autobatch.BatchElement)7 ReenableNamespacesRequest (com.palantir.atlasdb.timelock.api.ReenableNamespacesRequest)7 ArrayList (java.util.ArrayList)7