public static UpdateProgressAggregator computeUpdateProgress(Ring ring, DomainGroup domainGroup) throws IOException { UpdateProgressAggregator result = new UpdateProgressAggregator(); for (Host host : ring.getHosts()) { result.aggregate(Hosts.computeUpdateProgress(host, domainGroup)); } return result; }
public void add(Domain domain, boolean isUpToDate) { UpdateProgress updateProgress = getUpdateProgress(domain); // Compute counts updateProgress.numPartitions += 1; if (isUpToDate) { updateProgress.numPartitionsUpToDate += 1; } }
public static String formatUpdateProgress(UpdateProgressAggregator updateProgressAggregator, long eta) { if (updateProgressAggregator == null) { return ""; } StringBuilder content = new StringBuilder(); StringBuilder tooltip = new StringBuilder(); UpdateProgress updateProgress = updateProgressAggregator.computeUpdateProgress(); content.append(FormatUtils.formatDouble(updateProgress.getUpdateProgress() * 100) + "% up-to-date" + " (" + updateProgress.getNumPartitionsUpToDate() + "/" + updateProgress.getNumPartitions() + ")"); if (eta >= 0) { content.append(" ETA: " + FormatUtils.formatSecondsDuration(eta)); } content.append("<div class=\'progress-bar\'><div class=\'progress-bar-filler\' style=\'width: " + Math.round(updateProgress.getUpdateProgress() * 100) + "%\'></div></div>"); // Build tooltip tooltip.append("<table>"); for (Map.Entry<Domain, UpdateProgress> entry : updateProgressAggregator.sortedEntrySet()) { UpdateProgress domainUpdateProgress = entry.getValue(); tooltip.append("<tr><td class='centered'>"); tooltip.append(entry.getKey().getName()); tooltip.append("</td><td class='centered'>"); tooltip.append("<div class=\'progress-bar\'><div class=\'progress-bar-filler\' style=\'width: " + Math.round(domainUpdateProgress.getUpdateProgress() * 100) + "%\'></div></div>"); tooltip.append("</td><td class='centered'>"); tooltip.append(FormatUtils.formatDouble(domainUpdateProgress.getUpdateProgress() * 100) + "%"); tooltip.append("</td></tr>"); } tooltip.append("</table>"); return htmlTooltip(content.toString(), "Update Progress", tooltip.toString()); }
public static UpdateProgressAggregator computeUpdateProgress(Host host, DomainGroup domainGroup) throws IOException { UpdateProgressAggregator result = new UpdateProgressAggregator(); for (DomainAndVersion dgvdv : domainGroup.getDomainVersions()) { Domain domain = dgvdv.getDomain(); HostDomain hostDomain = host.getHostDomain(domain); if (hostDomain != null) { for (HostDomainPartition partition : hostDomain.getPartitions()) { // Ignore deletable partitions if (!partition.isDeletable()) { if (partition.getCurrentDomainVersion() != null && partition.getCurrentDomainVersion().equals(dgvdv.getVersionNumber())) { result.add(domain, true); } else { result.add(domain, false); } } } } } return result; }
public static UpdateProgressAggregator computeUpdateProgress(RingGroup ringGroup, DomainGroup domainGroup) throws IOException { UpdateProgressAggregator result = new UpdateProgressAggregator(); for (Ring ring : ringGroup.getRings()) { result.aggregate(Rings.computeUpdateProgress(ring, domainGroup)); } return result; }
public void aggregate(UpdateProgressAggregator other) { for (Map.Entry<Domain, UpdateProgress> entry : other.domainToUpdateProgress.entrySet()) { UpdateProgress updateProgress = getUpdateProgress(entry.getKey()); updateProgress.aggregate(entry.getValue()); } }