Search in sources :

Example 6 with Namespace

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

the class AtlasBackupResource method fetchFastForwardTimestamp.

private CompletedBackup fetchFastForwardTimestamp(InProgressBackupToken backupToken) {
    Namespace namespace = backupToken.getNamespace();
    long fastForwardTimestamp = timelock(namespace).getFreshTimestamp();
    return CompletedBackup.builder().namespace(namespace).immutableTimestamp(backupToken.getImmutableTimestamp()).backupStartTimestamp(backupToken.getBackupStartTimestamp()).backupEndTimestamp(fastForwardTimestamp).build();
}
Also used : Namespace(com.palantir.atlasdb.timelock.api.Namespace)

Example 7 with Namespace

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

the class AllNodesDisabledNamespacesUpdaterTest method disableDoesNotReportConsistentStateWhenNamespacesAreLockedWithDifferentIds.

@Test
public void disableDoesNotReportConsistentStateWhenNamespacesAreLockedWithDifferentIds() {
    Set<Namespace> namespaces = ImmutableSet.of(NAMESPACE);
    String otherLockId = "otherLockId";
    String yetAnotherLockId = "yetAnotherLockId";
    SingleNodeUpdateResponse lockedWithOtherLock = ImmutableSingleNodeUpdateResponse.builder().isSuccessful(false).putLockedNamespaces(NAMESPACE, otherLockId).build();
    SingleNodeUpdateResponse lockedWithYetAnotherLock = ImmutableSingleNodeUpdateResponse.builder().isSuccessful(false).putLockedNamespaces(NAMESPACE, yetAnotherLockId).build();
    when(remote1.disable(any(), any())).thenReturn(lockedWithOtherLock);
    when(remote2.disable(any(), any())).thenReturn(SingleNodeUpdateResponse.successful());
    when(remote2.reenable(any(), any())).thenReturn(SingleNodeUpdateResponse.successful());
    when(localUpdater.getNamespacesLockedWithDifferentLockId(any(), any())).thenReturn(lockedWithYetAnotherLock.lockedNamespaces());
    DisableNamespacesResponse response = updater.disableOnAllNodes(AUTH_HEADER, disableNamespacesRequest(namespaces));
    verify(remote1, never()).reenable(any(), any());
    verify(remote2).reenable(any(), any());
    assertThat(response).isEqualTo(partiallyDisabled(namespaces));
}
Also used : SuccessfulDisableNamespacesResponse(com.palantir.atlasdb.timelock.api.SuccessfulDisableNamespacesResponse) UnsuccessfulDisableNamespacesResponse(com.palantir.atlasdb.timelock.api.UnsuccessfulDisableNamespacesResponse) DisableNamespacesResponse(com.palantir.atlasdb.timelock.api.DisableNamespacesResponse) Namespace(com.palantir.atlasdb.timelock.api.Namespace) SingleNodeUpdateResponse(com.palantir.atlasdb.timelock.api.SingleNodeUpdateResponse) ImmutableSingleNodeUpdateResponse(com.palantir.atlasdb.timelock.api.ImmutableSingleNodeUpdateResponse) Test(org.junit.Test)

Example 8 with Namespace

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

the class AllNodesDisabledNamespacesUpdaterTest method rollsBackIfLocalUpdateFails.

