Search in sources :

Example 1 with EndAction

use of com.creditease.uav.feature.upgrade.action.EndAction in project uavstack by uavorg.

the class UpgradeOperationRecordConsumer method handleOperationRecord.

public void handleOperationRecord(String upgradeInfo) {
    EndAction endAction = new EndAction(this.feature, null, null);
    try {
        parseOldUpgradeRecord(feature, upgradeInfo);
    } catch (Exception e) {
        if (log.isTraceEnable()) {
            log.err(this, "Failed to parse upgrade record", e);
        }
        endAction.stopUpgradeProcess();
    }
    int length = this.recordList.size();
    if (length <= 1) {
        endAction.stopUpgradeProcess();
    }
    endAction = new EndAction(this.feature, this.upgradeContext, this.engine);
    if (!upgradeContext.getFileLock()) {
        if (log.isTraceEnable()) {
            log.warn(this, "Failed to get upgrade file lock");
        }
        endAction.stopUpgradeProcess();
    }
    UpgradeOperationRecord record = this.recordList.get(length - 1);
    if (upgradeContext.needRollback(record.getPhase())) {
        if (upgradeContext.isUAVContext()) {
            handleUAVOperationRecord(record, endAction);
        } else {
            handleThirdPartySoftwareOperationRecord(record);
        }
        return;
    }
    endAction.doAction(new ActionContext());
}
Also used : EndAction(com.creditease.uav.feature.upgrade.action.EndAction) ActionContext(com.creditease.agent.spi.ActionContext)

Example 2 with EndAction

use of com.creditease.uav.feature.upgrade.action.EndAction 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

EndAction (com.creditease.uav.feature.upgrade.action.EndAction)2 ActionContext (com.creditease.agent.spi.ActionContext)1 BackupAction (com.creditease.uav.feature.upgrade.action.BackupAction)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