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);
}
}
}
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);
}
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;
}
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);
}
Aggregations