Search in sources :

Example 11 with BackupRestoreStatus

use of com.emc.vipr.model.sys.backup.BackupRestoreStatus in project coprhd-controller by CoprHD.

the class BackupOps method updateRestoreStatus.

public void updateRestoreStatus(String backupName, boolean isLocal, BackupRestoreStatus.Status newStatus, String details, Map<String, Long> downloadSize, long increasedSize, boolean increaseCompletedNodeNumber, List<String> backupfileNames, boolean doLog, boolean doLock) {
    InterProcessLock lock = null;
    try {
        if (doLock) {
            lock = getLock(BackupConstants.RESTORE_STATUS_UPDATE_LOCK, -1, // -1= no timeout
            TimeUnit.MILLISECONDS);
            if (doLog) {
                log.info("get lock {}", BackupConstants.RESTORE_STATUS_UPDATE_LOCK);
            }
        }
        BackupRestoreStatus currentStatus = queryBackupRestoreStatus(backupName, isLocal);
        if (!canBeUpdated(newStatus, currentStatus)) {
            log.info("Can't update the status from {} to {}", currentStatus, newStatus);
            return;
        }
        currentStatus.setBackupName(backupName);
        if (newStatus != null) {
            currentStatus.setStatusWithDetails(newStatus, details);
        }
        if (downloadSize != null) {
            currentStatus.setSizeToDownload(downloadSize);
        }
        if (increasedSize > 0) {
            String localHostID = getLocalHostID();
            currentStatus.increaseDownloadedSize(localHostID, increasedSize);
        }
        if (increaseCompletedNodeNumber) {
            currentStatus.increaseNodeCompleted();
        }
        if (backupfileNames != null) {
            currentStatus.setBackupFileNames(backupfileNames);
        }
        updateBackupRestoreStatus(currentStatus, backupName);
        persistBackupRestoreStatus(currentStatus, isLocal, doLog);
        if (doLog) {
            log.info("Persist backup restore newStatus {} to zk successfully", currentStatus);
        }
    } finally {
        if (doLock) {
            if (doLog) {
                log.info("To release lock {}", BackupConstants.RESTORE_STATUS_UPDATE_LOCK);
            }
            releaseLock(lock);
        }
    }
}
Also used : BackupRestoreStatus(com.emc.vipr.model.sys.backup.BackupRestoreStatus) InterProcessLock(org.apache.curator.framework.recipes.locks.InterProcessLock)

Example 12 with BackupRestoreStatus

use of com.emc.vipr.model.sys.backup.BackupRestoreStatus in project coprhd-controller by CoprHD.

the class BackupOps method getSizeToDownload.

public long getSizeToDownload(String backupName) throws UnknownHostException {
    BackupRestoreStatus s = queryBackupRestoreStatus(backupName, false);
    Map<String, Long> map = s.getSizeToDownload();
    String localHostName = InetAddress.getLocalHost().getHostName();
    return map.get(localHostName);
}
Also used : BackupRestoreStatus(com.emc.vipr.model.sys.backup.BackupRestoreStatus)

Example 13 with BackupRestoreStatus

use of com.emc.vipr.model.sys.backup.BackupRestoreStatus in project coprhd-controller by CoprHD.

the class BackupOps method queryLocalBackupInfo.

