private boolean hasEnoughHosts(Ring ring) { return ring.getHosts().size() >= targetHostsPerRing; }
public static Map<Host, Map<String, FilesystemStatisticsAggregator>> computeFilesystemStatistics(Ring ring) throws IOException { Map<Host, Map<String, FilesystemStatisticsAggregator>> result = new HashMap<Host, Map<String, FilesystemStatisticsAggregator>>(); for (Host host : ring.getHosts()) { result.put(host, Hosts.computeFilesystemStatistics(host)); } return result; }
public static long computeUpdateETA(Ring ring) { long maxUpdateETA = -1; for (Host host : ring.getHosts()) { long hostUpdateETA = Hosts.computeUpdateETA(host); if (hostUpdateETA > maxUpdateETA) { maxUpdateETA = hostUpdateETA; } } return maxUpdateETA; } }
public static Map<Host, Map<Domain, RuntimeStatisticsAggregator>> computeRuntimeStatistics(Coordinator coordinator, Ring ring) throws IOException { Map<Host, Map<Domain, RuntimeStatisticsAggregator>> result = new HashMap<Host, Map<Domain, RuntimeStatisticsAggregator>>(); for (Host host : ring.getHosts()) { result.put(host, Hosts.computeRuntimeStatistics(coordinator, host)); } return result; }
public static int getNumHosts(RingGroup ringGroup) { int result = 0; for (Ring ring : ringGroup.getRings()) { result += ring.getHosts().size(); } return result; }
public static Set<Host> getHostsInState(Ring ring, HostState state) throws IOException { Set<Host> results = new HashSet<Host>(); for (Host host : ring.getHosts()) { if (host.getState() == state) { results.add(host); } } return results; }
public RingMonitor(final RingGroup ringGroup, final Ring ring, final List<Notifier> notifiers) throws IOException { this.ringGroup = ringGroup; this.ring = ring; this.notifiers = notifiers; for (Host host : ring.getHosts()) { hostMonitors.add(new HostMonitor(ringGroup, ring, host, notifiers)); } }
public static Set<Host> getHosts(RingGroup ringGroup) { TreeSet<Host> result = new TreeSet<Host>(); for (Ring ring : ringGroup.getRings()) { result.addAll(ring.getHosts()); } return result; }
public static void commandAll(Ring ring, HostCommand command) throws IOException { for (Host host : ring.getHosts()) { host.enqueueCommand(command); } }
public static boolean isUpToDate(Ring ring, DomainGroup domainGroup) throws IOException { for (Host host : ring.getHosts()) { if (!Hosts.isUpToDate(host, domainGroup)) { return false; } } return true; }
public static boolean isUpToDate(Ring ring, DomainGroup domainGroup, Domain domain) throws IOException { for (Host host : ring.getHosts()) { if (!Hosts.isUpToDate(host, domainGroup, domain)) { return false; } } return true; }
private String getABForRing(Ring ring) { Set<String> buckets = Sets.newHashSet(); for (Host host : ring.getHosts()) { buckets.add(host.getEnvironmentFlags().get(status.getAvailabilityBucketKey())); } if (buckets.size() == 1) { return Accessors.only(buckets); } throw new RuntimeException("Unable to find a single AB for ring: " + ring); }
public static Set<Host> getHostsNotUpToDate(RingGroup ringGroup, Collection<DomainAndVersion> versions) throws IOException { Set<Host> outOfDateHosts = Sets.newHashSet(); for (Ring ring : ringGroup.getRings()) { for (Host host : ring.getHosts()) { if (!Hosts.isUpToDateOrMoreRecent(host, versions)) { outOfDateHosts.add(host); } } } return outOfDateHosts; } }
protected void removeEmptyRings(RingGroup ringGroup) throws IOException { // avoid concurrent modification exceptions Set<Integer> rings = ringGroup.getRings().stream().map(Ring::getRingNumber).collect(Collectors.toSet()); for (Integer ringNum : rings) { Ring ring = ringGroup.getRing(ringNum); if (ring.getHosts().isEmpty()) { ringGroup.removeRing(ringNum); } } }
public static Set<Host> getHostsForDomainPartition(Ring ring, Domain domain, int partition) throws IOException { Set<Host> results = new HashSet<Host>(); for (Host host : ring.getHosts()) { HostDomain domainById = host.getHostDomain(domain); for (HostDomainPartition hdpc : domainById.getPartitions()) { if (hdpc.getPartitionNumber() == partition) { results.add(host); break; } } } return results; }
protected RingData getRingData(Ring ring) throws IOException { RingData data = new RingData(); data.ringNumber = ring.getRingNumber(); Map<String, HostData> hostMap = new HashMap<String, HostData>(); for (Host host : ring.getHosts()) { hostMap.put(host.getAddress().toString(), getHostData(host)); } data.hostsMap = hostMap; return data; }
public static boolean isServingOnlyUpToDateOrMoreRecent(RingGroup ringGroup, List<DomainAndVersion> domainVersions) throws IOException { for (Ring ring : ringGroup.getRings()) { for (Host host : ring.getHosts()) { if (host.getState() == HostState.SERVING && !Hosts.isUpToDateOrMoreRecent(host, domainVersions)) { return false; } } } return true; }
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 static ServingStatusAggregator computeServingStatusAggregator(Ring ring, DomainGroup domainGroup) throws IOException { ServingStatusAggregator servingStatusAggregator = new ServingStatusAggregator(); for (Host host : ring.getHosts()) { servingStatusAggregator.aggregate(Hosts.computeServingStatusAggregator(host, domainGroup)); } return servingStatusAggregator; }
public static boolean isServingOnlyUpToDate(RingGroup ringGroup) throws IOException { DomainGroup domainGroup = ringGroup.getDomainGroup(); for (Ring ring : ringGroup.getRings()) { for (Host host : ring.getHosts()) { if (host.getState() == HostState.SERVING && !Hosts.isUpToDate(host, domainGroup)) { return false; } } } return true; }