Search in sources :

Example 1 with UpgradeException

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;
}
Also used : UpgradeException(org.apache.hadoop.ozone.upgrade.UpgradeException) StatusAndMessages(org.apache.hadoop.ozone.upgrade.UpgradeFinalizer.StatusAndMessages) IOException(java.io.IOException)

Example 2 with UpgradeException

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;
}
Also used : UpgradeException(org.apache.hadoop.ozone.upgrade.UpgradeException) UpgradeFinalizer(org.apache.hadoop.ozone.upgrade.UpgradeFinalizer) OzoneManagerProtocol(org.apache.hadoop.ozone.om.protocol.OzoneManagerProtocol) IOException(java.io.IOException)

Example 3 with UpgradeException

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());
}
Also used : UpgradeException(org.apache.hadoop.ozone.upgrade.UpgradeException) OzoneManager(org.apache.hadoop.ozone.om.OzoneManager) StatusAndMessages(org.apache.hadoop.ozone.upgrade.UpgradeFinalizer.StatusAndMessages) IOException(java.io.IOException) ExpectedException(org.junit.rules.ExpectedException) UpgradeException(org.apache.hadoop.ozone.upgrade.UpgradeException) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

IOException (java.io.IOException)3 UpgradeException (org.apache.hadoop.ozone.upgrade.UpgradeException)3 StatusAndMessages (org.apache.hadoop.ozone.upgrade.UpgradeFinalizer.StatusAndMessages)2 OzoneManager (org.apache.hadoop.ozone.om.OzoneManager)1 OzoneManagerProtocol (org.apache.hadoop.ozone.om.protocol.OzoneManagerProtocol)1 UpgradeFinalizer (org.apache.hadoop.ozone.upgrade.UpgradeFinalizer)1 Test (org.junit.Test)1 ExpectedException (org.junit.rules.ExpectedException)1