Search in sources :

Example 1 with ReenableNamespacesResponse

use of com.palantir.atlasdb.timelock.api.ReenableNamespacesResponse in project atlasdb by palantir.

the class AllNodesDisabledNamespacesUpdaterTest method canReEnableSingleNamespace.

@Test
public void canReEnableSingleNamespace() {
    ReenableNamespacesRequest request = ReenableNamespacesRequest.of(ImmutableSet.of(NAMESPACE), LOCK_ID);
    when(remote1.reenable(AUTH_HEADER, request)).thenReturn(SUCCESSFUL_SINGLE_NODE_UPDATE);
    when(remote2.reenable(AUTH_HEADER, request)).thenReturn(SUCCESSFUL_SINGLE_NODE_UPDATE);
    when(localUpdater.reEnable(request)).thenReturn(SUCCESSFUL_SINGLE_NODE_UPDATE);
    ReenableNamespacesResponse response = updater.reEnableOnAllNodes(AUTH_HEADER, request);
    assertThat(response).isEqualTo(REENABLED_SUCCESSFULLY);
}
Also used : 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)

Example 2 with ReenableNamespacesResponse

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

Example 3 with ReenableNamespacesResponse

use of com.palantir.atlasdb.timelock.api.ReenableNamespacesResponse in project atlasdb by palantir.

the class AllNodesDisabledNamespacesUpdaterTest method reEnableDoesNotReportConsistentStateWhenNamespacesAreLockedWithDifferentIds.

@Test
public void reEnableDoesNotReportConsistentStateWhenNamespacesAreLockedWithDifferentIds() {
    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.reenable(any(), any())).thenReturn(lockedWithOtherLock);
    when(remote2.reenable(any(), any())).thenReturn(SingleNodeUpdateResponse.successful());
    when(localUpdater.reEnable(any())).thenReturn(lockedWithYetAnotherLock);
    ReenableNamespacesResponse reenableResponse = updater.reEnableOnAllNodes(AUTH_HEADER, ReenableNamespacesRequest.of(namespaces, LOCK_ID));
    assertThat(reenableResponse).isEqualTo(partiallyLocked(namespaces));
    verify(remote1, never()).disable(any(), any());
    verify(remote2, never()).disable(any(), any());
}
Also used : UnsuccessfulReenableNamespacesResponse(com.palantir.atlasdb.timelock.api.UnsuccessfulReenableNamespacesResponse) SuccessfulReenableNamespacesResponse(com.palantir.atlasdb.timelock.api.SuccessfulReenableNamespacesResponse) ReenableNamespacesResponse(com.palantir.atlasdb.timelock.api.ReenableNamespacesResponse) 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 4 with ReenableNamespacesResponse

use of com.palantir.atlasdb.timelock.api.ReenableNamespacesResponse in project atlasdb by palantir.

the class AllNodesDisabledNamespacesUpdaterTest method doesNotReEnableIfSomeNamespaceDisabledWithOtherLock.

// Case B: re-enable with wrong lock -> don't re-enable anywhere
@Test
public void doesNotReEnableIfSomeNamespaceDisabledWithOtherLock() {
    Set<Namespace> disabledNamespaces = ImmutableSet.of(OTHER_NAMESPACE);
    SingleNodeUpdateResponse unsuccessfulResponse = singleNodeUpdateFailure(disabledNamespaces);
    when(remote1.reenable(any(), any())).thenReturn(unsuccessfulResponse);
    when(remote2.reenable(any(), any())).thenReturn(unsuccessfulResponse);
    when(localUpdater.reEnable(any())).thenReturn(unsuccessfulResponse);
    ReenableNamespacesResponse response = updater.reEnableOnAllNodes(AUTH_HEADER, ReenableNamespacesRequest.of(BOTH_NAMESPACES, LOCK_ID));
    assertThat(response).isEqualTo(consistentlyLocked(disabledNamespaces));
}
Also used : UnsuccessfulReenableNamespacesResponse(com.palantir.atlasdb.timelock.api.UnsuccessfulReenableNamespacesResponse) SuccessfulReenableNamespacesResponse(com.palantir.atlasdb.timelock.api.SuccessfulReenableNamespacesResponse) ReenableNamespacesResponse(com.palantir.atlasdb.timelock.api.ReenableNamespacesResponse) 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 5 with ReenableNamespacesResponse

use of com.palantir.atlasdb.timelock.api.ReenableNamespacesResponse 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

ReenableNamespacesResponse (com.palantir.atlasdb.timelock.api.ReenableNamespacesResponse)5 SuccessfulReenableNamespacesResponse (com.palantir.atlasdb.timelock.api.SuccessfulReenableNamespacesResponse)5 UnsuccessfulReenableNamespacesResponse (com.palantir.atlasdb.timelock.api.UnsuccessfulReenableNamespacesResponse)5 Test (org.junit.Test)5 Namespace (com.palantir.atlasdb.timelock.api.Namespace)3 ReenableNamespacesRequest (com.palantir.atlasdb.timelock.api.ReenableNamespacesRequest)3 ImmutableSingleNodeUpdateResponse (com.palantir.atlasdb.timelock.api.ImmutableSingleNodeUpdateResponse)2 SingleNodeUpdateResponse (com.palantir.atlasdb.timelock.api.SingleNodeUpdateResponse)2 SafeRuntimeException (com.palantir.logsafe.exceptions.SafeRuntimeException)1