use of org.apache.hadoop.ozone.upgrade.UpgradeFinalizer.StatusAndMessages in project ozone by apache.
the class StorageContainerLocationProtocolClientSideTranslatorPB method finalizeScmUpgrade.
@Override
public StatusAndMessages finalizeScmUpgrade(String upgradeClientID) throws IOException {
FinalizeScmUpgradeRequestProto req = FinalizeScmUpgradeRequestProto.newBuilder().setUpgradeClientId(upgradeClientID).build();
FinalizeScmUpgradeResponseProto response = submitRequest(Type.FinalizeScmUpgrade, builder -> builder.setFinalizeScmUpgradeRequest(req)).getFinalizeScmUpgradeResponse();
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 StorageContainerLocationProtocolClientSideTranslatorPB method queryUpgradeFinalizationProgress.
@Override
public StatusAndMessages queryUpgradeFinalizationProgress(String upgradeClientID, boolean force, boolean readonly) throws IOException {
QueryUpgradeFinalizationProgressRequestProto req = QueryUpgradeFinalizationProgressRequestProto.newBuilder().setUpgradeClientId(upgradeClientID).setTakeover(force).setReadonly(readonly).build();
QueryUpgradeFinalizationProgressResponseProto response = submitRequest(Type.QueryUpgradeFinalizationProgress, builder -> builder.setQueryUpgradeFinalizationProgressRequest(req)).getQueryUpgradeFinalizationProgressResponse();
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 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.UpgradeFinalizer.StatusAndMessages in project ozone by apache.
the class TestOMUpgradeFinalization method testOmFinalization.
/**
* Currently this is a No-Op finalization since there is only one layout
* version in OM. But this test is expected to remain consistent when a
* new version is added.
*/
@Test
public void testOmFinalization() throws Exception {
// Assert OM Layout Version is 'fromLayoutVersion' on deploy.
assertEquals(fromLayoutVersion, ozoneManager.getVersionManager().getMetadataLayoutVersion());
assertNull(ozoneManager.getMetadataManager().getMetaTable().get(LAYOUT_VERSION_KEY));
OzoneManagerProtocol omClient = clientProtocol.getOzoneManagerClient();
StatusAndMessages response = omClient.finalizeUpgrade("finalize-test");
System.out.println("Finalization Messages : " + response.msgs());
waitForFinalization(omClient);
LambdaTestUtils.await(30000, 3000, () -> {
String lvString = ozoneManager.getMetadataManager().getMetaTable().get(LAYOUT_VERSION_KEY);
return maxLayoutVersion() == Integer.parseInt(lvString);
});
}
use of org.apache.hadoop.ozone.upgrade.UpgradeFinalizer.StatusAndMessages in project ozone by apache.
the class TestBasicUpgradeFinalizer method testAlreadyFinalizedDoesNotTriggerNewFinalization.
@Test
public void testAlreadyFinalizedDoesNotTriggerNewFinalization() throws IOException {
SimpleTestFinalizer finalizer = new SimpleTestFinalizer(new MockLayoutVersionManager(VERSION_3.layoutVersion()));
Object mockObj = mock(Object.class);
StatusAndMessages res = finalizer.finalize("test-client-1", mockObj);
assertEquals(ALREADY_FINALIZED, res.status());
assertFalse(finalizer.preCalled || finalizer.finalizeCalled || finalizer.postCalled);
}
Aggregations