Search in sources :

Example 26 with Namespace

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

Example 27 with Namespace

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

the class MultiNodePaxosTimeLockServerIntegrationTest method sanityCheckMultiClientLeaderTimeAgainstConjureTimelockService.

@Test
public void sanityCheckMultiClientLeaderTimeAgainstConjureTimelockService() {
    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("alpha"), Namespace.of("beta"));
    LeaderTimes leaderTimes = assertSanityAndGetLeaderTimes(leader, expectedNamespaces);
    // 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
    leaderTimes.getLeaderTimes().forEach((namespace, leaderTime) -> {
        LeaderTime conjureTimelockServiceLeaderTime = leader.client(namespace.get()).namespacedConjureTimelockService().leaderTime();
        assertThat(conjureTimelockServiceLeaderTime.id()).isEqualTo(leaderTime.id());
    });
}
Also used : LeaderTime(com.palantir.lock.v2.LeaderTime) LeaderTimes(com.palantir.atlasdb.timelock.api.LeaderTimes) Namespace(com.palantir.atlasdb.timelock.api.Namespace) Test(org.junit.Test)

Example 28 with Namespace

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

the class ExternalBackupPersister method storeCompletedBackup.

@Override
public void storeCompletedBackup(CompletedBackup completedBackup) {
    Namespace namespace = completedBackup.getNamespace();
    writeToFile(namespace, getImmutableTimestampFile(namespace), completedBackup.getImmutableTimestamp());
    writeToFile(namespace, getBackupTimestampFile(namespace), completedBackup.getBackupStartTimestamp());
    writeToFile(namespace, getFastForwardTimestampFile(namespace), completedBackup.getBackupEndTimestamp());
}
Also used : Namespace(com.palantir.atlasdb.timelock.api.Namespace)

Example 29 with Namespace

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

the class ExternalBackupPersister method storeImmutableTimestamp.

@Override
public void storeImmutableTimestamp(InProgressBackupToken inProgressBackupToken) {
    Namespace namespace = inProgressBackupToken.getNamespace();
    writeToFile(namespace, getImmutableTimestampFile(namespace), inProgressBackupToken.getImmutableTimestamp());
}
Also used : Namespace(com.palantir.atlasdb.timelock.api.Namespace)

Example 30 with Namespace

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

the class AtlasRestoreServiceTest method cannotRestoreTwiceToSameNamespace.

@Test
public void cannotRestoreTwiceToSameNamespace() {
    Namespace severeData = Namespace.of("severe-data");
    storeCompletedBackup(severeData);
    Namespace corruption = Namespace.of("corruption");
    RestoreRequest firstRequest = RestoreRequest.builder().oldNamespace(WITH_BACKUP).newNamespace(corruption).build();
    RestoreRequest secondRequest = RestoreRequest.builder().oldNamespace(severeData).newNamespace(corruption).build();
    Set<RestoreRequest> requests = ImmutableSet.of(firstRequest, secondRequest);
    assertThatThrownBy(() -> atlasRestoreService.prepareRestore(requests, BACKUP_ID)).isInstanceOf(SafeIllegalArgumentException.class).hasMessageContaining("severe data corruption");
}
Also used : CompleteRestoreRequest(com.palantir.atlasdb.backup.api.CompleteRestoreRequest) SafeIllegalArgumentException(com.palantir.logsafe.exceptions.SafeIllegalArgumentException) Namespace(com.palantir.atlasdb.timelock.api.Namespace) 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