Search in sources :

Example 1 with DownloadProgress

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

the class UpgradeService method checkDownloadProgress.

/**
 * For download progress monitoring, The zookeeper structure used in the setNodeGlobalScopeInfo() and getNodeGlobalScopeInfo() is
 * /sites/(site_uuid)/config/downloadinfo/(svcId)
 * Each node has a entry in the coordinator indicated by its svcId.
 * The remote download and internode download are monitored in the same way, because the process is the same in the UpgradeImageCommon
 * class.
 * Every second if the newly downloaded bytes are more that 1MB, we update the progress entry in the coordinator.
 * For the cancel function, it first check the progress entries in the coordinator to see if there is a download in progress, if there
 * is, get the
 * version from the entry, and erase this version from the target RepositoryInfo object in the coordinator. This operation will
 * terminate the ongoing download process.
 */
/**
 * Check the version downloading progress. the downloading could be from remote repository
 *
 * @return image downloading progress
 * @throws Exception
 */
@GET
@Path("image/download/progress/")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public DownloadProgress checkDownloadProgress(@QueryParam("site") String siteId, @Context HttpHeaders headers) throws Exception {
    _log.info("checkDownloadProgress()");
    DownloadProgress progress = new DownloadProgress();
    DownloadingInfo targetDownloadInfo = _coordinator.getTargetInfo(DownloadingInfo.class);
    if (targetDownloadInfo == null || targetDownloadInfo._status == DownloadStatus.CANCELLED) {
        // return empty progress. No download in progress
        return progress;
    }
    progress.setImageSize(targetDownloadInfo._size);
    for (String svcId : _coordinator.getAllNodes(siteId)) {
        DownloadingInfo downloadInfo = _coordinator.getNodeGlobalScopeInfo(DownloadingInfo.class, siteId, DOWNLOADINFO_KIND, svcId);
        if (null == downloadInfo) {
            progress.addNodeProgress(svcId, new NodeProgress(0, DownloadStatus.NORMAL, 0, 0));
        } else {
            int downloadErrorCount = downloadInfo._errorCounter.get(0);
            int checksumErrorCount = downloadInfo._errorCounter.get(1);
            progress.addNodeProgress(svcId, new NodeProgress(downloadInfo.downloadedBytes, downloadInfo._status, downloadErrorCount, checksumErrorCount));
        }
    }
    return progress;
}
Also used : DownloadingInfo(com.emc.storageos.coordinator.client.model.DownloadingInfo) DownloadProgress(com.emc.vipr.model.sys.DownloadProgress) NodeProgress(com.emc.vipr.model.sys.NodeProgress) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 2 with DownloadProgress

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

the class Upgrade method clusterStatus.

public static void clusterStatus() {
    ClusterInfo clusterInfo = getSysClient().upgrade().getClusterInfo();
    Collection<String> repositoryVersions = clusterInfo.getTargetState().getAvailable();
    Collection<String> newVersions = clusterInfo.getNewVersions() == null ? Collections.<String>emptyList() : clusterInfo.getNewVersions();
    String clusterState = calculateClusterState(clusterInfo);
    boolean isStable = clusterState.equalsIgnoreCase(ClusterInfo.ClusterState.STABLE.toString());
    boolean isWorking = !isStable && !clusterState.equalsIgnoreCase(ClusterInfo.ClusterState.UNKNOWN.toString());
    boolean isDownloading = clusterState.equals(DOWNLOADING_CLUSTER_STATE) || isStandbySiteDownloading();
    DbConsistencyStatusRestRep checkDbState = getSysClient().upgrade().getDbCheckState();
    String isDbCheckStatus = checkDbState.getStatus().toString();
    int checkProgress = checkDbState.getProgress();
    Map<String, Map<String, DownloadStatus>> downloadStatus = Maps.newLinkedHashMap();
    if (isDownloading) {
        SiteRestRep activeSite = DisasterRecoveryUtils.getActiveSite();
        DownloadProgress downloadProgress = getSysClient().upgrade().getDownloadProgress();
        downloadStatus.put(activeSite.getName(), calculateDownloadStatus(downloadProgress));
        for (SiteRestRep standby : DisasterRecoveryUtils.getStandbySites()) {
            downloadProgress = getSysClient().upgrade().getDownloadProgress(standby.getUuid());
            downloadStatus.put(standby.getName(), calculateDownloadStatus(downloadProgress));
        }
    }
    render(clusterInfo, clusterState, newVersions, repositoryVersions, isStable, isWorking, isDownloading, downloadStatus, checkProgress, isDbCheckStatus);
}
Also used : DbConsistencyStatusRestRep(com.emc.storageos.model.db.DbConsistencyStatusRestRep) ClusterInfo(com.emc.vipr.model.sys.ClusterInfo) SiteRestRep(com.emc.storageos.model.dr.SiteRestRep) DownloadProgress(com.emc.vipr.model.sys.DownloadProgress) Map(java.util.Map)

Example 3 with DownloadProgress

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

the class Upgrade method downloadProgress.

public static void downloadProgress() {
    Map<String, Map<String, DownloadStatus>> siteProgress = Maps.newLinkedHashMap();
    SiteRestRep activeSite = DisasterRecoveryUtils.getActiveSite();
    DownloadProgress downloadProgress = getSysClient().upgrade().getDownloadProgress();
    siteProgress.put(activeSite.getName(), calculateDownloadStatus(downloadProgress));
    for (SiteRestRep standby : DisasterRecoveryUtils.getStandbySites()) {
        downloadProgress = getSysClient().upgrade().getDownloadProgress(standby.getUuid());
        siteProgress.put(standby.getName(), calculateDownloadStatus(downloadProgress));
    }
    renderJSON(siteProgress);
}
Also used : SiteRestRep(com.emc.storageos.model.dr.SiteRestRep) DownloadProgress(com.emc.vipr.model.sys.DownloadProgress) Map(java.util.Map)

Aggregations

DownloadProgress (com.emc.vipr.model.sys.DownloadProgress)3 SiteRestRep (com.emc.storageos.model.dr.SiteRestRep)2 Map (java.util.Map)2 DownloadingInfo (com.emc.storageos.coordinator.client.model.DownloadingInfo)1 DbConsistencyStatusRestRep (com.emc.storageos.model.db.DbConsistencyStatusRestRep)1 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)1 ClusterInfo (com.emc.vipr.model.sys.ClusterInfo)1 NodeProgress (com.emc.vipr.model.sys.NodeProgress)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1