@Test
public void rollsBackIfLocalUpdateFails() {
    when(remote1.disable(any(), any())).thenReturn(SUCCESSFUL_SINGLE_NODE_UPDATE);
    when(remote2.disable(any(), any())).thenReturn(SUCCESSFUL_SINGLE_NODE_UPDATE);
    Set<Namespace> failedNamespaces = ImmutableSet.of(OTHER_NAMESPACE);
    when(localUpdater.disable(DisableNamespacesRequest.of(BOTH_NAMESPACES, LOCK_ID))).thenReturn(singleNodeUpdateFailure(failedNamespaces));
    DisableNamespacesResponse response = updater.disableOnAllNodes(AUTH_HEADER, disableNamespacesRequest(BOTH_NAMESPACES));
    assertThat(response).isEqualTo(partiallyDisabled(BOTH_NAMESPACES));
    ReenableNamespacesRequest rollbackRequest = ReenableNamespacesRequest.of(BOTH_NAMESPACES, LOCK_ID);
    verify(remote1).reenable(AUTH_HEADER, rollbackRequest);
    verify(remote2).reenable(AUTH_HEADER, rollbackRequest);
    // local update failed, so no need to roll back
    verify(localUpdater, never()).reEnable(any());
}
Also used : SuccessfulDisableNamespacesResponse(com.palantir.atlasdb.timelock.api.SuccessfulDisableNamespacesResponse) UnsuccessfulDisableNamespacesResponse(com.palantir.atlasdb.timelock.api.UnsuccessfulDisableNamespacesResponse) DisableNamespacesResponse(com.palantir.atlasdb.timelock.api.DisableNamespacesResponse) ReenableNamespacesRequest(com.palantir.atlasdb.timelock.api.ReenableNamespacesRequest) Namespace(com.palantir.atlasdb.timelock.api.Namespace) Test(org.junit.Test)

Example 9 with Namespace

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

the class AllNodesDisabledNamespacesUpdaterTest method reEnableCanPartiallyFail.

// Case A: Start with one disabled namespace, re-enable fails on some node, we should re-disable
@Test
public void reEnableCanPartiallyFail() {
    ImmutableSet<Namespace> oneNamespace = ImmutableSet.of(NAMESPACE);
    ReenableNamespacesRequest request = ReenableNamespacesRequest.of(oneNamespace, LOCK_ID);
    when(remote1.reenable(AUTH_HEADER, request)).thenReturn(SingleNodeUpdateResponse.successful());
    when(remote2.reenable(AUTH_HEADER, request)).thenReturn(singleNodeUpdateFailure(oneNamespace));
    when(localUpdater.reEnable(request)).thenReturn(SingleNodeUpdateResponse.successful());
    ReenableNamespacesResponse response = updater.reEnableOnAllNodes(AUTH_HEADER, request);
    assertThat(response).isEqualTo(partiallyLocked(oneNamespace));
    // verify we still unlocked locally
    verify(localUpdater).reEnable(request);
}
Also used : UnsuccessfulReenableNamespacesResponse(com.palantir.atlasdb.timelock.api.UnsuccessfulReenableNamespacesResponse) SuccessfulReenableNamespacesResponse(com.palantir.atlasdb.timelock.api.SuccessfulReenableNamespacesResponse) ReenableNamespacesResponse(com.palantir.atlasdb.timelock.api.ReenableNamespacesResponse) ReenableNamespacesRequest(com.palantir.atlasdb.timelock.api.ReenableNamespacesRequest) Namespace(com.palantir.atlasdb.timelock.api.Namespace) Test(org.junit.Test)

Example 10 with Namespace

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

the class AtlasRestoreResourceTest method completesRestoreSuccessfully.

@Test
public void completesRestoreSuccessfully() {
    Namespace newNamespace = Namespace.of("newNamespace");
    CompletedBackup completedBackup = completedBackup();
    CompleteRestoreResponse response = AtlasFutures.getUnchecked(atlasRestoreResource.completeRestore(AUTH_HEADER, CompleteRestoreRequest.of(ImmutableMap.of(newNamespace, completedBackup))));
    assertThat(response.getSuccessfulNamespaces()).containsExactly(newNamespace);
    verify(otherTimelock).fastForwardTimestamp(completedBackup.getBackupEndTimestamp());
}
Also used : CompletedBackup(com.palantir.atlasdb.backup.api.CompletedBackup) CompleteRestoreResponse(com.palantir.atlasdb.backup.api.CompleteRestoreResponse) 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