use of com.palantir.atlasdb.backup.api.InProgressBackupToken in project atlasdb by palantir.
the class AtlasBackupServiceTest method completeBackupReturnsSuccessfulNamespaces.
@Test
public void completeBackupReturnsSuccessfulNamespaces() {
InProgressBackupToken otherInProgress = inProgressBackupToken(OTHER_NAMESPACE);
Set<Namespace> namespaces = ImmutableSet.of(NAMESPACE, OTHER_NAMESPACE);
when(atlasBackupClient.prepareBackup(authHeader, PrepareBackupRequest.of(namespaces))).thenReturn(PrepareBackupResponse.of(ImmutableSet.of(IN_PROGRESS, otherInProgress)));
when(atlasBackupClient.completeBackup(authHeader, CompleteBackupRequest.of(ImmutableSet.of(IN_PROGRESS, otherInProgress)))).thenReturn(CompleteBackupResponse.of(ImmutableSet.of(completedBackup())));
atlasBackupService.prepareBackup(namespaces);
assertThat(atlasBackupService.completeBackup(namespaces)).containsExactly(NAMESPACE);
}
use of com.palantir.atlasdb.backup.api.InProgressBackupToken in project atlasdb by palantir.
the class AtlasBackupResourceTest method preparesBackupSuccessfully.
@Test
public void preparesBackupSuccessfully() {
LockToken lockToken = lockToken();
when(mockTimelock.lockImmutableTimestamp(any())).thenReturn(LockImmutableTimestampResponse.of(IMMUTABLE_TIMESTAMP, lockToken));
when(mockTimelock.getFreshTimestamp()).thenReturn(BACKUP_START_TIMESTAMP);
InProgressBackupToken expectedBackupToken = inProgressBackupToken(lockToken);
assertThat(AtlasFutures.getUnchecked(atlasBackupService.prepareBackup(AUTH_HEADER, PREPARE_BACKUP_REQUEST))).isEqualTo(prepareBackupResponseWith(expectedBackupToken));
verify(authHeaderValidator).suppliedHeaderMatchesConfig(AUTH_HEADER);
}
use of com.palantir.atlasdb.backup.api.InProgressBackupToken in project atlasdb by palantir.
the class AtlasBackupResourceTest method validBackupToken.
private InProgressBackupToken validBackupToken() {
LockToken lockToken = lockToken();
InProgressBackupToken backupToken = inProgressBackupToken(lockToken);
Set<LockToken> singleLockToken = ImmutableSet.of(lockToken);
when(mockTimelock.unlock(singleLockToken)).thenReturn(Futures.immediateFuture(singleLockToken));
return backupToken;
}
use of com.palantir.atlasdb.backup.api.InProgressBackupToken in project atlasdb by palantir.
the class ExternalBackupPersisterTest method putAndGetImmutableTimestamp.
@Test
public void putAndGetImmutableTimestamp() {
long immutableTimestamp = 1337L;
InProgressBackupToken inProgressBackupToken = InProgressBackupToken.builder().namespace(NAMESPACE).immutableTimestamp(immutableTimestamp).backupStartTimestamp(3141L).lockToken(LockToken.of(UUID.randomUUID())).build();
externalBackupPersister.storeImmutableTimestamp(ATLAS_SERVICE, inProgressBackupToken);
assertThat(externalBackupPersister.getImmutableTimestamp(ATLAS_SERVICE)).contains(immutableTimestamp);
}
use of com.palantir.atlasdb.backup.api.InProgressBackupToken in project atlasdb by palantir.
the class AtlasBackupService method prepareBackup.
public Set<AtlasService> prepareBackup(Set<AtlasService> atlasServices) {
throwIfClosed(atlasServices);
Set<AtlasService> inProgressAndProposedBackups = Sets.union(atlasServices, inProgressBackups.keySet());
AtlasServices.throwIfAtlasServicesCollide(inProgressAndProposedBackups);
Map<Namespace, AtlasService> namespaceToServices = KeyedStream.of(atlasServices).mapKeys(AtlasService::getNamespace).collectToMap();
PrepareBackupRequest request = PrepareBackupRequest.of(namespaceToServices.keySet());
PrepareBackupResponse response = atlasBackupClient.prepareBackup(authHeader, request);
Map<AtlasService, InProgressBackupToken> tokensPerService = KeyedStream.of(response.getSuccessful()).mapKeys(token -> namespaceToServices.get(token.getNamespace())).collectToMap();
KeyedStream.stream(tokensPerService).forEach(this::storeBackupToken);
return tokensPerService.keySet();
}
Aggregations