public BackupInfo queryLocalBackupInfo(String backupTag) {
    BackupInfo backupInfo = new BackupInfo();
    backupInfo.setBackupName(backupTag);
    for (int retryCnt = 0; retryCnt < BackupConstants.RETRY_MAX_CNT; retryCnt++) {
        try {
            BackupRestoreStatus s = queryBackupRestoreStatus(backupTag, true);
            backupInfo.setRestoreStatus(s);
            List<BackupProcessor.BackupTask<BackupInfo>> backupTasks = new BackupProcessor(getHosts(), Arrays.asList(ports.get(2)), backupTag).process(new QueryBackupCallable(), true);
            for (BackupProcessor.BackupTask task : backupTasks) {
                BackupInfo backupInfoFromNode = (BackupInfo) task.getResponse().getFuture().get();
                log.info("Query backup({}) success", backupTag);
                mergeBackupInfo(backupInfo, backupInfoFromNode);
            }
        } catch (RetryableBackupException e) {
            log.info("Retry to query backup {}", backupTag);
            continue;
        } catch (Exception e) {
            log.warn("Query local backup({}) info got an error", backupTag, e);
        }
        break;
    }
    return backupInfo;
}
Also used : BackupInfo(com.emc.vipr.model.sys.backup.BackupInfo) BackupRestoreStatus(com.emc.vipr.model.sys.backup.BackupRestoreStatus) RetryableBackupException(com.emc.storageos.management.backup.exceptions.RetryableBackupException) URISyntaxException(java.net.URISyntaxException) CancellationException(java.util.concurrent.CancellationException) MalformedObjectNameException(javax.management.MalformedObjectNameException) RetryableBackupException(com.emc.storageos.management.backup.exceptions.RetryableBackupException) KeeperException(org.apache.zookeeper.KeeperException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) ExecutionException(java.util.concurrent.ExecutionException) BackupException(com.emc.storageos.management.backup.exceptions.BackupException)

Example 14 with BackupRestoreStatus

use of com.emc.vipr.model.sys.backup.BackupRestoreStatus in project coprhd-controller by CoprHD.

the class Backup method externalStatusJson.

/**
 * Only get the remote restore status
 * @param ids
 */
@Restrictions({ @Restrict("SYSTEM_ADMIN"), @Restrict("SYSTEM_MONITOR"), @Restrict("RESTRICTED_SYSTEM_ADMIN") })
public static void externalStatusJson(@As(",") String[] ids) {
    List<BackupDataTable.Backup> results = Lists.newArrayList();
    for (String id : ids) {
        if (StringUtils.isNotBlank(id)) {
            BackupDataTable.Backup backup = new BackupDataTable.Backup(id, false);
            BackupRestoreStatus restoreStatus = BackupUtils.getRestoreStatus(id, false);
            backup.status = restoreStatus.getStatus().name();
            if (restoreStatus.getStatus() == BackupRestoreStatus.Status.RESTORE_FAILED) {
                backup.error = restoreStatus.getDetails();
            }
            results.add(backup);
        }
    }
    renderJSON(results);
}
Also used : BackupDataTable(models.datatable.BackupDataTable) BackupRestoreStatus(com.emc.vipr.model.sys.backup.BackupRestoreStatus) Restrictions(controllers.deadbolt.Restrictions)

Aggregations

BackupRestoreStatus (com.emc.vipr.model.sys.backup.BackupRestoreStatus)14 BackupException (com.emc.storageos.management.backup.exceptions.BackupException)5 IOException (java.io.IOException)5 RetryableBackupException (com.emc.storageos.management.backup.exceptions.RetryableBackupException)3 MalformedURLException (java.net.MalformedURLException)3 URISyntaxException (java.net.URISyntaxException)3 UnknownHostException (java.net.UnknownHostException)3 CancellationException (java.util.concurrent.CancellationException)3 ExecutionException (java.util.concurrent.ExecutionException)3 MalformedObjectNameException (javax.management.MalformedObjectNameException)3 KeeperException (org.apache.zookeeper.KeeperException)3 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)2 BackupInfo (com.emc.vipr.model.sys.backup.BackupInfo)2 Restrictions (controllers.deadbolt.Restrictions)2 File (java.io.File)2 BackupDataTable (models.datatable.BackupDataTable)2 CoordinatorClientInetAddressMap (com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap)1 Configuration (com.emc.storageos.coordinator.common.Configuration)1 ConfigurationImpl (com.emc.storageos.coordinator.common.impl.ConfigurationImpl)1 BackupSet (com.emc.vipr.model.sys.backup.BackupSets.BackupSet)1