use of org.apache.hadoop.ozone.upgrade.UpgradeException in project ozone by apache.
the class FinalizeScmUpgradeSubcommand method execute.
@Override
public void execute(ScmClient scmClient) throws IOException {
String upgradeClientID = "Upgrade-Client-" + UUID.randomUUID().toString();
try {
StatusAndMessages finalizationResponse = scmClient.finalizeScmUpgrade(upgradeClientID);
if (isFinalized(finalizationResponse.status())) {
System.out.println("Upgrade has already been finalized.");
emitExitMsg();
return;
} else if (!isStarting(finalizationResponse.status())) {
System.err.println("Invalid response from Storage Container Manager.");
System.err.println("Current finalization status is: " + finalizationResponse.status());
throw new IOException("Exiting...");
}
} catch (UpgradeException e) {
handleInvalidRequestAfterInitiatingFinalization(force, e);
}
monitorAndWaitFinalization(scmClient, upgradeClientID);
return;
}
use of org.apache.hadoop.ozone.upgrade.UpgradeException in project ozone by apache.
the class FinalizeUpgradeSubCommand method call.
@Override
public Void call() throws Exception {
boolean forceHA = false;
OzoneManagerProtocol client = parent.createOmClient(omServiceId, omHost, forceHA);
String upgradeClientID = "Upgrade-Client-" + UUID.randomUUID().toString();
try {
UpgradeFinalizer.StatusAndMessages finalizationResponse = client.finalizeUpgrade(upgradeClientID);
if (isFinalized(finalizationResponse.status())) {
System.out.println("Upgrade has already been finalized.");
emitExitMsg();
return null;
} else if (!isStarting(finalizationResponse.status())) {
System.err.println("Invalid response from Ozone Manager.");
System.err.println("Current finalization status is: " + finalizationResponse.status());
throw new IOException("Exiting...");
}
} catch (UpgradeException e) {
handleInvalidRequestAfterInitiatingFinalization(force, e);
}
monitorAndWaitFinalization(client, upgradeClientID);
return null;
}
use of org.apache.hadoop.ozone.upgrade.UpgradeException in project ozone by apache.
the class TestOMUpgradeFinalizer method testFinalizationWithFailingUpgradeAction.
@Test
public void testFinalizationWithFailingUpgradeAction() throws Exception {
Optional<OmUpgradeAction> action = Optional.of(ignore -> {
throw new IOException("Fail.");
});
OzoneManager om = mockOzoneManager(0);
Iterable<OMLayoutFeature> lfs = mockFeatures("feature-1", "feature-2");
when(lfs.iterator().next().action(ON_FINALIZE)).thenReturn(action);
setupVersionManagerMockToFinalize(lfs);
OMUpgradeFinalizer finalizer = new OMUpgradeFinalizer(versionManager);
try {
finalizer.finalize(CLIENT_ID, om);
fail();
} catch (Exception e) {
assertThat(e, instanceOf(UpgradeException.class));
assertThat(e.getMessage(), containsString(lfs.iterator().next().name()));
assertEquals(((UpgradeException) e).getResult(), LAYOUT_FEATURE_FINALIZATION_FAILED);
}
if (finalizer.isFinalizationDone()) {
when(versionManager.getUpgradeState()).thenReturn(FINALIZATION_DONE);
}
// Verify that we have never updated the layout version.
Iterator<OMLayoutFeature> it = lfs.iterator();
OMLayoutFeature f = it.next();
verify(om.getOmStorage(), never()).setLayoutVersion(f.layoutVersion());
// Verify that we never got to the second feature.
f = it.next();
verify(om.getOmStorage(), never()).setLayoutVersion(f.layoutVersion());
StatusAndMessages status = finalizer.reportStatus(CLIENT_ID, false);
assertEquals(FINALIZATION_DONE, status.status());
assertFalse(status.msgs().isEmpty());
}
Aggregations