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