Map<String,SortedMap<TServerInstance,TabletServerStatus>> newPools = new HashMap<>(); for (Entry<TServerInstance,TabletServerStatus> e : current.entrySet()) { List<String> poolNames = getPoolNamesForHost(e.getKey().host()); for (String pool : poolNames) { SortedMap<TServerInstance,TabletServerStatus> np = newPools.get(pool);
public TServerInstance getAssignment(SortedMap<TServerInstance,TabletServerStatus> locations, TServerInstance last) { if (locations.size() == 0) return null; if (last != null) { // Maintain locality String fakeSessionID = " "; TServerInstance simple = new TServerInstance(last.getLocation(), fakeSessionID); Iterator<TServerInstance> find = locations.tailMap(simple).keySet().iterator(); if (find.hasNext()) { TServerInstance current = find.next(); if (current.host().equals(last.host())) return current; } } // The strategy here is to walk through the locations and hand them back, one at a time // Grab an iterator off of the set of options; use a new iterator if it hands back something not // in the current list. if (assignments == null || !assignments.hasNext()) assignments = randomize(locations.keySet()).iterator(); TServerInstance result = assignments.next(); if (!locations.containsKey(result)) { assignments = null; return randomize(locations.keySet()).iterator().next(); } return result; }
List<TServerInstance> subset = new ArrayList<>(); master.onlineTabletServers().forEach(t -> { if (regex.matcher(t.host()).matches()) { subset.add(t);
public TServerInstance getAssignment(SortedMap<TServerInstance,TabletServerStatus> locations, KeyExtent extent, TServerInstance last) { if (locations.size() == 0) return null; if (last != null) { // Maintain locality String fakeSessionID = " "; TServerInstance simple = new TServerInstance(last.getLocation(), fakeSessionID); Iterator<TServerInstance> find = locations.tailMap(simple).keySet().iterator(); if (find.hasNext()) { TServerInstance current = find.next(); if (current.host().equals(last.host())) return current; } } // The strategy here is to walk through the locations and hand them back, one at a time // Grab an iterator off of the set of options; use a new iterator if it hands back something not // in the current list. if (assignments == null || !assignments.hasNext()) assignments = randomize(locations.keySet()).iterator(); TServerInstance result = assignments.next(); if (!locations.containsKey(result)) { assignments = null; return randomize(locations.keySet()).iterator().next(); } return result; }
Map<String,SortedMap<TServerInstance,TabletServerStatus>> newPools = new HashMap<>(); for (Entry<TServerInstance,TabletServerStatus> e : current.entrySet()) { List<String> poolNames = getPoolNamesForHost(e.getKey().host()); for (String pool : poolNames) { SortedMap<TServerInstance,TabletServerStatus> np = newPools.get(pool);
public TServerInstance getAssignment(SortedMap<TServerInstance,TabletServerStatus> locations, KeyExtent extent, TServerInstance last) { if (locations.size() == 0) return null; if (last != null) { // Maintain locality String fakeSessionID = " "; TServerInstance simple = new TServerInstance(last.getLocation(), fakeSessionID); Iterator<TServerInstance> find = locations.tailMap(simple).keySet().iterator(); if (find.hasNext()) { TServerInstance current = find.next(); if (current.host().equals(last.host())) return current; } } // The strategy here is to walk through the locations and hand them back, one at a time // Grab an iterator off of the set of options; use a new iterator if it hands back something not in the current list. if (assignments == null || !assignments.hasNext()) assignments = randomize(locations.keySet()).iterator(); TServerInstance result = assignments.next(); if (!locations.containsKey(result)) { assignments = null; return randomize(locations.keySet()).iterator().next(); } return result; }