Search in sources :

Example 1 with BackupInfo

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");
}
Also used : BackupInfo(org.apache.asterix.event.model.BackupInfo) AsterixInstance(org.apache.asterix.event.model.AsterixInstance) Patterns(org.apache.asterix.event.schema.pattern.Patterns)

Example 2 with BackupInfo

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);
}
Also used : BackupInfo(org.apache.asterix.event.model.BackupInfo) Backup(org.apache.asterix.installer.schema.conf.Backup) AsterixInstance(org.apache.asterix.event.model.AsterixInstance) Patterns(org.apache.asterix.event.schema.pattern.Patterns) Date(java.util.Date)

Example 3 with BackupInfo

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);
}
Also used : BackupInfo(org.apache.asterix.event.model.BackupInfo) Pattern(org.apache.asterix.event.schema.pattern.Pattern) ArrayList(java.util.ArrayList) Patterns(org.apache.asterix.event.schema.pattern.Patterns) HashSet(java.util.HashSet)

Aggregations

BackupInfo (org.apache.asterix.event.model.BackupInfo)3 Patterns (org.apache.asterix.event.schema.pattern.Patterns)3 AsterixInstance (org.apache.asterix.event.model.AsterixInstance)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1 Pattern (org.apache.asterix.event.schema.pattern.Pattern)1 Backup (org.apache.asterix.installer.schema.conf.Backup)1