Search in sources :

Example 1 with InProgressBackupToken

use of com.palantir.atlasdb.backup.api.InProgressBackupToken in project atlasdb by palantir.

the class AtlasBackupService method completeBackup.

public Set<Namespace> completeBackup(Set<Namespace> namespaces) {
    Set<InProgressBackupToken> tokens = namespaces.stream().map(inProgressBackups::remove).filter(Objects::nonNull).collect(Collectors.toSet());
    CompleteBackupRequest request = CompleteBackupRequest.of(tokens);
    CompleteBackupResponse response = atlasBackupClient.completeBackup(authHeader, request);
    return response.getSuccessfulBackups().stream().peek(coordinationServiceRecorder::storeFastForwardState).peek(backupPersister::storeCompletedBackup).map(CompletedBackup::getNamespace).collect(Collectors.toSet());
}
Also used : CompleteBackupResponse(com.palantir.atlasdb.backup.api.CompleteBackupResponse) CompleteBackupRequest(com.palantir.atlasdb.backup.api.CompleteBackupRequest) InProgressBackupToken(com.palantir.atlasdb.backup.api.InProgressBackupToken)

Example 2 with InProgressBackupToken

use of com.palantir.atlasdb.backup.api.InProgressBackupToken in project atlasdb by palantir.

the class AtlasBackupResourceTest method completeBackupDoesNotContainNamespaceWhenLockIsLost.

@Test
public void completeBackupDoesNotContainNamespaceWhenLockIsLost() {
    InProgressBackupToken backupToken = invalidBackupToken();
    assertThat(AtlasFutures.getUnchecked(atlasBackupService.completeBackup(AUTH_HEADER, completeBackupRequest(backupToken)))).isEqualTo(EMPTY_COMPLETE_BACKUP_RESPONSE);
}
Also used : InProgressBackupToken(com.palantir.atlasdb.backup.api.InProgressBackupToken) Test(org.junit.Test)

Example 3 with InProgressBackupToken

use of com.palantir.atlasdb.backup.api.InProgressBackupToken in project atlasdb by palantir.

the class AtlasBackupResourceTest method completeBackupFiltersOutUnsuccessfulNamespaces.

@Test
public void completeBackupFiltersOutUnsuccessfulNamespaces() {
    when(mockTimelock.getFreshTimestamp()).thenReturn(BACKUP_END_TIMESTAMP);
    InProgressBackupToken validToken = validBackupToken();
    InProgressBackupToken invalidToken = invalidBackupToken(OTHER_NAMESPACE, otherTimelock);
    CompletedBackup expected = completedBackup(validToken);
    assertThat(AtlasFutures.getUnchecked(atlasBackupService.completeBackup(AUTH_HEADER, completeBackupRequest(validToken, invalidToken)))).isEqualTo(completeBackupResponseWith(expected));
}
Also used : CompletedBackup(com.palantir.atlasdb.backup.api.CompletedBackup) InProgressBackupToken(com.palantir.atlasdb.backup.api.InProgressBackupToken) Test(org.junit.Test)

Example 4 with InProgressBackupToken

use of com.palantir.atlasdb.backup.api.InProgressBackupToken in project atlasdb by palantir.

the class AtlasBackupResourceTest method refreshesBackupSuccessfully.

@Test
public void refreshesBackupSuccessfully() {
    InProgressBackupToken inProgressBackupToken = validBackupToken();
    Set<LockToken> lockTokens = ImmutableSet.of(inProgressBackupToken.getLockToken());
    when(mockTimelock.refreshLockLeases(lockTokens)).thenReturn(Futures.immediateFuture(RefreshLockResponseV2.of(lockTokens, mock(Lease.class))));
    assertThat(AtlasFutures.getUnchecked(atlasBackupService.refreshBackup(AUTH_HEADER, refreshBackupRequest(inProgressBackupToken)))).isEqualTo(refreshBackupResponseWith(inProgressBackupToken));
    verify(authHeaderValidator).suppliedHeaderMatchesConfig(AUTH_HEADER);
}
Also used : Lease(com.palantir.lock.v2.Lease) LockToken(com.palantir.lock.v2.LockToken) InProgressBackupToken(com.palantir.atlasdb.backup.api.InProgressBackupToken) Test(org.junit.Test)

Example 5 with InProgressBackupToken

use of com.palantir.atlasdb.backup.api.InProgressBackupToken in project atlasdb by palantir.

the class AtlasBackupResourceTest method completeBackupContainsNamespaceWhenLockIsHeld.

@Test
public void completeBackupContainsNamespaceWhenLockIsHeld() {
    when(mockTimelock.getFreshTimestamp()).thenReturn(BACKUP_END_TIMESTAMP);
    InProgressBackupToken backupToken = validBackupToken();
    CompletedBackup expected = completedBackup(backupToken);
    assertThat(AtlasFutures.getUnchecked(atlasBackupService.completeBackup(AUTH_HEADER, completeBackupRequest(backupToken)))).isEqualTo(completeBackupResponseWith(expected));
    verify(authHeaderValidator).suppliedHeaderMatchesConfig(AUTH_HEADER);
}
Also used : CompletedBackup(com.palantir.atlasdb.backup.api.CompletedBackup) InProgressBackupToken(com.palantir.atlasdb.backup.api.InProgressBackupToken) Test(org.junit.Test)

Aggregations

InProgressBackupToken (com.palantir.atlasdb.backup.api.InProgressBackupToken)15 Test (org.junit.Test)9 CompletedBackup (com.palantir.atlasdb.backup.api.CompletedBackup)5 Namespace (com.palantir.atlasdb.timelock.api.Namespace)5 AtlasService (com.palantir.atlasdb.backup.api.AtlasService)4 LockToken (com.palantir.lock.v2.LockToken)4 CompleteBackupRequest (com.palantir.atlasdb.backup.api.CompleteBackupRequest)3 CompleteBackupResponse (com.palantir.atlasdb.backup.api.CompleteBackupResponse)3 NamedThreadFactory (com.palantir.common.concurrent.NamedThreadFactory)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 Sets (com.google.common.collect.Sets)2 Futures (com.google.common.util.concurrent.Futures)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)2 AtlasBackupClient (com.palantir.atlasdb.backup.api.AtlasBackupClient)2 AtlasBackupClientBlocking (com.palantir.atlasdb.backup.api.AtlasBackupClientBlocking)2 PrepareBackupRequest (com.palantir.atlasdb.backup.api.PrepareBackupRequest)2 PrepareBackupResponse (com.palantir.atlasdb.backup.api.PrepareBackupResponse)2 RefreshBackupRequest (com.palantir.atlasdb.backup.api.RefreshBackupRequest)2