Search in sources :

Example 6 with StatusAndMessages

use of org.apache.hadoop.ozone.upgrade.UpgradeFinalizer.StatusAndMessages in project ozone by apache.

the class TestBasicUpgradeFinalizer method testFinalizerPhasesAreInvokedInOrder.

@Test
public void testFinalizerPhasesAreInvokedInOrder() throws IOException {
    SimpleTestFinalizer finalizer = spy(SimpleTestFinalizer.class);
    InOrder inOrder = inOrder(finalizer);
    Object mockObj = mock(Object.class);
    doCallRealMethod().when(finalizer).finalize(anyString(), ArgumentMatchers.eq(mockObj));
    finalizer.finalize("test-client-1", mockObj);
    StatusAndMessages res = finalizer.reportStatus("test-client-1", false);
    assertEquals(FINALIZATION_DONE, res.status());
    inOrder.verify(finalizer).preFinalizeUpgrade(ArgumentMatchers.eq(mockObj));
    inOrder.verify(finalizer).finalizeUpgrade(ArgumentMatchers.eq(mockObj));
    inOrder.verify(finalizer).postFinalizeUpgrade(ArgumentMatchers.eq(mockObj));
    assertTrue(finalizer.isFinalizationDone());
    assertTrue(finalizer.preCalled && finalizer.finalizeCalled && finalizer.postCalled);
}
Also used : InOrder(org.mockito.InOrder) StatusAndMessages(org.apache.hadoop.ozone.upgrade.UpgradeFinalizer.StatusAndMessages) Test(org.junit.Test)

Example 7 with StatusAndMessages

use of org.apache.hadoop.ozone.upgrade.UpgradeFinalizer.StatusAndMessages in project ozone by apache.

the class TestHDDSUpgrade method testFinalizationWithFailureInjectionHelper.

public void testFinalizationWithFailureInjectionHelper(Thread failureInjectionThread) throws Exception {
    waitForPipelineCreated();
    createTestContainers();
    createKey();
    // Test the Pre-Upgrade conditions on SCM as well as DataNodes.
    testPreUpgradeConditionsSCM();
    testPreUpgradeConditionsDataNodes();
    // Trigger Finalization on the SCM
    StatusAndMessages status = scm.finalizeUpgrade("xyz");
    Assert.assertEquals(STARTING_FINALIZATION, status.status());
    // has completed its job.
    if (failureInjectionThread != null) {
        failureInjectionThread.join();
    }
    // ALREADY_FINALIZED state as well.
    while ((status.status() != FINALIZATION_DONE) && (status.status() != ALREADY_FINALIZED)) {
        loadSCMState();
        status = scm.queryUpgradeFinalizationProgress("xyz", true, false);
        if (status.status() == FINALIZATION_REQUIRED) {
            status = scm.finalizeUpgrade("xyz");
        }
    }
    // Verify Post-Upgrade conditions on the SCM.
    // With failure injection
    testPostUpgradeConditionsSCM();
    // All datanodes on the SCM should have moved to HEALTHY-READONLY state.
    // Due to timing constraint also allow a "HEALTHY" state.
    loadSCMState();
    testDataNodesStateOnSCM(HEALTHY_READONLY, HEALTHY);
    // Need to wait for post finalization heartbeat from DNs.
    LambdaTestUtils.await(600000, 500, () -> {
        try {
            loadSCMState();
            testDataNodesStateOnSCM(HEALTHY, null);
            sleep(100);
        } catch (Throwable ex) {
            LOG.info(ex.getMessage());
            return false;
        }
        return true;
    });
    // Verify the SCM has driven all the DataNodes through Layout Upgrade.
    testPostUpgradeConditionsDataNodes();
    // Verify that new pipeline can be created with upgraded datanodes.
    try {
        testPostUpgradePipelineCreation();
    } catch (SCMException e) {
        // for this i.e. all datanodes are already part of some pipeline.
        for (HddsDatanodeService dataNode : cluster.getHddsDatanodes()) {
            DatanodeStateMachine dsm = dataNode.getDatanodeStateMachine();
            Set<PipelineID> pipelines = scm.getScmNodeManager().getPipelines(dsm.getDatanodeDetails());
            Assert.assertTrue(pipelines != null);
        }
    }
}
Also used : Set(java.util.Set) StatusAndMessages(org.apache.hadoop.ozone.upgrade.UpgradeFinalizer.StatusAndMessages) HddsDatanodeService(org.apache.hadoop.ozone.HddsDatanodeService) DatanodeStateMachine(org.apache.hadoop.ozone.container.common.statemachine.DatanodeStateMachine) SCMException(org.apache.hadoop.hdds.scm.exceptions.SCMException)

Example 8 with StatusAndMessages

use of org.apache.hadoop.ozone.upgrade.UpgradeFinalizer.StatusAndMessages in project ozone by apache.

the class StorageContainerLocationProtocolServerSideTranslatorPB method getFinalizeScmUpgrade.

