Search in sources :

Example 1 with UpgradeOperationRecordConsumer

use of com.creditease.uav.feature.upgrade.record.UpgradeOperationRecordConsumer 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();
}
Also used : UpgradeOperationRecordConsumer(com.creditease.uav.feature.upgrade.record.UpgradeOperationRecordConsumer) UpgradeConfig(com.creditease.uav.feature.upgrade.beans.UpgradeConfig) BackupAction(com.creditease.uav.feature.upgrade.action.BackupAction) EndAction(com.creditease.uav.feature.upgrade.action.EndAction) UpgradeContext(com.creditease.uav.feature.upgrade.beans.UpgradeContext) PackageDownloadAction(com.creditease.uav.feature.upgrade.action.PackageDownloadAction)

Aggregations

BackupAction (com.creditease.uav.feature.upgrade.action.BackupAction)1 EndAction (com.creditease.uav.feature.upgrade.action.EndAction)1 PackageDownloadAction (com.creditease.uav.feature.upgrade.action.PackageDownloadAction)1 UpgradeConfig (com.creditease.uav.feature.upgrade.beans.UpgradeConfig)1 UpgradeContext (com.creditease.uav.feature.upgrade.beans.UpgradeContext)1 UpgradeOperationRecordConsumer (com.creditease.uav.feature.upgrade.record.UpgradeOperationRecordConsumer)1