Search in sources :

Example 6 with ReenableNamespacesRequest

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);
}
Also used : ReenableNamespacesRequest(com.palantir.atlasdb.timelock.api.ReenableNamespacesRequest) Test(org.junit.Test)

Example 7 with ReenableNamespacesRequest

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();
}
Also used : ReenableNamespacesRequest(com.palantir.atlasdb.timelock.api.ReenableNamespacesRequest) SingleNodeUpdateResponse(com.palantir.atlasdb.timelock.api.SingleNodeUpdateResponse)

Example 8 with ReenableNamespacesRequest

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));
}
Also used : SuccessfulDisableNamespacesResponse(com.palantir.atlasdb.timelock.api.SuccessfulDisableNamespacesResponse) UnsuccessfulDisableNamespacesResponse(com.palantir.atlasdb.timelock.api.UnsuccessfulDisableNamespacesResponse) DisableNamespacesResponse(com.palantir.atlasdb.timelock.api.DisableNamespacesResponse) ReenableNamespacesRequest(com.palantir.atlasdb.timelock.api.ReenableNamespacesRequest) Namespace(com.palantir.atlasdb.timelock.api.Namespace) SingleNodeUpdateResponse(com.palantir.atlasdb.timelock.api.SingleNodeUpdateResponse) ImmutableSingleNodeUpdateResponse(com.palantir.atlasdb.timelock.api.ImmutableSingleNodeUpdateResponse) Test(org.junit.Test)

Example 9 with ReenableNamespacesRequest

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));
}
Also used : SuccessfulDisableNamespacesResponse(com.palantir.atlasdb.timelock.api.SuccessfulDisableNamespacesResponse) UnsuccessfulDisableNamespacesResponse(com.palantir.atlasdb.timelock.api.UnsuccessfulDisableNamespacesResponse) DisableNamespacesResponse(com.palantir.atlasdb.timelock.api.DisableNamespacesResponse) ReenableNamespacesRequest(com.palantir.atlasdb.timelock.api.ReenableNamespacesRequest) Namespace(com.palantir.atlasdb.timelock.api.Namespace) Test(org.junit.Test)

Example 10 with ReenableNamespacesRequest

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()));
}
Also used : SafeRuntimeException(com.palantir.logsafe.exceptions.SafeRuntimeException) UnsuccessfulReenableNamespacesResponse(com.palantir.atlasdb.timelock.api.UnsuccessfulReenableNamespacesResponse) SuccessfulReenableNamespacesResponse(com.palantir.atlasdb.timelock.api.SuccessfulReenableNamespacesResponse) ReenableNamespacesResponse(com.palantir.atlasdb.timelock.api.ReenableNamespacesResponse) ReenableNamespacesRequest(com.palantir.atlasdb.timelock.api.ReenableNamespacesRequest) Test(org.junit.Test)

Aggregations

ReenableNamespacesRequest (com.palantir.atlasdb.timelock.api.ReenableNamespacesRequest)13 Test (org.junit.Test)12 Namespace (com.palantir.atlasdb.timelock.api.Namespace)8 DisableNamespacesResponse (com.palantir.atlasdb.timelock.api.DisableNamespacesResponse)5 SuccessfulDisableNamespacesResponse (com.palantir.atlasdb.timelock.api.SuccessfulDisableNamespacesResponse)5 UnsuccessfulDisableNamespacesResponse (com.palantir.atlasdb.timelock.api.UnsuccessfulDisableNamespacesResponse)5 CompleteRestoreRequest (com.palantir.atlasdb.backup.api.CompleteRestoreRequest)4 CompletedBackup (com.palantir.atlasdb.backup.api.CompletedBackup)4 AtlasService (com.palantir.atlasdb.backup.api.AtlasService)3 ReenableNamespacesResponse (com.palantir.atlasdb.timelock.api.ReenableNamespacesResponse)3 SuccessfulReenableNamespacesResponse (com.palantir.atlasdb.timelock.api.SuccessfulReenableNamespacesResponse)3 UnsuccessfulReenableNamespacesResponse (com.palantir.atlasdb.timelock.api.UnsuccessfulReenableNamespacesResponse)3 Optional (java.util.Optional)3 InOrder (org.mockito.InOrder)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 AtlasRestoreClient (com.palantir.atlasdb.backup.api.AtlasRestoreClient)2 CompleteRestoreResponse (com.palantir.atlasdb.backup.api.CompleteRestoreResponse)2 CassandraRepairHelper (com.palantir.atlasdb.cassandra.backup.CassandraRepairHelper)2 RangesForRepair (com.palantir.atlasdb.cassandra.backup.RangesForRepair)2