public FinalizeScmUpgradeResponseProto getFinalizeScmUpgrade(FinalizeScmUpgradeRequestProto request) throws IOException {
    StatusAndMessages progress = impl.finalizeScmUpgrade(request.getUpgradeClientId());
    UpgradeFinalizationStatus.Status protoStatus = UpgradeFinalizationStatus.Status.valueOf(progress.status().name());
    UpgradeFinalizationStatus response = UpgradeFinalizationStatus.newBuilder().setStatus(protoStatus).addAllMessages(progress.msgs()).build();
    return FinalizeScmUpgradeResponseProto.newBuilder().setStatus(response).build();
}
Also used : UpgradeFinalizationStatus(org.apache.hadoop.hdds.protocol.proto.HddsProtos.UpgradeFinalizationStatus) StatusAndMessages(org.apache.hadoop.ozone.upgrade.UpgradeFinalizer.StatusAndMessages)

Example 9 with StatusAndMessages

use of org.apache.hadoop.ozone.upgrade.UpgradeFinalizer.StatusAndMessages in project ozone by apache.

the class OzoneManagerProtocolClientSideTranslatorPB method queryUpgradeFinalizationProgress.

@Override
public StatusAndMessages queryUpgradeFinalizationProgress(String upgradeClientID, boolean takeover, boolean readonly) throws IOException {
    FinalizeUpgradeProgressRequest req = FinalizeUpgradeProgressRequest.newBuilder().setUpgradeClientId(upgradeClientID).setTakeover(takeover).setReadonly(readonly).build();
    OMRequest omRequest = createOMRequest(Type.FinalizeUpgradeProgress).setFinalizeUpgradeProgressRequest(req).build();
    FinalizeUpgradeProgressResponse response = handleError(submitRequest(omRequest)).getFinalizeUpgradeProgressResponse();
    UpgradeFinalizationStatus status = response.getStatus();
    return new StatusAndMessages(UpgradeFinalizer.Status.valueOf(status.getStatus().name()), status.getMessagesList());
}
Also used : OMRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest) FinalizeUpgradeProgressResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.FinalizeUpgradeProgressResponse) UpgradeFinalizationStatus(org.apache.hadoop.hdds.protocol.proto.HddsProtos.UpgradeFinalizationStatus) StatusAndMessages(org.apache.hadoop.ozone.upgrade.UpgradeFinalizer.StatusAndMessages) FinalizeUpgradeProgressRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.FinalizeUpgradeProgressRequest)

Example 10 with StatusAndMessages

use of org.apache.hadoop.ozone.upgrade.UpgradeFinalizer.StatusAndMessages in project ozone by apache.

the class OzoneManagerRequestHandler method reportUpgradeProgress.

private FinalizeUpgradeProgressResponse reportUpgradeProgress(FinalizeUpgradeProgressRequest request) throws IOException {
    String upgradeClientId = request.getUpgradeClientId();
    boolean takeover = request.getTakeover();
    boolean readonly = request.getReadonly();
    StatusAndMessages progress = impl.queryUpgradeFinalizationProgress(upgradeClientId, takeover, readonly);
    UpgradeFinalizationStatus.Status protoStatus = UpgradeFinalizationStatus.Status.valueOf(progress.status().name());
    UpgradeFinalizationStatus response = UpgradeFinalizationStatus.newBuilder().setStatus(protoStatus).addAllMessages(progress.msgs()).build();
    return FinalizeUpgradeProgressResponse.newBuilder().setStatus(response).build();
}
Also used : UpgradeFinalizationStatus(org.apache.hadoop.hdds.protocol.proto.HddsProtos.UpgradeFinalizationStatus) StatusAndMessages(org.apache.hadoop.ozone.upgrade.UpgradeFinalizer.StatusAndMessages)

Aggregations

StatusAndMessages (org.apache.hadoop.ozone.upgrade.UpgradeFinalizer.StatusAndMessages)22 Test (org.junit.Test)11 UpgradeFinalizationStatus (org.apache.hadoop.hdds.protocol.proto.HddsProtos.UpgradeFinalizationStatus)8 IOException (java.io.IOException)6 Preconditions (com.google.common.base.Preconditions)2 RpcController (com.google.protobuf.RpcController)2 ServiceException (com.google.protobuf.ServiceException)2 Closeable (java.io.Closeable)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 Optional (java.util.Optional)2 Consumer (java.util.function.Consumer)2 Pair (org.apache.commons.lang3.tuple.Pair)2 InterfaceAudience (org.apache.hadoop.hdds.annotation.InterfaceAudience)2 HddsProtos (org.apache.hadoop.hdds.protocol.proto.HddsProtos)2 GetScmInfoResponseProto (org.apache.hadoop.hdds.protocol.proto.HddsProtos.GetScmInfoResponseProto)2 StorageContainerLocationProtocolProtos (org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos)2 ActivatePipelineRequestProto (org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ActivatePipelineRequestProto)2