use of org.opennms.upgrade.api.OnmsUpgradeException in project opennms by OpenNMS.
the class Upgrade method executeUpgrade.
/**
* Execute upgrade.
*
* @param upg the upgrade implementation class
*/
protected void executeUpgrade(OnmsUpgrade upg) {
Date start = new Date();
try {
if (wasExecuted(upg)) {
log(" Task %s has been executed at %s\n", upg.getId(), getUpgradeStatus().getLastExecutionTime(upg));
return;
}
log("- Running pre-execution phase\n");
upg.preExecute();
} catch (OnmsUpgradeException e) {
log(" Ignoring: %s\n", e.getMessage());
return;
}
try {
log("- Running execution phase\n");
upg.execute();
log("- Saving the execution state\n");
markAsExecuted(upg);
} catch (OnmsUpgradeException executeException) {
log(" Warning: can't perform the upgrade operation because: %s\n", executeException.getMessage());
try {
log("- Executing rollback phase\n");
upg.rollback();
} catch (OnmsUpgradeException rollbackException) {
log(" Warning: can't rollback the upgrade because: %s\n", rollbackException.getMessage());
rollbackException.printStackTrace();
}
}
try {
log("- Running post-execution phase\n");
upg.postExecute();
} catch (OnmsUpgradeException e) {
log(" Warning: can't run the post-execute phase because: %s\n", e.getMessage());
}
log("\nFinished in %s\n\n", FuzzyDateFormatter.calculateDifference(start, new Date()));
}
Aggregations