Search in sources :

Example 6 with BackupRestoreStatus

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");
}
Also used : BackupRestoreStatus(com.emc.vipr.model.sys.backup.BackupRestoreStatus) ConfigurationImpl(com.emc.storageos.coordinator.common.impl.ConfigurationImpl) CoordinatorClientInetAddressMap(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap)

Example 7 with BackupRestoreStatus

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;
}
Also used : BackupRestoreStatus(com.emc.vipr.model.sys.backup.BackupRestoreStatus) File(java.io.File) 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 8 with BackupRestoreStatus

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;
}
Also used : BackupInfo(com.emc.vipr.model.sys.backup.BackupInfo) ZipInputStream(java.util.zip.ZipInputStream) ZipInputStream(java.util.zip.ZipInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) BackupRestoreStatus(com.emc.vipr.model.sys.backup.BackupRestoreStatus) ZipEntry(java.util.zip.ZipEntry) IOException(java.io.IOException) 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 9 with BackupRestoreStatus

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;
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration) BackupRestoreStatus(com.emc.vipr.model.sys.backup.BackupRestoreStatus)

Example 10 with BackupRestoreStatus

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);
    }
}
Also used : BackupRestoreStatus(com.emc.vipr.model.sys.backup.BackupRestoreStatus) File(java.io.File) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) IOException(java.io.IOException) BackupException(com.emc.storageos.management.backup.exceptions.BackupException)

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