use of com.creditease.uav.feature.upgrade.beans.UpgradeContext in project uavstack by uavorg.
the class UpgradeOperationRecordConsumer method parseOldUpgradeRecord.
private void parseOldUpgradeRecord(String feature, String upgradeInfo) throws Exception {
String rootDir = null;
if (!StringHelper.isEmpty(upgradeInfo)) {
UpgradeConfig config = new UpgradeConfig(upgradeInfo);
if (config.isUAV()) {
if (log.isTraceEnable()) {
log.info(this, "Parsing record: uav upgrade process");
}
rootDir = ConfigurationManager.getInstance().getContext(IConfigurationManager.ROOT);
}
}
if (StringHelper.isEmpty(rootDir)) {
throw new Exception("no root directory");
}
Path recordFilePath = Paths.get(rootDir.replace("\"", ""), UpgradeConstants.UPGRADE_RECORD_FILE_NAME);
if (!Files.exists(recordFilePath)) {
throw new Exception("no operation record file");
}
List<String> recordStrList = Files.readAllLines(recordFilePath, Charset.forName("utf-8"));
// construct upgradeContext with the first line of record list, that is, the first record stores upgrade
// parameters.
this.upgradeContext = new UpgradeContext(new UpgradeConfig(recordStrList.remove(0)), true);
for (String recordStr : recordStrList) {
this.recordList.add(new UpgradeOperationRecord(recordStr));
}
}
use of com.creditease.uav.feature.upgrade.beans.UpgradeContext 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