Skip to content

Commit

Permalink
[Improve] app backup minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfboys committed Oct 8, 2024
1 parent bbe7731 commit 90c86ea
Showing 1 changed file with 14 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,37 +207,22 @@ public Boolean delete(Long id) throws InternalException {
@Override
@Transactional(rollbackFor = {Exception.class})
public void backup(Application application, FlinkSql flinkSql) {
// basic configuration file backup
log.info("skip backup..");
if (application != null) {
return;
ApplicationConfig config = configService.getEffective(application.getId());
if (config != null) {
application.setConfigId(config.getId());
}
// flink sql tasks need to back up sql and dependencies
int version = 1;
if (flinkSql != null) {
application.setSqlId(flinkSql.getId());
version = flinkSql.getVersion();
} else if (config != null) {
version = config.getVersion();
}
String appHome =
(application.isCustomCodeJob() && application.isCICDJob())
? application.getDistHome()
: application.getAppHome();
FsOperator fsOperator = application.getFsOperator();
if (fsOperator.exists(appHome)) {
// move files to back up directory
ApplicationConfig config = configService.getEffective(application.getId());
if (config != null) {
application.setConfigId(config.getId());
}
// flink sql tasks need to back up sql and dependencies
int version = 1;
if (flinkSql != null) {
application.setSqlId(flinkSql.getId());
version = flinkSql.getVersion();
} else if (config != null) {
version = config.getVersion();
}

ApplicationBackUp applicationBackUp = new ApplicationBackUp(application);
applicationBackUp.setVersion(version);
ApplicationBackUp applicationBackUp = new ApplicationBackUp(application);
applicationBackUp.setVersion(version);

this.save(applicationBackUp);
fsOperator.mkdirs(applicationBackUp.getPath());
fsOperator.copyDir(appHome, applicationBackUp.getPath());
}
this.save(applicationBackUp);
}
}

0 comments on commit 90c86ea

Please sign in to comment.