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());
}
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);
}
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));
}
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);
}
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);
}
Aggregations