use of org.apache.asterix.event.model.BackupInfo in project asterixdb by apache.
the class RestoreConfig method execCommand.
@Override
protected void execCommand() throws Exception {
InstallerDriver.initConfig(true);
String asterixInstanceName = ((RestoreConfig) config).name;
AsterixInstance instance = AsterixEventServiceUtil.validateAsterixInstanceExists(asterixInstanceName, State.INACTIVE);
int backupId = ((RestoreConfig) config).backupId;
List<BackupInfo> backupInfoList = instance.getBackupInfo();
if (backupInfoList.size() <= backupId || backupId < 0) {
throw new IllegalStateException("Invalid backup id");
}
BackupInfo backupInfo = backupInfoList.get(backupId);
Patterns patterns = PatternCreator.INSTANCE.getRestoreAsterixPattern(instance, backupInfo);
AsterixEventService.getAsterixEventServiceClient(instance.getCluster()).submit(patterns);
LOGGER.info("Asterix instance: " + asterixInstanceName + " has been restored from backup");
}
use of org.apache.asterix.event.model.BackupInfo in project asterixdb by apache.
the class BackupConfig method execCommand.
@Override
protected void execCommand() throws Exception {
InstallerDriver.initConfig(true);
String asterixInstanceName = ((BackupConfig) config).name;
AsterixInstance instance = AsterixEventServiceUtil.validateAsterixInstanceExists(asterixInstanceName, State.INACTIVE);
List<BackupInfo> backupInfo = instance.getBackupInfo();
Backup backupConf = AsterixEventService.getConfiguration().getBackup();
Patterns patterns = PatternCreator.INSTANCE.getBackUpAsterixPattern(instance, backupConf);
AsterixEventService.getAsterixEventServiceClient(instance.getCluster()).submit(patterns);
int backupId = backupInfo.size();
BackupInfo binfo = new BackupInfo(backupId, new Date(), backupConf);
backupInfo.add(binfo);
LOGGER.info(asterixInstanceName + " backed up " + binfo);
ServiceProvider.INSTANCE.getLookupService().updateAsterixInstance(instance);
}
use of org.apache.asterix.event.model.BackupInfo in project asterixdb by apache.
the class PatternCreator method createDeleteInstancePattern.
public Patterns createDeleteInstancePattern(AsterixInstance instance) throws Exception {
List<Pattern> patternList = new ArrayList<>();
patternList.addAll(createRemoveAsterixStoragePattern(instance).getPattern());
if (instance.getBackupInfo() != null && !instance.getBackupInfo().isEmpty()) {
List<BackupInfo> backups = instance.getBackupInfo();
Set<String> removedBackupDirsHDFS = new HashSet<>();
Set<String> removedBackupDirsLocal = new HashSet<>();
String backupDir;
for (BackupInfo binfo : backups) {
backupDir = binfo.getBackupConf().getBackupDir();
switch(binfo.getBackupType()) {
case HDFS:
if (removedBackupDirsHDFS.contains(backupDir)) {
continue;
}
patternList.addAll(createRemoveHDFSBackupPattern(instance, backupDir).getPattern());
removedBackupDirsHDFS.add(backupDir);
break;
case LOCAL:
if (removedBackupDirsLocal.contains(backupDir)) {
continue;
}
patternList.addAll(createRemoveLocalBackupPattern(instance, backupDir).getPattern());
removedBackupDirsLocal.add(backupDir);
break;
}
}
}
patternList.addAll(createRemoveAsterixLogDirPattern(instance).getPattern());
patternList.addAll(createRemoveAsterixRootMetadata(instance).getPattern());
patternList.addAll(createRemoveAsterixTxnLogs(instance).getPattern());
return new Patterns(patternList);
}
Aggregations