for (Host host : ring.getHostsSorted()) {
@Override public void manageTransitions(Coordinator coordinator, RingGroup ringGroup) throws IOException { DomainGroup domainGroup = ringGroup.getDomainGroup(); if (domainGroup == null) { // Nothing to do LOG.info("Domain group not found. Nothing to do."); return; } Map<Domain, Map<Integer, Set<Host>>> domainToPartitionToHostsFullyServing = PartitionUtils.domainToPartitionToHostsServing(ringGroup, status); ThreeNestedMap<Domain, Integer, String, Long> domainPartitionBucketHostCounts = PartitionUtils.domainToPartitionToHostsServingInBucket(domainToPartitionToHostsFullyServing, status); SortedSet<Ring> rings = ringGroup.getRingsSorted(); int ringCount = rings.size(); for (Ring ring : rings) { partitionAssigner.prepare(ring, domainGroup.getDomainVersions(), ringGroup.getRingGroupConductorMode()); for (Host host : ring.getHostsSorted()) { manageTransitions(ringCount, host, domainGroup, domainToPartitionToHostsFullyServing, domainPartitionBucketHostCounts); } } }
@Override public void manageTransitions(Coordinator coordinator, RingGroup ringGroup) throws IOException { for (Ring ring : ringGroup.getRings()) { for (Host host : ring.getHostsSorted()) { PartitionUtils.isFullyServing(host, true, status); } } // Reconfigure rings if we changed the target # of hosts per ring // if there is a ring with too many hosts, remove a host from the ring removeExcessHosts(ringGroup); // if there are multiple rings within a bucket without enough hosts in them, // choose one of them, remove a host from the one with the fewest hosts consolidateRings(ringGroup); // if either of the above operations left an empty ring, remove it removeEmptyRings(ringGroup); // if we can put together a full ring with unassigned hosts, do so assignUnassignedHostsToRings(ringGroup); // configure the domains synchronizeDomains(coordinator, ringGroup); // add domains to the ring group if possible addDomainsToRingGroup(coordinator, ringGroup); }