Search in sources :

Example 1 with NodeProgress

use of com.emc.vipr.model.sys.NodeProgress 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)

Aggregations

DownloadingInfo (com.emc.storageos.coordinator.client.model.DownloadingInfo)1 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)1 DownloadProgress (com.emc.vipr.model.sys.DownloadProgress)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