@Override protected Map<Integer, Host> getPartitionsAssignment(Domain domain, List<HostAndIndexInRing> hosts) { Map<Host, List<Integer>> hostToPartitions = getHostToPartitions(domain, hosts); // Compute result Map<Integer, Host> result = new HashMap<Integer, Host>(); for (Map.Entry<Host, List<Integer>> entry : hostToPartitions.entrySet()) { for (Integer partitionNumber : entry.getValue()) { result.put(partitionNumber, entry.getKey()); } } return result; }
private Map<Integer, Host> getPartitionAssignment(int numPartitions, Host... hosts) { List<AbstractMappingPartitionAssigner.HostAndIndexInRing> hostAndIndexInRings = new ArrayList<AbstractMappingPartitionAssigner.HostAndIndexInRing>(); for (int i = 0; i < hosts.length; ++i) { Host host = hosts[i]; if (host != null) { hostAndIndexInRings.add(new AbstractMappingPartitionAssigner.HostAndIndexInRing(host, i)); } } RendezVousPartitionAssigner partitionAssigner = new RendezVousPartitionAssigner(); Domain domain = new MockDomain("domain", 0, numPartitions, null, null, null, null); return partitionAssigner.getPartitionsAssignment(domain, hostAndIndexInRings); } }
private Map<Host, List<Integer>> getHostToPartitions(Domain domain, List<HostAndIndexInRing> hosts) { int maxPartitionsPerHost = getMaxPartitionsPerHost(domain, hosts.size()); Map<Host, List<Integer>> result = new HashMap<Host, List<Integer>>(); List<Host> orderedHosts = getOrderedWeightedHosts(domain, partitionNumber, hosts); boolean assigned = false; for (Host host : orderedHosts) {
public RingGroupConductor(RingGroupConductorConfigurator configurator) throws IOException { this(configurator, new RingGroupUpdateTransitionFunctionImpl(new RendezVousPartitionAssigner(), statusFor(configurator) ), new RingGroupAutoconfigureTransitionFunction( configurator.getTargetHostsPerRing(), configurator.getConfiguredDomains(), statusFor(configurator) ) ); }