use of com.creditease.uav.feature.upgrade.action.BackupAction in project uavstack by uavorg.
the class UpgradeAgent method start.
@SuppressWarnings("unused")
@Override
public void start() {
// initial ActionEngine
this.engine = this.getActionEngineMgr().newActionEngine("UpgradeActionEngine", this.feature);
String restart = System.getProperty("StartByCronTask");
String upgradeInfo = System.getProperty(UPGRADE_INFO);
if (log.isTraceEnable()) {
log.info(this, "Upgrade param info is " + upgradeInfo);
log.info(this, System.getProperty("java.class.path"));
}
if (DataConvertHelper.toInt(restart, Integer.MIN_VALUE) == 1) {
if (log.isTraceEnable()) {
log.info(this, "This upgrade process was restarted by cron task ");
}
ThreadHelper.suspend(3000);
UpgradeOperationRecordConsumer consumer = new UpgradeOperationRecordConsumer("UpgradeOperationRecordConsumer", this.feature, this.engine);
consumer.handleOperationRecord(upgradeInfo);
return;
}
this.upgradeContext = new UpgradeContext(new UpgradeConfig(upgradeInfo));
this.endAction = new EndAction(this.feature, upgradeContext, engine);
checkVersion4Upgrade(endAction);
String host = this.getConfigManager().getFeatureConfiguration(this.feature, "http.server.host");
int port = DataConvertHelper.toInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.server.port"), UpgradeConstants.DEFAULT_HTTP_PORT);
if (StringHelper.isEmpty(host)) {
if (log.isTraceEnable()) {
log.warn(this, "Invalid http server host");
}
endAction.stopUpgradeProcess();
return;
}
if (!this.upgradeContext.getFileLock()) {
if (log.isTraceEnable()) {
log.warn(this, "Can not get the lock of " + UpgradeConstants.UPGRADE_FILE_LOCK_NAME + ", another upgrade process is running");
}
endAction.stopUpgradeProcess();
return;
}
BackupAction backupAction = new BackupAction(this.feature, upgradeContext, engine);
PackageDownloadAction downloadAction = new PackageDownloadAction(this.feature, upgradeContext, engine, host, port);
registerActionsAccordingUpgradeTarget();
workThread = new Thread(this, "Upgrade Thread");
workThread.start();
}
Aggregations