use of com.palantir.atlasdb.timelock.api.ReenableNamespacesRequest in project atlasdb by palantir.
the class TimeLockManagementResourceTest method reEnableTimeLockCallsUpdater.
@Test
public void reEnableTimeLockCallsUpdater() {
ReenableNamespacesRequest request = ReenableNamespacesRequest.of(NAMESPACES, LOCK_ID);
timeLockManagementResource.reenableTimelock(AUTH_HEADER, request);
verify(allNodesDisabledNamespacesUpdater).reEnableOnAllNodes(AUTH_HEADER, request);
}
use of com.palantir.atlasdb.timelock.api.ReenableNamespacesRequest in project atlasdb by palantir.
the class AllNodesDisabledNamespacesUpdater method attemptReEnableOnNodes.
// ReEnable
private boolean attemptReEnableOnNodes(AuthHeader authHeader, Set<Namespace> namespaces, String lockId, List<DisabledNamespacesUpdaterService> successfulNodes) {
ReenableNamespacesRequest request = ReenableNamespacesRequest.builder().namespaces(namespaces).lockId(lockId).build();
Collection<SingleNodeUpdateResponse> responses = reEnableNamespacesOnRemoteNodes(authHeader, request, successfulNodes);
return responses.stream().filter(SingleNodeUpdateResponse::isSuccessful).count() == successfulNodes.size();
}
use of com.palantir.atlasdb.timelock.api.ReenableNamespacesRequest in project atlasdb by palantir.
the class AllNodesDisabledNamespacesUpdaterTest method rollsBackDisableIfInconsistentStateIsFound.
// Case C: If we start with an inconsistent state, we roll back our request
@Test
public void rollsBackDisableIfInconsistentStateIsFound() {
Set<Namespace> disabledNamespaces = ImmutableSet.of(OTHER_NAMESPACE);
SingleNodeUpdateResponse unsuccessfulResponse = singleNodeUpdateFailure(disabledNamespaces);
when(remote1.disable(any(), any())).thenReturn(unsuccessfulResponse);
when(remote2.disable(any(), any())).thenReturn(SUCCESSFUL_SINGLE_NODE_UPDATE);
when(remote2.reenable(any(), any())).thenReturn(SUCCESSFUL_SINGLE_NODE_UPDATE);
when(localUpdater.getNamespacesLockedWithDifferentLockId(any(), any())).thenReturn(ImmutableMap.of());
DisableNamespacesResponse response = updater.disableOnAllNodes(AUTH_HEADER, disableNamespacesRequest(ImmutableSet.of(NAMESPACE, OTHER_NAMESPACE)));
ReenableNamespacesRequest rollbackRequest = ReenableNamespacesRequest.of(BOTH_NAMESPACES, LOCK_ID);
verify(remote1, never()).reenable(any(), any());
verify(remote2).reenable(AUTH_HEADER, rollbackRequest);
verify(localUpdater, never()).reEnable(any());
assertThat(response).isEqualTo(partiallyDisabled(BOTH_NAMESPACES));
}
use of com.palantir.atlasdb.timelock.api.ReenableNamespacesRequest in project atlasdb by palantir.
the class AllNodesDisabledNamespacesUpdaterTest method rollsBackDisabledNamespacesAfterPartialFailure.
// Case A: start with no disabled namespaces; disable fails on some node; we should re-enable all
@Test
public void rollsBackDisabledNamespacesAfterPartialFailure() {
Set<Namespace> failedNamespaces = ImmutableSet.of(OTHER_NAMESPACE);
when(remote1.disable(any(), any())).thenReturn(SUCCESSFUL_SINGLE_NODE_UPDATE);
when(remote2.disable(any(), any())).thenReturn(singleNodeUpdateFailure(failedNamespaces));
when(remote1.reenable(any(), any())).thenReturn(SUCCESSFUL_SINGLE_NODE_UPDATE);
when(localUpdater.getNamespacesLockedWithDifferentLockId(any(), any())).thenReturn(ImmutableMap.of());
DisableNamespacesResponse response = updater.disableOnAllNodes(AUTH_HEADER, disableNamespacesRequest(BOTH_NAMESPACES));
ReenableNamespacesRequest rollbackRequest = ReenableNamespacesRequest.of(BOTH_NAMESPACES, LOCK_ID);
verify(remote1).reenable(AUTH_HEADER, rollbackRequest);
verify(remote2, never()).reenable(AUTH_HEADER, rollbackRequest);
verify(localUpdater, never()).disable(any());
assertThat(response).isEqualTo(partiallyDisabled(BOTH_NAMESPACES));
}
use of com.palantir.atlasdb.timelock.api.ReenableNamespacesRequest in project atlasdb by palantir.
the class AllNodesDisabledNamespacesUpdaterTest method handlesNodesBecomingUnreachableDuringReEnable.
@Test
public void handlesNodesBecomingUnreachableDuringReEnable() {
when(remote1.reenable(any(), any())).thenReturn(SUCCESSFUL_SINGLE_NODE_UPDATE);
when(remote2.reenable(any(), any())).thenThrow(new SafeRuntimeException("unreachable"));
when(localUpdater.reEnable(any())).thenReturn(SUCCESSFUL_SINGLE_NODE_UPDATE);
ReenableNamespacesRequest request = ReenableNamespacesRequest.of(BOTH_NAMESPACES, LOCK_ID);
ReenableNamespacesResponse response = updater.reEnableOnAllNodes(AUTH_HEADER, request);
assertThat(response).isEqualTo(partiallyLocked(ImmutableSet.of()));
}
Aggregations