use of com.emc.vipr.model.sys.backup.BackupRestoreStatus in project coprhd-controller by CoprHD.
the class BackupOps method setGeoFlag.
public synchronized void setGeoFlag(String backupName, boolean isLocal) {
BackupRestoreStatus state = queryBackupRestoreStatus(backupName, isLocal);
state.setGeo(true);
log.info("Persist backup restore status {} stack=", state, new Throwable());
Map<String, String> allItems = state.toMap();
ConfigurationImpl config = new ConfigurationImpl();
config.setKind(getBackupConfigKind(isLocal));
config.setId(backupName);
for (Map.Entry<String, String> entry : allItems.entrySet()) {
config.setConfig(entry.getKey(), entry.getValue());
}
coordinatorClient.persistServiceConfiguration(coordinatorClient.getSiteId(), config);
log.info("Persist backup restore status to zk successfully");
}
use of com.emc.vipr.model.sys.backup.BackupRestoreStatus in project coprhd-controller by CoprHD.
the class BackupOps method isDownloadComplete.
public boolean isDownloadComplete(String backupName) {
BackupRestoreStatus s = queryBackupRestoreStatus(backupName, false);
if (s.getStatus() != BackupRestoreStatus.Status.DOWNLOAD_SUCCESS) {
return false;
}
File downloadFolder = getDownloadDirectory(backupName);
try {
checkBackup(downloadFolder, false);
} catch (Exception e) {
return false;
}
return true;
}
use of com.emc.vipr.model.sys.backup.BackupRestoreStatus in project coprhd-controller by CoprHD.
the class BackupOps method getBackupInfo.
/**
* Query info of a remote backup, if the backup has been downloaded, get info from local downloaded directory
* @param backupName
* @param client
* @return
* @throws IOException
*/
public BackupInfo getBackupInfo(String backupName, BackupClient client) throws Exception {
log.info("To get backup info of {} from server={} ", backupName, client.getUri());
BackupInfo backupInfo = new BackupInfo();
try {
long size = client.getFileSize(backupName);
backupInfo.setBackupSize(size);
} catch (Exception e) {
log.warn("Failed to get the backup file size, e=", e);
throw BackupException.fatals.failedToGetBackupSize(backupName, e);
}
InputStream in = client.download(backupName);
ZipInputStream zin = new ZipInputStream(in);
ZipEntry zentry = zin.getNextEntry();
while (zentry != null) {
if (isPropEntry(zentry)) {
log.info("Found the property file={}", zentry.getName());
setBackupInfo(backupInfo, backupName, zin);
break;
}
zentry = zin.getNextEntry();
}
try {
zin.closeEntry();
zin.close();
} catch (IOException e) {
log.debug("Failed to close the stream e", e);
// it's a known issue to use curl
// it's safe to ignore this exception here.
}
BackupRestoreStatus s = queryBackupRestoreStatus(backupName, true);
backupInfo.setRestoreStatus(s);
return backupInfo;
}
use of com.emc.vipr.model.sys.backup.BackupRestoreStatus in project coprhd-controller by CoprHD.
the class BackupOps method queryBackupRestoreStatus.
/**
* Query restore status from ZK
*/
public BackupRestoreStatus queryBackupRestoreStatus(String backupName, boolean isLocal) {
Configuration cfg = coordinatorClient.queryConfiguration(coordinatorClient.getSiteId(), getBackupConfigKind(isLocal), backupName);
Map<String, String> allItems = (cfg == null) ? new HashMap<String, String>() : cfg.getAllConfigs(false);
BackupRestoreStatus restoreStatus = new BackupRestoreStatus(allItems);
return restoreStatus;
}
use of com.emc.vipr.model.sys.backup.BackupRestoreStatus in project coprhd-controller by CoprHD.
the class DownloadExecutor method postDownload.
private void postDownload() {
BackupRestoreStatus restoreStatus = backupOps.queryBackupRestoreStatus(remoteBackupFileName, false);
log.info("In postDownload status={}", restoreStatus);
try {
File downloadedDir = backupOps.getDownloadDirectory(remoteBackupFileName);
backupOps.checkBackup(downloadedDir, false);
// persist the names of data files into the ZK
List<String> filenames = backupOps.getBackupFileNames(downloadedDir);
backupOps.setBackupFileNames(remoteBackupFileName, filenames);
// since all files has been downloaded/unzipped to current node,
// calculate the size to download on each node
// on current node, since all files have been downloaded
// set the size-to-download = downloaded-size
// calculate the size to be downloaded on other nodes
Map<String, Long> downloadSize = backupOps.getInternalDownloadSize(remoteBackupFileName);
BackupRestoreStatus s = backupOps.queryBackupRestoreStatus(remoteBackupFileName, false);
Map<String, Long> sizeToDownload = s.getSizeToDownload();
sizeToDownload.putAll(downloadSize);
s.setSizeToDownload(sizeToDownload);
log.info("sizeToDownload={} downloadedSize={}", sizeToDownload, s.getDownloadedSize());
backupOps.persistBackupRestoreStatus(s, false, true);
notifyOtherNodes(remoteBackupFileName);
} catch (Exception e) {
log.error("Invalid backup e=", e);
backupOps.setRestoreStatus(remoteBackupFileName, false, Status.DOWNLOAD_FAILED, e.getMessage(), false, true);
}
}
Aggregations