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