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