private Set<ServerName> getInheritedFNForDaughter(FavoredNodeAssignmentHelper helper, List<ServerName> parentFavoredNodes, Position primary, Position secondary) throws IOException { Set<ServerName> daughterFN = Sets.newLinkedHashSet(); if (parentFavoredNodes.size() >= primary.ordinal()) { daughterFN.add(parentFavoredNodes.get(primary.ordinal())); } if (parentFavoredNodes.size() >= secondary.ordinal()) { daughterFN.add(parentFavoredNodes.get(secondary.ordinal())); } while (daughterFN.size() < FavoredNodeAssignmentHelper.FAVORED_NODES_NUM) { ServerName newNode = helper.generateMissingFavoredNode(Lists.newArrayList(daughterFN)); daughterFN.add(newNode); } return daughterFN; }
private Set<ServerName> getInheritedFNForDaughter(FavoredNodeAssignmentHelper helper, List<ServerName> parentFavoredNodes, Position primary, Position secondary) throws IOException { Set<ServerName> daughterFN = Sets.newLinkedHashSet(); if (parentFavoredNodes.size() >= primary.ordinal()) { daughterFN.add(parentFavoredNodes.get(primary.ordinal())); } if (parentFavoredNodes.size() >= secondary.ordinal()) { daughterFN.add(parentFavoredNodes.get(secondary.ordinal())); } while (daughterFN.size() < FAVORED_NODES_NUM) { ServerName newNode = helper.generateMissingFavoredNode(Lists.newArrayList(daughterFN)); daughterFN.add(newNode); } return daughterFN; }
/** * Creates a <i>mutable</i> {@code LinkedHashSet} instance containing the given elements in order. * * <p><b>Note:</b> if mutability is not required and the elements are non-null, use {@link * ImmutableSet#copyOf(Iterable)} instead. * * <p><b>Note for Java 7 and later:</b> if {@code elements} is a {@link Collection}, you don't * need this method. Instead, use the {@code LinkedHashSet} constructor directly, taking advantage * of the new <a href="http://goo.gl/iz2Wi">"diamond" syntax</a>. * * <p>Overall, this method is not very useful and will likely be deprecated in the future. * * @param elements the elements that the set should contain, in order * @return a new {@code LinkedHashSet} containing those elements (minus duplicates) */ public static <E> LinkedHashSet<E> newLinkedHashSet(Iterable<? extends E> elements) { if (elements instanceof Collection) { return new LinkedHashSet<E>(Collections2.cast(elements)); } LinkedHashSet<E> set = newLinkedHashSet(); Iterables.addAll(set, elements); return set; }
Set<K> keysToLoad = Sets.newLinkedHashSet(); for (K key : keys) { V value = get(key);