[ 
https://issues.apache.org/jira/browse/HADOOP-17115?focusedWorklogId=597857&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-597857
 ]

ASF GitHub Bot logged work on HADOOP-17115:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 17/May/21 18:04
            Start Date: 17/May/21 18:04
    Worklog Time Spent: 10m 
      Work Description: busbey commented on a change in pull request #2985:
URL: https://github.com/apache/hadoop/pull/2985#discussion_r632984329



##########
File path: 
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Sets.java
##########
@@ -0,0 +1,329 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.util;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Static utility methods pertaining to {@link Set} instances.
+ * This class is Hadoop's internal use alternative to Guava's Sets
+ * utility class.
+ */
+@InterfaceAudience.Private
+public final class Sets {

Review comment:
       It looks like some of the javadocs are directly copied from Guava's 
`Sets`? Please include a note in the Javadoc here that the method api/javadocs 
are from Guava's `Sets` class (pref w/a specific guava release noted). 
Hopefully that will make  references to use of "ImmutableSet#of" in javadocs 
clear enough. Alternatively rewrite any javadocs originally from guava.
   
   If any of the implementations are copied from Guava's `Sets` class also 
indicate that.

##########
File path: 
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Sets.java
##########
@@ -0,0 +1,329 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.util;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Static utility methods pertaining to {@link Set} instances.
+ * This class is Hadoop's internal use alternative to Guava's Sets
+ * utility class.
+ */
+@InterfaceAudience.Private
+public final class Sets {
+
+  private Sets() {
+    // empty
+  }
+
+  /**
+   * Creates a <i>mutable</i>, initially empty {@code HashSet} instance.
+   *
+   * <p><b>Note:</b> if mutability is not required, use ImmutableSet#of()
+   * instead. If {@code E} is an {@link Enum} type, use {@link EnumSet#noneOf}
+   * instead. Otherwise, strongly consider using a {@code LinkedHashSet}
+   * instead, at the cost of increased memory footprint, to get
+   * deterministic iteration behavior.
+   */
+  public static <E> HashSet<E> newHashSet() {
+    return new HashSet<E>();
+  }
+
+  /**
+   * Creates a <i>mutable</i>, empty {@code TreeSet} instance sorted by the
+   * natural sort ordering of its elements.
+   *
+   * <p><b>Note:</b> if mutability is not required, use ImmutableSortedSet#of()
+   * instead.
+   *
+   * @return a new, empty {@code TreeSet}
+   */
+  public static <E extends Comparable> TreeSet<E> newTreeSet() {
+    return new TreeSet<E>();
+  }
+
+  /**
+   * Creates a <i>mutable</i> {@code HashSet} instance initially containing
+   * the given elements.
+   *
+   * <p><b>Note:</b> if elements are non-null and won't be added or removed
+   * after this point, use ImmutableSet#of() or ImmutableSet#copyOf(Object[])
+   * instead. If {@code E} is an {@link Enum} type, use
+   * {@link EnumSet#of(Enum, Enum[])} instead. Otherwise, strongly consider
+   * using a {@code LinkedHashSet} instead, at the cost of increased memory
+   * footprint, to get deterministic iteration behavior.
+   *
+   * <p>This method is just a small convenience, either for
+   * {@code newHashSet(}{@link Arrays#asList}{@code (...))}, or for creating an
+   * empty set then calling {@link Collections#addAll}.
+   */
+  @SafeVarargs
+  public static <E> HashSet<E> newHashSet(E... elements) {
+    HashSet<E> set = newHashSetWithExpectedSize(elements.length);
+    Collections.addAll(set, elements);
+    return set;
+  }
+
+  /**
+   * Creates a <i>mutable</i> {@code HashSet} instance containing the given
+   * elements. A very thin convenience for creating an empty set then calling
+   * {@link Collection#addAll} or Iterables#addAll.
+   *
+   * <p><b>Note:</b> if mutability is not required and the elements are
+   * non-null, use ImmutableSet#copyOf(Iterable) instead. (Or, change
+   * {@code elements} to be a FluentIterable and call {@code 
elements.toSet()}.)
+   *
+   * <p><b>Note:</b> if {@code E} is an {@link Enum} type, use
+   * newEnumSet(Iterable, Class) instead.
+   */
+  public static <E> HashSet<E> newHashSet(Iterable<? extends E> elements) {
+    return (elements instanceof Collection)
+        ? new HashSet<E>(cast(elements))
+        : newHashSet(elements.iterator());
+  }
+
+  /**
+   * Creates a <i>mutable</i> {@code TreeSet} instance containing the given
+   * elements sorted by their natural ordering.
+   *
+   * <p><b>Note:</b> if mutability is not required, use
+   * ImmutableSortedSet#copyOf(Iterable) instead.
+   *
+   * <p><b>Note:</b> If {@code elements} is a {@code SortedSet} with an
+   * explicit comparator, this method has different behavior than
+   * {@link TreeSet#TreeSet(SortedSet)}, which returns a {@code TreeSet}
+   * with that comparator.
+   *
+   * <p><b>Note for Java 7 and later:</b> this method is now unnecessary and
+   * should be treated as deprecated. Instead, use the {@code TreeSet}
+   * constructor directly, taking advantage of the new
+   * <a href="http://goo.gl/iz2Wi";>"diamond" syntax</a>.
+   *
+   * <p>This method is just a small convenience for creating an empty set and
+   * then calling Iterables#addAll. This method is not very useful and will
+   * likely be deprecated in the future.
+   *
+   * @param elements the elements that the set should contain
+   * @return a new {@code TreeSet} containing those elements (minus duplicates)
+   */
+  public static <E extends Comparable> TreeSet<E> newTreeSet(
+      Iterable<? extends E> elements) {
+    TreeSet<E> set = newTreeSet();
+    addAll(set, elements);
+    return set;
+  }
+
+  private static <E extends Comparable> boolean addAll(TreeSet<E> addTo,
+      Iterable<? extends E> elementsToAdd) {
+    if (elementsToAdd instanceof Collection) {
+      Collection<? extends E> c = cast(elementsToAdd);
+      return addTo.addAll(c);
+    }
+    if (elementsToAdd == null) {
+      throw new NullPointerException();
+    }
+    return addAll(addTo, elementsToAdd.iterator());
+  }
+
+  /**
+   * Creates a <i>mutable</i> {@code HashSet} instance containing the given
+   * elements. A very thin convenience for creating an empty set and then
+   * calling Iterators#addAll.
+   *
+   * <p><b>Note:</b> if mutability is not required and the elements are
+   * non-null, use ImmutableSet#copyOf(Iterator) instead.
+   *
+   * <p><b>Note:</b> if {@code E} is an {@link Enum} type, you should create
+   * an {@link EnumSet} instead.
+   *
+   * <p>Overall, this method is not very useful and will likely be deprecated
+   * in the future.
+   */
+  public static <E> HashSet<E> newHashSet(Iterator<? extends E> elements) {
+    HashSet<E> set = newHashSet();
+    addAll(set, elements);
+    return set;
+  }
+
+  /**
+   * Returns a new hash set using the smallest initial table size that can hold
+   * {@code expectedSize} elements without resizing. Note that this is not what
+   * {@link HashSet#HashSet(int)} does, but it is what most users want and
+   * expect it to do.
+   *
+   * <p>This behavior can't be broadly guaranteed, but has been tested with
+   * OpenJDK 1.7 and 1.8.
+   *
+   * @param expectedSize the number of elements you expect to add to the
+   *     returned set
+   * @return a new, empty hash set with enough capacity to hold
+   *     {@code expectedSize} elements without resizing
+   * @throws IllegalArgumentException if {@code expectedSize} is negative
+   */
+  public static <E> HashSet<E> newHashSetWithExpectedSize(int expectedSize) {
+    return new HashSet<E>(expectedSize);
+  }
+
+  private static <E> Collection<E> cast(Iterable<E> iterable) {
+    return (Collection<E>) iterable;
+  }
+
+  private static <E> boolean addAll(Collection<E> addTo,
+      Iterator<? extends E> iterator) {
+    if (addTo == null) {
+      throw new NullPointerException();
+    }
+    if (iterator == null) {
+      throw new NullPointerException();
+    }
+    boolean wasModified = false;
+    while (iterator.hasNext()) {
+      wasModified |= addTo.add(iterator.next());
+    }
+    return wasModified;
+  }
+
+  /**
+   * Returns the intersection of two sets as an unmodifiable set.
+   */
+  public static <E> Set<E> intersection(final Set<E> set1,
+      final Set<E> set2) {
+    if (set1 == null) {
+      throw new NullPointerException("set1");
+    }
+    if (set2 == null) {
+      throw new NullPointerException("set2");
+    }
+    Set<E> newSet = new HashSet<>(set1);
+    newSet.retainAll(set2);
+    return Collections.unmodifiableSet(newSet);
+  }
+
+  /**
+   * Returns the symmetric difference of two sets as an unmodifiable set.
+   * Should be used with HashSet only.
+   */
+  public static <E> Set<E> union(
+      final Set<E> set1, final Set<E> set2) {
+    if (set1 == null) {
+      throw new NullPointerException("set1");
+    }
+    if (set2 == null) {
+      throw new NullPointerException("set2");
+    }
+    Set<E> newSet = new HashSet<>(set1);
+    newSet.addAll(set2);
+    return Collections.unmodifiableSet(newSet);
+  }
+
+  /**
+   * Returns the difference of two sets as an unmodifiable set.
+   * Removes all element from set1 that are contained in set2.
+   * This method is used to find difference for HashSets. For TreeSets with
+   * strict order requirement, recommended method is
+   * {@link #differenceInTreeSets(Set, Set)}.
+   */
+  public static <E> Set<E> difference(
+      final Set<E> set1, final Set<E> set2) {

Review comment:
       This doesn't remove stuff from set1, so recommend being clear in the 
phrasing. e.g.
   
   ```
   The difference is defined as elements that are in set1 but not in set 2.
   ```

##########
File path: 
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Sets.java
##########
@@ -0,0 +1,329 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.util;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Static utility methods pertaining to {@link Set} instances.
+ * This class is Hadoop's internal use alternative to Guava's Sets
+ * utility class.
+ */
+@InterfaceAudience.Private
+public final class Sets {
+
+  private Sets() {
+    // empty
+  }
+
+  /**
+   * Creates a <i>mutable</i>, initially empty {@code HashSet} instance.
+   *
+   * <p><b>Note:</b> if mutability is not required, use ImmutableSet#of()
+   * instead. If {@code E} is an {@link Enum} type, use {@link EnumSet#noneOf}
+   * instead. Otherwise, strongly consider using a {@code LinkedHashSet}
+   * instead, at the cost of increased memory footprint, to get
+   * deterministic iteration behavior.
+   */
+  public static <E> HashSet<E> newHashSet() {
+    return new HashSet<E>();
+  }
+
+  /**
+   * Creates a <i>mutable</i>, empty {@code TreeSet} instance sorted by the
+   * natural sort ordering of its elements.
+   *
+   * <p><b>Note:</b> if mutability is not required, use ImmutableSortedSet#of()
+   * instead.
+   *
+   * @return a new, empty {@code TreeSet}
+   */
+  public static <E extends Comparable> TreeSet<E> newTreeSet() {
+    return new TreeSet<E>();
+  }

Review comment:
       for these two "make an empty set" implementations, what's the advantage 
of having an implementation here rather than following the advice from Guava 
for jdk7+ to use the constructor directly?

##########
File path: 
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Sets.java
##########
@@ -0,0 +1,329 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.util;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Static utility methods pertaining to {@link Set} instances.
+ * This class is Hadoop's internal use alternative to Guava's Sets
+ * utility class.
+ */
+@InterfaceAudience.Private
+public final class Sets {
+
+  private Sets() {
+    // empty
+  }
+
+  /**
+   * Creates a <i>mutable</i>, initially empty {@code HashSet} instance.
+   *
+   * <p><b>Note:</b> if mutability is not required, use ImmutableSet#of()
+   * instead. If {@code E} is an {@link Enum} type, use {@link EnumSet#noneOf}
+   * instead. Otherwise, strongly consider using a {@code LinkedHashSet}
+   * instead, at the cost of increased memory footprint, to get
+   * deterministic iteration behavior.
+   */
+  public static <E> HashSet<E> newHashSet() {
+    return new HashSet<E>();
+  }
+
+  /**
+   * Creates a <i>mutable</i>, empty {@code TreeSet} instance sorted by the
+   * natural sort ordering of its elements.
+   *
+   * <p><b>Note:</b> if mutability is not required, use ImmutableSortedSet#of()
+   * instead.
+   *
+   * @return a new, empty {@code TreeSet}
+   */
+  public static <E extends Comparable> TreeSet<E> newTreeSet() {
+    return new TreeSet<E>();
+  }
+
+  /**
+   * Creates a <i>mutable</i> {@code HashSet} instance initially containing
+   * the given elements.
+   *
+   * <p><b>Note:</b> if elements are non-null and won't be added or removed
+   * after this point, use ImmutableSet#of() or ImmutableSet#copyOf(Object[])
+   * instead. If {@code E} is an {@link Enum} type, use
+   * {@link EnumSet#of(Enum, Enum[])} instead. Otherwise, strongly consider
+   * using a {@code LinkedHashSet} instead, at the cost of increased memory
+   * footprint, to get deterministic iteration behavior.
+   *
+   * <p>This method is just a small convenience, either for
+   * {@code newHashSet(}{@link Arrays#asList}{@code (...))}, or for creating an
+   * empty set then calling {@link Collections#addAll}.
+   */
+  @SafeVarargs
+  public static <E> HashSet<E> newHashSet(E... elements) {
+    HashSet<E> set = newHashSetWithExpectedSize(elements.length);
+    Collections.addAll(set, elements);
+    return set;
+  }
+
+  /**
+   * Creates a <i>mutable</i> {@code HashSet} instance containing the given
+   * elements. A very thin convenience for creating an empty set then calling
+   * {@link Collection#addAll} or Iterables#addAll.
+   *
+   * <p><b>Note:</b> if mutability is not required and the elements are
+   * non-null, use ImmutableSet#copyOf(Iterable) instead. (Or, change
+   * {@code elements} to be a FluentIterable and call {@code 
elements.toSet()}.)
+   *
+   * <p><b>Note:</b> if {@code E} is an {@link Enum} type, use
+   * newEnumSet(Iterable, Class) instead.
+   */
+  public static <E> HashSet<E> newHashSet(Iterable<? extends E> elements) {
+    return (elements instanceof Collection)
+        ? new HashSet<E>(cast(elements))
+        : newHashSet(elements.iterator());
+  }
+
+  /**
+   * Creates a <i>mutable</i> {@code TreeSet} instance containing the given
+   * elements sorted by their natural ordering.
+   *
+   * <p><b>Note:</b> if mutability is not required, use
+   * ImmutableSortedSet#copyOf(Iterable) instead.
+   *
+   * <p><b>Note:</b> If {@code elements} is a {@code SortedSet} with an
+   * explicit comparator, this method has different behavior than
+   * {@link TreeSet#TreeSet(SortedSet)}, which returns a {@code TreeSet}
+   * with that comparator.
+   *
+   * <p><b>Note for Java 7 and later:</b> this method is now unnecessary and
+   * should be treated as deprecated. Instead, use the {@code TreeSet}
+   * constructor directly, taking advantage of the new
+   * <a href="http://goo.gl/iz2Wi";>"diamond" syntax</a>.
+   *
+   * <p>This method is just a small convenience for creating an empty set and
+   * then calling Iterables#addAll. This method is not very useful and will
+   * likely be deprecated in the future.
+   *
+   * @param elements the elements that the set should contain
+   * @return a new {@code TreeSet} containing those elements (minus duplicates)
+   */
+  public static <E extends Comparable> TreeSet<E> newTreeSet(
+      Iterable<? extends E> elements) {
+    TreeSet<E> set = newTreeSet();
+    addAll(set, elements);
+    return set;
+  }
+
+  private static <E extends Comparable> boolean addAll(TreeSet<E> addTo,
+      Iterable<? extends E> elementsToAdd) {
+    if (elementsToAdd instanceof Collection) {
+      Collection<? extends E> c = cast(elementsToAdd);
+      return addTo.addAll(c);
+    }
+    if (elementsToAdd == null) {
+      throw new NullPointerException();
+    }
+    return addAll(addTo, elementsToAdd.iterator());
+  }
+
+  /**
+   * Creates a <i>mutable</i> {@code HashSet} instance containing the given
+   * elements. A very thin convenience for creating an empty set and then
+   * calling Iterators#addAll.
+   *
+   * <p><b>Note:</b> if mutability is not required and the elements are
+   * non-null, use ImmutableSet#copyOf(Iterator) instead.
+   *
+   * <p><b>Note:</b> if {@code E} is an {@link Enum} type, you should create
+   * an {@link EnumSet} instead.
+   *
+   * <p>Overall, this method is not very useful and will likely be deprecated
+   * in the future.
+   */
+  public static <E> HashSet<E> newHashSet(Iterator<? extends E> elements) {
+    HashSet<E> set = newHashSet();
+    addAll(set, elements);
+    return set;
+  }
+
+  /**
+   * Returns a new hash set using the smallest initial table size that can hold
+   * {@code expectedSize} elements without resizing. Note that this is not what
+   * {@link HashSet#HashSet(int)} does, but it is what most users want and
+   * expect it to do.
+   *
+   * <p>This behavior can't be broadly guaranteed, but has been tested with
+   * OpenJDK 1.7 and 1.8.
+   *
+   * @param expectedSize the number of elements you expect to add to the
+   *     returned set
+   * @return a new, empty hash set with enough capacity to hold
+   *     {@code expectedSize} elements without resizing
+   * @throws IllegalArgumentException if {@code expectedSize} is negative
+   */
+  public static <E> HashSet<E> newHashSetWithExpectedSize(int expectedSize) {
+    return new HashSet<E>(expectedSize);
+  }
+
+  private static <E> Collection<E> cast(Iterable<E> iterable) {
+    return (Collection<E>) iterable;
+  }
+
+  private static <E> boolean addAll(Collection<E> addTo,
+      Iterator<? extends E> iterator) {
+    if (addTo == null) {
+      throw new NullPointerException();
+    }
+    if (iterator == null) {
+      throw new NullPointerException();
+    }
+    boolean wasModified = false;
+    while (iterator.hasNext()) {
+      wasModified |= addTo.add(iterator.next());
+    }
+    return wasModified;
+  }
+
+  /**
+   * Returns the intersection of two sets as an unmodifiable set.
+   */
+  public static <E> Set<E> intersection(final Set<E> set1,
+      final Set<E> set2) {
+    if (set1 == null) {
+      throw new NullPointerException("set1");
+    }
+    if (set2 == null) {
+      throw new NullPointerException("set2");
+    }
+    Set<E> newSet = new HashSet<>(set1);
+    newSet.retainAll(set2);
+    return Collections.unmodifiableSet(newSet);
+  }
+
+  /**
+   * Returns the symmetric difference of two sets as an unmodifiable set.
+   * Should be used with HashSet only.
+   */
+  public static <E> Set<E> union(
+      final Set<E> set1, final Set<E> set2) {
+    if (set1 == null) {
+      throw new NullPointerException("set1");
+    }
+    if (set2 == null) {
+      throw new NullPointerException("set2");
+    }
+    Set<E> newSet = new HashSet<>(set1);
+    newSet.addAll(set2);
+    return Collections.unmodifiableSet(newSet);
+  }
+
+  /**
+   * Returns the difference of two sets as an unmodifiable set.
+   * Removes all element from set1 that are contained in set2.
+   * This method is used to find difference for HashSets. For TreeSets with
+   * strict order requirement, recommended method is
+   * {@link #differenceInTreeSets(Set, Set)}.
+   */
+  public static <E> Set<E> difference(
+      final Set<E> set1, final Set<E> set2) {
+    if (set1 == null) {
+      throw new NullPointerException("set1");
+    }
+    if (set2 == null) {
+      throw new NullPointerException("set2");
+    }
+    Set<E> newSet = new HashSet<>(set1);
+    newSet.removeAll(set2);
+    return Collections.unmodifiableSet(newSet);
+  }
+
+  /**
+   * Returns the difference of two Tree sets as an unmodifiable set.
+   * Removes all element from set1 that are contained in set2.
+   */
+  public static <E> Set<E> differenceInTreeSets(
+      final Set<E> set1, final Set<E> set2) {
+    if (set1 == null) {
+      throw new NullPointerException("set1");
+    }
+    if (set2 == null) {
+      throw new NullPointerException("set2");
+    }
+    Set<E> newSet = new TreeSet<>(set1);
+    newSet.removeAll(set2);
+    return Collections.unmodifiableSet(newSet);
+  }
+
+  /**
+   * Returns the symmetric difference of two sets as an unmodifiable set.
+   */
+  public static <E> Set<E> symmetricDifference(
+      final Set<E> set1, final Set<E> set2) {

Review comment:
       include a definition of symmetric difference, e.g. `The symmetric 
difference is defined as elements that are in set1 or set2, but not in both.`

##########
File path: 
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Sets.java
##########
@@ -0,0 +1,329 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.util;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Static utility methods pertaining to {@link Set} instances.
+ * This class is Hadoop's internal use alternative to Guava's Sets
+ * utility class.
+ */
+@InterfaceAudience.Private
+public final class Sets {
+
+  private Sets() {
+    // empty
+  }
+
+  /**
+   * Creates a <i>mutable</i>, initially empty {@code HashSet} instance.
+   *
+   * <p><b>Note:</b> if mutability is not required, use ImmutableSet#of()
+   * instead. If {@code E} is an {@link Enum} type, use {@link EnumSet#noneOf}
+   * instead. Otherwise, strongly consider using a {@code LinkedHashSet}
+   * instead, at the cost of increased memory footprint, to get
+   * deterministic iteration behavior.
+   */
+  public static <E> HashSet<E> newHashSet() {
+    return new HashSet<E>();
+  }
+
+  /**
+   * Creates a <i>mutable</i>, empty {@code TreeSet} instance sorted by the
+   * natural sort ordering of its elements.
+   *
+   * <p><b>Note:</b> if mutability is not required, use ImmutableSortedSet#of()
+   * instead.
+   *
+   * @return a new, empty {@code TreeSet}
+   */
+  public static <E extends Comparable> TreeSet<E> newTreeSet() {
+    return new TreeSet<E>();
+  }
+
+  /**
+   * Creates a <i>mutable</i> {@code HashSet} instance initially containing
+   * the given elements.
+   *
+   * <p><b>Note:</b> if elements are non-null and won't be added or removed
+   * after this point, use ImmutableSet#of() or ImmutableSet#copyOf(Object[])
+   * instead. If {@code E} is an {@link Enum} type, use
+   * {@link EnumSet#of(Enum, Enum[])} instead. Otherwise, strongly consider
+   * using a {@code LinkedHashSet} instead, at the cost of increased memory
+   * footprint, to get deterministic iteration behavior.
+   *
+   * <p>This method is just a small convenience, either for
+   * {@code newHashSet(}{@link Arrays#asList}{@code (...))}, or for creating an
+   * empty set then calling {@link Collections#addAll}.
+   */
+  @SafeVarargs
+  public static <E> HashSet<E> newHashSet(E... elements) {
+    HashSet<E> set = newHashSetWithExpectedSize(elements.length);
+    Collections.addAll(set, elements);
+    return set;
+  }
+
+  /**
+   * Creates a <i>mutable</i> {@code HashSet} instance containing the given
+   * elements. A very thin convenience for creating an empty set then calling
+   * {@link Collection#addAll} or Iterables#addAll.
+   *
+   * <p><b>Note:</b> if mutability is not required and the elements are
+   * non-null, use ImmutableSet#copyOf(Iterable) instead. (Or, change
+   * {@code elements} to be a FluentIterable and call {@code 
elements.toSet()}.)
+   *
+   * <p><b>Note:</b> if {@code E} is an {@link Enum} type, use
+   * newEnumSet(Iterable, Class) instead.
+   */
+  public static <E> HashSet<E> newHashSet(Iterable<? extends E> elements) {
+    return (elements instanceof Collection)
+        ? new HashSet<E>(cast(elements))
+        : newHashSet(elements.iterator());
+  }
+
+  /**
+   * Creates a <i>mutable</i> {@code TreeSet} instance containing the given
+   * elements sorted by their natural ordering.
+   *
+   * <p><b>Note:</b> if mutability is not required, use
+   * ImmutableSortedSet#copyOf(Iterable) instead.
+   *
+   * <p><b>Note:</b> If {@code elements} is a {@code SortedSet} with an
+   * explicit comparator, this method has different behavior than
+   * {@link TreeSet#TreeSet(SortedSet)}, which returns a {@code TreeSet}
+   * with that comparator.
+   *
+   * <p><b>Note for Java 7 and later:</b> this method is now unnecessary and
+   * should be treated as deprecated. Instead, use the {@code TreeSet}
+   * constructor directly, taking advantage of the new
+   * <a href="http://goo.gl/iz2Wi";>"diamond" syntax</a>.
+   *
+   * <p>This method is just a small convenience for creating an empty set and
+   * then calling Iterables#addAll. This method is not very useful and will
+   * likely be deprecated in the future.
+   *
+   * @param elements the elements that the set should contain
+   * @return a new {@code TreeSet} containing those elements (minus duplicates)
+   */
+  public static <E extends Comparable> TreeSet<E> newTreeSet(
+      Iterable<? extends E> elements) {
+    TreeSet<E> set = newTreeSet();
+    addAll(set, elements);
+    return set;
+  }
+
+  private static <E extends Comparable> boolean addAll(TreeSet<E> addTo,
+      Iterable<? extends E> elementsToAdd) {
+    if (elementsToAdd instanceof Collection) {
+      Collection<? extends E> c = cast(elementsToAdd);
+      return addTo.addAll(c);
+    }
+    if (elementsToAdd == null) {
+      throw new NullPointerException();
+    }
+    return addAll(addTo, elementsToAdd.iterator());
+  }
+
+  /**
+   * Creates a <i>mutable</i> {@code HashSet} instance containing the given
+   * elements. A very thin convenience for creating an empty set and then
+   * calling Iterators#addAll.
+   *
+   * <p><b>Note:</b> if mutability is not required and the elements are
+   * non-null, use ImmutableSet#copyOf(Iterator) instead.
+   *
+   * <p><b>Note:</b> if {@code E} is an {@link Enum} type, you should create
+   * an {@link EnumSet} instead.
+   *
+   * <p>Overall, this method is not very useful and will likely be deprecated
+   * in the future.
+   */
+  public static <E> HashSet<E> newHashSet(Iterator<? extends E> elements) {
+    HashSet<E> set = newHashSet();
+    addAll(set, elements);
+    return set;
+  }
+
+  /**
+   * Returns a new hash set using the smallest initial table size that can hold
+   * {@code expectedSize} elements without resizing. Note that this is not what
+   * {@link HashSet#HashSet(int)} does, but it is what most users want and
+   * expect it to do.
+   *
+   * <p>This behavior can't be broadly guaranteed, but has been tested with
+   * OpenJDK 1.7 and 1.8.
+   *
+   * @param expectedSize the number of elements you expect to add to the
+   *     returned set
+   * @return a new, empty hash set with enough capacity to hold
+   *     {@code expectedSize} elements without resizing
+   * @throws IllegalArgumentException if {@code expectedSize} is negative
+   */
+  public static <E> HashSet<E> newHashSetWithExpectedSize(int expectedSize) {
+    return new HashSet<E>(expectedSize);
+  }

Review comment:
       the javadoc for `newHashSetWithExpectedSize` says that this method call 
to `HashSet#HashSet(int)` won't fulfill the contract of this method.
   
   If the handful of places we call this method can be reworked to somehow not 
rely on the behavior, we should do that. There's very few of them, and e.g. the 
use in `FsDatasetImpl` should probably just be calling `new 
HashSet(Collection)`.
   
   If that doesn't work for whatever reason, then I recommend copying the 
implementation of Guava's `Maps.capacity` here as a private method and using 
it, since that's what the guava version of this method does.

##########
File path: 
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Sets.java
##########
@@ -0,0 +1,329 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.util;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Static utility methods pertaining to {@link Set} instances.
+ * This class is Hadoop's internal use alternative to Guava's Sets
+ * utility class.
+ */
+@InterfaceAudience.Private
+public final class Sets {
+
+  private Sets() {
+    // empty
+  }
+
+  /**
+   * Creates a <i>mutable</i>, initially empty {@code HashSet} instance.
+   *
+   * <p><b>Note:</b> if mutability is not required, use ImmutableSet#of()
+   * instead. If {@code E} is an {@link Enum} type, use {@link EnumSet#noneOf}
+   * instead. Otherwise, strongly consider using a {@code LinkedHashSet}
+   * instead, at the cost of increased memory footprint, to get
+   * deterministic iteration behavior.
+   */
+  public static <E> HashSet<E> newHashSet() {
+    return new HashSet<E>();
+  }
+
+  /**
+   * Creates a <i>mutable</i>, empty {@code TreeSet} instance sorted by the
+   * natural sort ordering of its elements.
+   *
+   * <p><b>Note:</b> if mutability is not required, use ImmutableSortedSet#of()
+   * instead.
+   *
+   * @return a new, empty {@code TreeSet}
+   */
+  public static <E extends Comparable> TreeSet<E> newTreeSet() {
+    return new TreeSet<E>();
+  }
+
+  /**
+   * Creates a <i>mutable</i> {@code HashSet} instance initially containing
+   * the given elements.
+   *
+   * <p><b>Note:</b> if elements are non-null and won't be added or removed
+   * after this point, use ImmutableSet#of() or ImmutableSet#copyOf(Object[])
+   * instead. If {@code E} is an {@link Enum} type, use
+   * {@link EnumSet#of(Enum, Enum[])} instead. Otherwise, strongly consider
+   * using a {@code LinkedHashSet} instead, at the cost of increased memory
+   * footprint, to get deterministic iteration behavior.
+   *
+   * <p>This method is just a small convenience, either for
+   * {@code newHashSet(}{@link Arrays#asList}{@code (...))}, or for creating an
+   * empty set then calling {@link Collections#addAll}.
+   */
+  @SafeVarargs
+  public static <E> HashSet<E> newHashSet(E... elements) {
+    HashSet<E> set = newHashSetWithExpectedSize(elements.length);
+    Collections.addAll(set, elements);
+    return set;
+  }
+
+  /**
+   * Creates a <i>mutable</i> {@code HashSet} instance containing the given
+   * elements. A very thin convenience for creating an empty set then calling
+   * {@link Collection#addAll} or Iterables#addAll.
+   *
+   * <p><b>Note:</b> if mutability is not required and the elements are
+   * non-null, use ImmutableSet#copyOf(Iterable) instead. (Or, change
+   * {@code elements} to be a FluentIterable and call {@code 
elements.toSet()}.)
+   *
+   * <p><b>Note:</b> if {@code E} is an {@link Enum} type, use
+   * newEnumSet(Iterable, Class) instead.
+   */
+  public static <E> HashSet<E> newHashSet(Iterable<? extends E> elements) {
+    return (elements instanceof Collection)
+        ? new HashSet<E>(cast(elements))
+        : newHashSet(elements.iterator());
+  }
+
+  /**
+   * Creates a <i>mutable</i> {@code TreeSet} instance containing the given
+   * elements sorted by their natural ordering.
+   *
+   * <p><b>Note:</b> if mutability is not required, use
+   * ImmutableSortedSet#copyOf(Iterable) instead.
+   *
+   * <p><b>Note:</b> If {@code elements} is a {@code SortedSet} with an
+   * explicit comparator, this method has different behavior than
+   * {@link TreeSet#TreeSet(SortedSet)}, which returns a {@code TreeSet}
+   * with that comparator.
+   *
+   * <p><b>Note for Java 7 and later:</b> this method is now unnecessary and
+   * should be treated as deprecated. Instead, use the {@code TreeSet}
+   * constructor directly, taking advantage of the new
+   * <a href="http://goo.gl/iz2Wi";>"diamond" syntax</a>.
+   *
+   * <p>This method is just a small convenience for creating an empty set and
+   * then calling Iterables#addAll. This method is not very useful and will
+   * likely be deprecated in the future.
+   *
+   * @param elements the elements that the set should contain
+   * @return a new {@code TreeSet} containing those elements (minus duplicates)
+   */
+  public static <E extends Comparable> TreeSet<E> newTreeSet(
+      Iterable<? extends E> elements) {
+    TreeSet<E> set = newTreeSet();
+    addAll(set, elements);
+    return set;
+  }
+
+  private static <E extends Comparable> boolean addAll(TreeSet<E> addTo,
+      Iterable<? extends E> elementsToAdd) {
+    if (elementsToAdd instanceof Collection) {
+      Collection<? extends E> c = cast(elementsToAdd);
+      return addTo.addAll(c);
+    }
+    if (elementsToAdd == null) {
+      throw new NullPointerException();
+    }
+    return addAll(addTo, elementsToAdd.iterator());
+  }
+
+  /**
+   * Creates a <i>mutable</i> {@code HashSet} instance containing the given
+   * elements. A very thin convenience for creating an empty set and then
+   * calling Iterators#addAll.
+   *
+   * <p><b>Note:</b> if mutability is not required and the elements are
+   * non-null, use ImmutableSet#copyOf(Iterator) instead.
+   *
+   * <p><b>Note:</b> if {@code E} is an {@link Enum} type, you should create
+   * an {@link EnumSet} instead.
+   *
+   * <p>Overall, this method is not very useful and will likely be deprecated
+   * in the future.
+   */
+  public static <E> HashSet<E> newHashSet(Iterator<? extends E> elements) {
+    HashSet<E> set = newHashSet();
+    addAll(set, elements);
+    return set;
+  }
+
+  /**
+   * Returns a new hash set using the smallest initial table size that can hold
+   * {@code expectedSize} elements without resizing. Note that this is not what
+   * {@link HashSet#HashSet(int)} does, but it is what most users want and
+   * expect it to do.
+   *
+   * <p>This behavior can't be broadly guaranteed, but has been tested with
+   * OpenJDK 1.7 and 1.8.
+   *
+   * @param expectedSize the number of elements you expect to add to the
+   *     returned set
+   * @return a new, empty hash set with enough capacity to hold
+   *     {@code expectedSize} elements without resizing
+   * @throws IllegalArgumentException if {@code expectedSize} is negative
+   */
+  public static <E> HashSet<E> newHashSetWithExpectedSize(int expectedSize) {
+    return new HashSet<E>(expectedSize);
+  }
+
+  private static <E> Collection<E> cast(Iterable<E> iterable) {
+    return (Collection<E>) iterable;
+  }
+
+  private static <E> boolean addAll(Collection<E> addTo,
+      Iterator<? extends E> iterator) {
+    if (addTo == null) {
+      throw new NullPointerException();
+    }
+    if (iterator == null) {
+      throw new NullPointerException();
+    }
+    boolean wasModified = false;
+    while (iterator.hasNext()) {
+      wasModified |= addTo.add(iterator.next());
+    }
+    return wasModified;
+  }
+
+  /**
+   * Returns the intersection of two sets as an unmodifiable set.
+   */
+  public static <E> Set<E> intersection(final Set<E> set1,
+      final Set<E> set2) {

Review comment:
       please add ```the intersection is defined as elements that are in both 
set1 and set2.```

##########
File path: 
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Sets.java
##########
@@ -0,0 +1,329 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.util;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Static utility methods pertaining to {@link Set} instances.
+ * This class is Hadoop's internal use alternative to Guava's Sets
+ * utility class.
+ */
+@InterfaceAudience.Private
+public final class Sets {
+
+  private Sets() {
+    // empty
+  }
+
+  /**
+   * Creates a <i>mutable</i>, initially empty {@code HashSet} instance.
+   *
+   * <p><b>Note:</b> if mutability is not required, use ImmutableSet#of()
+   * instead. If {@code E} is an {@link Enum} type, use {@link EnumSet#noneOf}
+   * instead. Otherwise, strongly consider using a {@code LinkedHashSet}
+   * instead, at the cost of increased memory footprint, to get
+   * deterministic iteration behavior.
+   */
+  public static <E> HashSet<E> newHashSet() {
+    return new HashSet<E>();
+  }
+
+  /**
+   * Creates a <i>mutable</i>, empty {@code TreeSet} instance sorted by the
+   * natural sort ordering of its elements.
+   *
+   * <p><b>Note:</b> if mutability is not required, use ImmutableSortedSet#of()
+   * instead.
+   *
+   * @return a new, empty {@code TreeSet}
+   */
+  public static <E extends Comparable> TreeSet<E> newTreeSet() {
+    return new TreeSet<E>();
+  }
+
+  /**
+   * Creates a <i>mutable</i> {@code HashSet} instance initially containing
+   * the given elements.
+   *
+   * <p><b>Note:</b> if elements are non-null and won't be added or removed
+   * after this point, use ImmutableSet#of() or ImmutableSet#copyOf(Object[])
+   * instead. If {@code E} is an {@link Enum} type, use
+   * {@link EnumSet#of(Enum, Enum[])} instead. Otherwise, strongly consider
+   * using a {@code LinkedHashSet} instead, at the cost of increased memory
+   * footprint, to get deterministic iteration behavior.
+   *
+   * <p>This method is just a small convenience, either for
+   * {@code newHashSet(}{@link Arrays#asList}{@code (...))}, or for creating an
+   * empty set then calling {@link Collections#addAll}.
+   */
+  @SafeVarargs
+  public static <E> HashSet<E> newHashSet(E... elements) {
+    HashSet<E> set = newHashSetWithExpectedSize(elements.length);
+    Collections.addAll(set, elements);
+    return set;
+  }
+
+  /**
+   * Creates a <i>mutable</i> {@code HashSet} instance containing the given
+   * elements. A very thin convenience for creating an empty set then calling
+   * {@link Collection#addAll} or Iterables#addAll.
+   *
+   * <p><b>Note:</b> if mutability is not required and the elements are
+   * non-null, use ImmutableSet#copyOf(Iterable) instead. (Or, change
+   * {@code elements} to be a FluentIterable and call {@code 
elements.toSet()}.)
+   *
+   * <p><b>Note:</b> if {@code E} is an {@link Enum} type, use
+   * newEnumSet(Iterable, Class) instead.
+   */
+  public static <E> HashSet<E> newHashSet(Iterable<? extends E> elements) {
+    return (elements instanceof Collection)
+        ? new HashSet<E>(cast(elements))
+        : newHashSet(elements.iterator());
+  }
+
+  /**
+   * Creates a <i>mutable</i> {@code TreeSet} instance containing the given
+   * elements sorted by their natural ordering.
+   *
+   * <p><b>Note:</b> if mutability is not required, use
+   * ImmutableSortedSet#copyOf(Iterable) instead.
+   *
+   * <p><b>Note:</b> If {@code elements} is a {@code SortedSet} with an
+   * explicit comparator, this method has different behavior than
+   * {@link TreeSet#TreeSet(SortedSet)}, which returns a {@code TreeSet}
+   * with that comparator.
+   *
+   * <p><b>Note for Java 7 and later:</b> this method is now unnecessary and
+   * should be treated as deprecated. Instead, use the {@code TreeSet}
+   * constructor directly, taking advantage of the new
+   * <a href="http://goo.gl/iz2Wi";>"diamond" syntax</a>.
+   *
+   * <p>This method is just a small convenience for creating an empty set and
+   * then calling Iterables#addAll. This method is not very useful and will
+   * likely be deprecated in the future.
+   *
+   * @param elements the elements that the set should contain
+   * @return a new {@code TreeSet} containing those elements (minus duplicates)
+   */
+  public static <E extends Comparable> TreeSet<E> newTreeSet(
+      Iterable<? extends E> elements) {
+    TreeSet<E> set = newTreeSet();
+    addAll(set, elements);
+    return set;
+  }
+
+  private static <E extends Comparable> boolean addAll(TreeSet<E> addTo,
+      Iterable<? extends E> elementsToAdd) {
+    if (elementsToAdd instanceof Collection) {
+      Collection<? extends E> c = cast(elementsToAdd);
+      return addTo.addAll(c);
+    }
+    if (elementsToAdd == null) {
+      throw new NullPointerException();
+    }
+    return addAll(addTo, elementsToAdd.iterator());
+  }
+
+  /**
+   * Creates a <i>mutable</i> {@code HashSet} instance containing the given
+   * elements. A very thin convenience for creating an empty set and then
+   * calling Iterators#addAll.
+   *
+   * <p><b>Note:</b> if mutability is not required and the elements are
+   * non-null, use ImmutableSet#copyOf(Iterator) instead.
+   *
+   * <p><b>Note:</b> if {@code E} is an {@link Enum} type, you should create
+   * an {@link EnumSet} instead.
+   *
+   * <p>Overall, this method is not very useful and will likely be deprecated
+   * in the future.
+   */
+  public static <E> HashSet<E> newHashSet(Iterator<? extends E> elements) {
+    HashSet<E> set = newHashSet();
+    addAll(set, elements);
+    return set;
+  }
+
+  /**
+   * Returns a new hash set using the smallest initial table size that can hold
+   * {@code expectedSize} elements without resizing. Note that this is not what
+   * {@link HashSet#HashSet(int)} does, but it is what most users want and
+   * expect it to do.
+   *
+   * <p>This behavior can't be broadly guaranteed, but has been tested with
+   * OpenJDK 1.7 and 1.8.
+   *
+   * @param expectedSize the number of elements you expect to add to the
+   *     returned set
+   * @return a new, empty hash set with enough capacity to hold
+   *     {@code expectedSize} elements without resizing
+   * @throws IllegalArgumentException if {@code expectedSize} is negative
+   */
+  public static <E> HashSet<E> newHashSetWithExpectedSize(int expectedSize) {
+    return new HashSet<E>(expectedSize);
+  }
+
+  private static <E> Collection<E> cast(Iterable<E> iterable) {
+    return (Collection<E>) iterable;
+  }
+
+  private static <E> boolean addAll(Collection<E> addTo,
+      Iterator<? extends E> iterator) {
+    if (addTo == null) {
+      throw new NullPointerException();
+    }
+    if (iterator == null) {
+      throw new NullPointerException();
+    }
+    boolean wasModified = false;
+    while (iterator.hasNext()) {
+      wasModified |= addTo.add(iterator.next());
+    }
+    return wasModified;
+  }
+
+  /**
+   * Returns the intersection of two sets as an unmodifiable set.
+   */
+  public static <E> Set<E> intersection(final Set<E> set1,
+      final Set<E> set2) {
+    if (set1 == null) {
+      throw new NullPointerException("set1");
+    }
+    if (set2 == null) {
+      throw new NullPointerException("set2");
+    }
+    Set<E> newSet = new HashSet<>(set1);
+    newSet.retainAll(set2);
+    return Collections.unmodifiableSet(newSet);
+  }
+
+  /**
+   * Returns the symmetric difference of two sets as an unmodifiable set.
+   * Should be used with HashSet only.
+   */
+  public static <E> Set<E> union(
+      final Set<E> set1, final Set<E> set2) {

Review comment:
       looks like Javadoc for the wrong method?

##########
File path: 
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Sets.java
##########
@@ -0,0 +1,329 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.util;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Static utility methods pertaining to {@link Set} instances.
+ * This class is Hadoop's internal use alternative to Guava's Sets
+ * utility class.
+ */
+@InterfaceAudience.Private
+public final class Sets {
+
+  private Sets() {
+    // empty
+  }
+
+  /**
+   * Creates a <i>mutable</i>, initially empty {@code HashSet} instance.
+   *
+   * <p><b>Note:</b> if mutability is not required, use ImmutableSet#of()
+   * instead. If {@code E} is an {@link Enum} type, use {@link EnumSet#noneOf}
+   * instead. Otherwise, strongly consider using a {@code LinkedHashSet}
+   * instead, at the cost of increased memory footprint, to get
+   * deterministic iteration behavior.
+   */
+  public static <E> HashSet<E> newHashSet() {
+    return new HashSet<E>();
+  }
+
+  /**
+   * Creates a <i>mutable</i>, empty {@code TreeSet} instance sorted by the
+   * natural sort ordering of its elements.
+   *
+   * <p><b>Note:</b> if mutability is not required, use ImmutableSortedSet#of()
+   * instead.
+   *
+   * @return a new, empty {@code TreeSet}
+   */
+  public static <E extends Comparable> TreeSet<E> newTreeSet() {
+    return new TreeSet<E>();
+  }
+
+  /**
+   * Creates a <i>mutable</i> {@code HashSet} instance initially containing
+   * the given elements.
+   *
+   * <p><b>Note:</b> if elements are non-null and won't be added or removed
+   * after this point, use ImmutableSet#of() or ImmutableSet#copyOf(Object[])
+   * instead. If {@code E} is an {@link Enum} type, use
+   * {@link EnumSet#of(Enum, Enum[])} instead. Otherwise, strongly consider
+   * using a {@code LinkedHashSet} instead, at the cost of increased memory
+   * footprint, to get deterministic iteration behavior.
+   *
+   * <p>This method is just a small convenience, either for
+   * {@code newHashSet(}{@link Arrays#asList}{@code (...))}, or for creating an
+   * empty set then calling {@link Collections#addAll}.
+   */
+  @SafeVarargs
+  public static <E> HashSet<E> newHashSet(E... elements) {
+    HashSet<E> set = newHashSetWithExpectedSize(elements.length);
+    Collections.addAll(set, elements);
+    return set;
+  }
+
+  /**
+   * Creates a <i>mutable</i> {@code HashSet} instance containing the given
+   * elements. A very thin convenience for creating an empty set then calling
+   * {@link Collection#addAll} or Iterables#addAll.
+   *
+   * <p><b>Note:</b> if mutability is not required and the elements are
+   * non-null, use ImmutableSet#copyOf(Iterable) instead. (Or, change
+   * {@code elements} to be a FluentIterable and call {@code 
elements.toSet()}.)
+   *
+   * <p><b>Note:</b> if {@code E} is an {@link Enum} type, use
+   * newEnumSet(Iterable, Class) instead.
+   */
+  public static <E> HashSet<E> newHashSet(Iterable<? extends E> elements) {
+    return (elements instanceof Collection)
+        ? new HashSet<E>(cast(elements))
+        : newHashSet(elements.iterator());
+  }
+
+  /**
+   * Creates a <i>mutable</i> {@code TreeSet} instance containing the given
+   * elements sorted by their natural ordering.
+   *
+   * <p><b>Note:</b> if mutability is not required, use
+   * ImmutableSortedSet#copyOf(Iterable) instead.
+   *
+   * <p><b>Note:</b> If {@code elements} is a {@code SortedSet} with an
+   * explicit comparator, this method has different behavior than
+   * {@link TreeSet#TreeSet(SortedSet)}, which returns a {@code TreeSet}
+   * with that comparator.
+   *
+   * <p><b>Note for Java 7 and later:</b> this method is now unnecessary and
+   * should be treated as deprecated. Instead, use the {@code TreeSet}
+   * constructor directly, taking advantage of the new
+   * <a href="http://goo.gl/iz2Wi";>"diamond" syntax</a>.
+   *
+   * <p>This method is just a small convenience for creating an empty set and
+   * then calling Iterables#addAll. This method is not very useful and will
+   * likely be deprecated in the future.
+   *
+   * @param elements the elements that the set should contain
+   * @return a new {@code TreeSet} containing those elements (minus duplicates)
+   */
+  public static <E extends Comparable> TreeSet<E> newTreeSet(
+      Iterable<? extends E> elements) {
+    TreeSet<E> set = newTreeSet();
+    addAll(set, elements);
+    return set;
+  }
+
+  private static <E extends Comparable> boolean addAll(TreeSet<E> addTo,
+      Iterable<? extends E> elementsToAdd) {
+    if (elementsToAdd instanceof Collection) {
+      Collection<? extends E> c = cast(elementsToAdd);
+      return addTo.addAll(c);
+    }
+    if (elementsToAdd == null) {
+      throw new NullPointerException();
+    }
+    return addAll(addTo, elementsToAdd.iterator());
+  }
+
+  /**
+   * Creates a <i>mutable</i> {@code HashSet} instance containing the given
+   * elements. A very thin convenience for creating an empty set and then
+   * calling Iterators#addAll.
+   *
+   * <p><b>Note:</b> if mutability is not required and the elements are
+   * non-null, use ImmutableSet#copyOf(Iterator) instead.
+   *
+   * <p><b>Note:</b> if {@code E} is an {@link Enum} type, you should create
+   * an {@link EnumSet} instead.
+   *
+   * <p>Overall, this method is not very useful and will likely be deprecated
+   * in the future.
+   */
+  public static <E> HashSet<E> newHashSet(Iterator<? extends E> elements) {
+    HashSet<E> set = newHashSet();
+    addAll(set, elements);
+    return set;
+  }
+
+  /**
+   * Returns a new hash set using the smallest initial table size that can hold
+   * {@code expectedSize} elements without resizing. Note that this is not what
+   * {@link HashSet#HashSet(int)} does, but it is what most users want and
+   * expect it to do.
+   *
+   * <p>This behavior can't be broadly guaranteed, but has been tested with
+   * OpenJDK 1.7 and 1.8.
+   *
+   * @param expectedSize the number of elements you expect to add to the
+   *     returned set
+   * @return a new, empty hash set with enough capacity to hold
+   *     {@code expectedSize} elements without resizing
+   * @throws IllegalArgumentException if {@code expectedSize} is negative
+   */
+  public static <E> HashSet<E> newHashSetWithExpectedSize(int expectedSize) {
+    return new HashSet<E>(expectedSize);
+  }
+
+  private static <E> Collection<E> cast(Iterable<E> iterable) {
+    return (Collection<E>) iterable;
+  }
+
+  private static <E> boolean addAll(Collection<E> addTo,
+      Iterator<? extends E> iterator) {
+    if (addTo == null) {
+      throw new NullPointerException();
+    }
+    if (iterator == null) {
+      throw new NullPointerException();
+    }
+    boolean wasModified = false;
+    while (iterator.hasNext()) {
+      wasModified |= addTo.add(iterator.next());
+    }
+    return wasModified;
+  }
+
+  /**
+   * Returns the intersection of two sets as an unmodifiable set.
+   */
+  public static <E> Set<E> intersection(final Set<E> set1,
+      final Set<E> set2) {
+    if (set1 == null) {
+      throw new NullPointerException("set1");
+    }
+    if (set2 == null) {
+      throw new NullPointerException("set2");
+    }
+    Set<E> newSet = new HashSet<>(set1);
+    newSet.retainAll(set2);
+    return Collections.unmodifiableSet(newSet);
+  }
+
+  /**
+   * Returns the symmetric difference of two sets as an unmodifiable set.
+   * Should be used with HashSet only.
+   */
+  public static <E> Set<E> union(
+      final Set<E> set1, final Set<E> set2) {
+    if (set1 == null) {
+      throw new NullPointerException("set1");
+    }
+    if (set2 == null) {
+      throw new NullPointerException("set2");
+    }
+    Set<E> newSet = new HashSet<>(set1);
+    newSet.addAll(set2);
+    return Collections.unmodifiableSet(newSet);
+  }
+
+  /**
+   * Returns the difference of two sets as an unmodifiable set.
+   * Removes all element from set1 that are contained in set2.
+   * This method is used to find difference for HashSets. For TreeSets with
+   * strict order requirement, recommended method is
+   * {@link #differenceInTreeSets(Set, Set)}.
+   */
+  public static <E> Set<E> difference(
+      final Set<E> set1, final Set<E> set2) {
+    if (set1 == null) {
+      throw new NullPointerException("set1");
+    }
+    if (set2 == null) {
+      throw new NullPointerException("set2");
+    }
+    Set<E> newSet = new HashSet<>(set1);
+    newSet.removeAll(set2);
+    return Collections.unmodifiableSet(newSet);
+  }
+
+  /**
+   * Returns the difference of two Tree sets as an unmodifiable set.
+   * Removes all element from set1 that are contained in set2.
+   */
+  public static <E> Set<E> differenceInTreeSets(
+      final Set<E> set1, final Set<E> set2) {

Review comment:
       This doesn't modify set1, so recommend being clear in phrasing, e.g. 
`the difference is defined as elements that are in set1 but not in set2`

##########
File path: 
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Sets.java
##########
@@ -0,0 +1,329 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.util;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Static utility methods pertaining to {@link Set} instances.
+ * This class is Hadoop's internal use alternative to Guava's Sets
+ * utility class.
+ */
+@InterfaceAudience.Private
+public final class Sets {
+
+  private Sets() {
+    // empty
+  }
+
+  /**
+   * Creates a <i>mutable</i>, initially empty {@code HashSet} instance.
+   *
+   * <p><b>Note:</b> if mutability is not required, use ImmutableSet#of()
+   * instead. If {@code E} is an {@link Enum} type, use {@link EnumSet#noneOf}
+   * instead. Otherwise, strongly consider using a {@code LinkedHashSet}
+   * instead, at the cost of increased memory footprint, to get
+   * deterministic iteration behavior.
+   */
+  public static <E> HashSet<E> newHashSet() {
+    return new HashSet<E>();
+  }
+
+  /**
+   * Creates a <i>mutable</i>, empty {@code TreeSet} instance sorted by the
+   * natural sort ordering of its elements.
+   *
+   * <p><b>Note:</b> if mutability is not required, use ImmutableSortedSet#of()
+   * instead.
+   *
+   * @return a new, empty {@code TreeSet}
+   */
+  public static <E extends Comparable> TreeSet<E> newTreeSet() {
+    return new TreeSet<E>();
+  }
+
+  /**
+   * Creates a <i>mutable</i> {@code HashSet} instance initially containing
+   * the given elements.
+   *
+   * <p><b>Note:</b> if elements are non-null and won't be added or removed
+   * after this point, use ImmutableSet#of() or ImmutableSet#copyOf(Object[])
+   * instead. If {@code E} is an {@link Enum} type, use
+   * {@link EnumSet#of(Enum, Enum[])} instead. Otherwise, strongly consider
+   * using a {@code LinkedHashSet} instead, at the cost of increased memory
+   * footprint, to get deterministic iteration behavior.
+   *
+   * <p>This method is just a small convenience, either for
+   * {@code newHashSet(}{@link Arrays#asList}{@code (...))}, or for creating an
+   * empty set then calling {@link Collections#addAll}.
+   */
+  @SafeVarargs
+  public static <E> HashSet<E> newHashSet(E... elements) {
+    HashSet<E> set = newHashSetWithExpectedSize(elements.length);
+    Collections.addAll(set, elements);
+    return set;
+  }
+
+  /**
+   * Creates a <i>mutable</i> {@code HashSet} instance containing the given
+   * elements. A very thin convenience for creating an empty set then calling
+   * {@link Collection#addAll} or Iterables#addAll.
+   *
+   * <p><b>Note:</b> if mutability is not required and the elements are
+   * non-null, use ImmutableSet#copyOf(Iterable) instead. (Or, change
+   * {@code elements} to be a FluentIterable and call {@code 
elements.toSet()}.)
+   *
+   * <p><b>Note:</b> if {@code E} is an {@link Enum} type, use
+   * newEnumSet(Iterable, Class) instead.
+   */
+  public static <E> HashSet<E> newHashSet(Iterable<? extends E> elements) {
+    return (elements instanceof Collection)
+        ? new HashSet<E>(cast(elements))
+        : newHashSet(elements.iterator());
+  }
+
+  /**
+   * Creates a <i>mutable</i> {@code TreeSet} instance containing the given
+   * elements sorted by their natural ordering.
+   *
+   * <p><b>Note:</b> if mutability is not required, use
+   * ImmutableSortedSet#copyOf(Iterable) instead.
+   *
+   * <p><b>Note:</b> If {@code elements} is a {@code SortedSet} with an
+   * explicit comparator, this method has different behavior than
+   * {@link TreeSet#TreeSet(SortedSet)}, which returns a {@code TreeSet}
+   * with that comparator.
+   *
+   * <p><b>Note for Java 7 and later:</b> this method is now unnecessary and
+   * should be treated as deprecated. Instead, use the {@code TreeSet}
+   * constructor directly, taking advantage of the new
+   * <a href="http://goo.gl/iz2Wi";>"diamond" syntax</a>.
+   *
+   * <p>This method is just a small convenience for creating an empty set and
+   * then calling Iterables#addAll. This method is not very useful and will
+   * likely be deprecated in the future.
+   *
+   * @param elements the elements that the set should contain
+   * @return a new {@code TreeSet} containing those elements (minus duplicates)
+   */
+  public static <E extends Comparable> TreeSet<E> newTreeSet(
+      Iterable<? extends E> elements) {
+    TreeSet<E> set = newTreeSet();
+    addAll(set, elements);
+    return set;
+  }
+
+  private static <E extends Comparable> boolean addAll(TreeSet<E> addTo,
+      Iterable<? extends E> elementsToAdd) {
+    if (elementsToAdd instanceof Collection) {
+      Collection<? extends E> c = cast(elementsToAdd);
+      return addTo.addAll(c);
+    }
+    if (elementsToAdd == null) {
+      throw new NullPointerException();
+    }
+    return addAll(addTo, elementsToAdd.iterator());
+  }
+
+  /**
+   * Creates a <i>mutable</i> {@code HashSet} instance containing the given
+   * elements. A very thin convenience for creating an empty set and then
+   * calling Iterators#addAll.
+   *
+   * <p><b>Note:</b> if mutability is not required and the elements are
+   * non-null, use ImmutableSet#copyOf(Iterator) instead.
+   *
+   * <p><b>Note:</b> if {@code E} is an {@link Enum} type, you should create
+   * an {@link EnumSet} instead.
+   *
+   * <p>Overall, this method is not very useful and will likely be deprecated
+   * in the future.
+   */
+  public static <E> HashSet<E> newHashSet(Iterator<? extends E> elements) {
+    HashSet<E> set = newHashSet();
+    addAll(set, elements);
+    return set;
+  }
+
+  /**
+   * Returns a new hash set using the smallest initial table size that can hold
+   * {@code expectedSize} elements without resizing. Note that this is not what
+   * {@link HashSet#HashSet(int)} does, but it is what most users want and
+   * expect it to do.
+   *
+   * <p>This behavior can't be broadly guaranteed, but has been tested with
+   * OpenJDK 1.7 and 1.8.
+   *
+   * @param expectedSize the number of elements you expect to add to the
+   *     returned set
+   * @return a new, empty hash set with enough capacity to hold
+   *     {@code expectedSize} elements without resizing
+   * @throws IllegalArgumentException if {@code expectedSize} is negative
+   */
+  public static <E> HashSet<E> newHashSetWithExpectedSize(int expectedSize) {
+    return new HashSet<E>(expectedSize);
+  }
+
+  private static <E> Collection<E> cast(Iterable<E> iterable) {
+    return (Collection<E>) iterable;
+  }
+
+  private static <E> boolean addAll(Collection<E> addTo,
+      Iterator<? extends E> iterator) {
+    if (addTo == null) {
+      throw new NullPointerException();
+    }
+    if (iterator == null) {
+      throw new NullPointerException();
+    }
+    boolean wasModified = false;
+    while (iterator.hasNext()) {
+      wasModified |= addTo.add(iterator.next());
+    }
+    return wasModified;
+  }
+
+  /**
+   * Returns the intersection of two sets as an unmodifiable set.
+   */
+  public static <E> Set<E> intersection(final Set<E> set1,
+      final Set<E> set2) {
+    if (set1 == null) {
+      throw new NullPointerException("set1");
+    }
+    if (set2 == null) {
+      throw new NullPointerException("set2");
+    }
+    Set<E> newSet = new HashSet<>(set1);
+    newSet.retainAll(set2);
+    return Collections.unmodifiableSet(newSet);
+  }
+
+  /**
+   * Returns the symmetric difference of two sets as an unmodifiable set.
+   * Should be used with HashSet only.
+   */
+  public static <E> Set<E> union(
+      final Set<E> set1, final Set<E> set2) {
+    if (set1 == null) {
+      throw new NullPointerException("set1");
+    }
+    if (set2 == null) {
+      throw new NullPointerException("set2");
+    }
+    Set<E> newSet = new HashSet<>(set1);
+    newSet.addAll(set2);
+    return Collections.unmodifiableSet(newSet);
+  }
+
+  /**
+   * Returns the difference of two sets as an unmodifiable set.
+   * Removes all element from set1 that are contained in set2.
+   * This method is used to find difference for HashSets. For TreeSets with
+   * strict order requirement, recommended method is
+   * {@link #differenceInTreeSets(Set, Set)}.
+   */
+  public static <E> Set<E> difference(
+      final Set<E> set1, final Set<E> set2) {
+    if (set1 == null) {
+      throw new NullPointerException("set1");
+    }
+    if (set2 == null) {
+      throw new NullPointerException("set2");
+    }
+    Set<E> newSet = new HashSet<>(set1);
+    newSet.removeAll(set2);
+    return Collections.unmodifiableSet(newSet);
+  }
+
+  /**
+   * Returns the difference of two Tree sets as an unmodifiable set.
+   * Removes all element from set1 that are contained in set2.
+   */
+  public static <E> Set<E> differenceInTreeSets(
+      final Set<E> set1, final Set<E> set2) {
+    if (set1 == null) {
+      throw new NullPointerException("set1");
+    }
+    if (set2 == null) {
+      throw new NullPointerException("set2");
+    }
+    Set<E> newSet = new TreeSet<>(set1);
+    newSet.removeAll(set2);
+    return Collections.unmodifiableSet(newSet);
+  }
+
+  /**
+   * Returns the symmetric difference of two sets as an unmodifiable set.
+   */
+  public static <E> Set<E> symmetricDifference(
+      final Set<E> set1, final Set<E> set2) {
+    if (set1 == null) {
+      throw new NullPointerException("set1");
+    }
+    if (set2 == null) {
+      throw new NullPointerException("set2");
+    }
+    Set<E> intersection = new HashSet<>(set1);
+    intersection.retainAll(set2);
+    Set<E> symmetricDifference = new HashSet<>(set1);
+    symmetricDifference.addAll(set2);
+    symmetricDifference.removeAll(intersection);
+    return Collections.unmodifiableSet(symmetricDifference);
+  }
+
+  /**
+   * Creates a thread-safe set backed by a hash map. The set is backed by a
+   * {@link ConcurrentHashMap} instance, and thus carries the same concurrency
+   * guarantees.
+   *
+   * <p>Unlike {@code HashSet}, this class does NOT allow {@code null} to be
+   * used as an element. The set is serializable.
+   *
+   * @return a new, empty thread-safe {@code Set}
+   */
+  public static <E> Set<E> newConcurrentHashSet() {
+    return Collections.newSetFromMap(new ConcurrentHashMap<E, Boolean>());
+  }
+
+  /**
+   * Creates a <i>mutable</i>, empty {@code LinkedHashSet} instance.
+   *
+   * <p><b>Note:</b> if mutability is not required, use ImmutableSet#of()
+   * instead.
+   *
+   * @return a new, empty {@code LinkedHashSet}
+   */
+  public static <E> LinkedHashSet<E> newLinkedHashSet() {
+    return new LinkedHashSet<E>();
+  }

Review comment:
       For this "make an empty set" implementation, what's the advantage of 
having an implementation here rather than following the advice from Guava for 
jdk7+ to use the constructor directly?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 597857)
    Time Spent: 6h 50m  (was: 6h 40m)

> Replace Guava Sets usage by Hadoop's own Sets
> ---------------------------------------------
>
>                 Key: HADOOP-17115
>                 URL: https://issues.apache.org/jira/browse/HADOOP-17115
>             Project: Hadoop Common
>          Issue Type: Sub-task
>            Reporter: Ahmed Hussein
>            Assignee: Viraj Jasani
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 6h 50m
>  Remaining Estimate: 0h
>
> Unjustified usage of Guava API to initialize a {{HashSet}}. This should be 
> replaced by Java APIs.
> {code:java}
> Targets
>     Occurrences of 'Sets.newHashSet' in project
> Found Occurrences  (223 usages found)
>     org.apache.hadoop.crypto.key  (2 usages found)
>         TestValueQueue.java  (2 usages found)
>             testWarmUp()  (2 usages found)
>                 106 Assert.assertEquals(Sets.newHashSet("k1", "k2", "k3"),
>                 107 Sets.newHashSet(fillInfos[0].key,
>     org.apache.hadoop.crypto.key.kms  (6 usages found)
>         TestLoadBalancingKMSClientProvider.java  (6 usages found)
>             testCreation()  (6 usages found)
>                 86 
> assertEquals(Sets.newHashSet("http://host1:9600/kms/foo/v1/";),
>                 87 Sets.newHashSet(providers[0].getKMSUrl()));
>                 95 
> assertEquals(Sets.newHashSet("http://host1:9600/kms/foo/v1/";,
>                 98 Sets.newHashSet(providers[0].getKMSUrl(),
>                 108 
> assertEquals(Sets.newHashSet("http://host1:9600/kms/foo/v1/";,
>                 111 Sets.newHashSet(providers[0].getKMSUrl(),
>     org.apache.hadoop.crypto.key.kms.server  (1 usage found)
>         KMSAudit.java  (1 usage found)
>             59 static final Set<KMS.KMSOp> AGGREGATE_OPS_WHITELIST = 
> Sets.newHashSet(
>     org.apache.hadoop.fs.s3a  (1 usage found)
>         TestS3AAWSCredentialsProvider.java  (1 usage found)
>             testFallbackToDefaults()  (1 usage found)
>                 183 Sets.newHashSet());
>     org.apache.hadoop.fs.s3a.auth  (1 usage found)
>         AssumedRoleCredentialProvider.java  (1 usage found)
>             AssumedRoleCredentialProvider(URI, Configuration)  (1 usage found)
>                 113 Sets.newHashSet(this.getClass()));
>     org.apache.hadoop.fs.s3a.commit.integration  (1 usage found)
>         ITestS3ACommitterMRJob.java  (1 usage found)
>             test_200_execute()  (1 usage found)
>                 232 Set<String> expectedKeys = Sets.newHashSet();
>     org.apache.hadoop.fs.s3a.commit.staging  (5 usages found)
>         TestStagingCommitter.java  (3 usages found)
>             testSingleTaskMultiFileCommit()  (1 usage found)
>                 341 Set<String> keys = Sets.newHashSet();
>             runTasks(JobContext, int, int)  (1 usage found)
>                 603 Set<String> uploads = Sets.newHashSet();
>             commitTask(StagingCommitter, TaskAttemptContext, int)  (1 usage 
> found)
>                 640 Set<String> files = Sets.newHashSet();
>         TestStagingPartitionedTaskCommit.java  (2 usages found)
>             verifyFilesCreated(PartitionedStagingCommitter)  (1 usage found)
>                 148 Set<String> files = Sets.newHashSet();
>             buildExpectedList(StagingCommitter)  (1 usage found)
>                 188 Set<String> expected = Sets.newHashSet();
>     org.apache.hadoop.hdfs  (5 usages found)
>         DFSUtil.java  (2 usages found)
>             getNNServiceRpcAddressesForCluster(Configuration)  (1 usage found)
>                 615 Set<String> availableNameServices = Sets.newHashSet(conf
>             getNNLifelineRpcAddressesForCluster(Configuration)  (1 usage 
> found)
>                 660 Set<String> availableNameServices = Sets.newHashSet(conf
>         MiniDFSCluster.java  (1 usage found)
>             597 private Set<FileSystem> fileSystems = Sets.newHashSet();
>         TestDFSUtil.java  (2 usages found)
>             testGetNNServiceRpcAddressesForNsIds()  (2 usages found)
>                 1046 assertEquals(Sets.newHashSet("nn1"), internal);
>                 1049 assertEquals(Sets.newHashSet("nn1", "nn2"), all);
>     org.apache.hadoop.hdfs.net  (5 usages found)
>         TestDFSNetworkTopology.java  (5 usages found)
>             testChooseRandomWithStorageType()  (4 usages found)
>                 277 Sets.newHashSet("host2", "host4", "host5", "host6");
>                 278 Set<String> archiveUnderL1 = Sets.newHashSet("host1", 
> "host3");
>                 279 Set<String> ramdiskUnderL1 = Sets.newHashSet("host7");
>                 280 Set<String> ssdUnderL1 = Sets.newHashSet("host8");
>             testChooseRandomWithStorageTypeWithExcluded()  (1 usage found)
>                 363 Set<String> expectedSet = Sets.newHashSet("host4", 
> "host5");
>     org.apache.hadoop.hdfs.qjournal.server  (2 usages found)
>         JournalNodeSyncer.java  (2 usages found)
>             getOtherJournalNodeAddrs()  (1 usage found)
>                 276 HashSet<String> sharedEditsUri = Sets.newHashSet();
>             getJournalAddrList(String)  (1 usage found)
>                 318 Sets.newHashSet(jn.getBoundIpcAddress()));
>     org.apache.hadoop.hdfs.server.datanode  (5 usages found)
>         BlockPoolManager.java  (1 usage found)
>             doRefreshNamenodes(Map<String, Map<String, InetSocketAddress>>, 
> Map<String, Map<String, InetSocketAddress>>)  (1 usage found)
>                 198 toRemove = Sets.newHashSet(Sets.difference(
>         BPOfferService.java  (2 usages found)
>             refreshNNList(String, List<String>, ArrayList<InetSocketAddress>, 
> ArrayList<InetSocketAddress>)  (2 usages found)
>                 146 Set<InetSocketAddress> oldAddrs = Sets.newHashSet();
>                 150 Set<InetSocketAddress> newAddrs = Sets.newHashSet(addrs);
>         TestRefreshNamenodes.java  (2 usages found)
>             testRefreshNamenodes()  (2 usages found)
>                 74 Set<InetSocketAddress> nnAddrsFromCluster = 
> Sets.newHashSet();
>                 80 Set<InetSocketAddress> nnAddrsFromDN = Sets.newHashSet();
>     org.apache.hadoop.hdfs.server.datanode.fsdataset.impl  (1 usage found)
>         FsDatasetImpl.java  (1 usage found)
>             getInitialVolumeFailureInfos(Collection<StorageLocation>, 
> DataStorage)  (1 usage found)
>                 430 Set<StorageLocation> failedLocationSet = 
> Sets.newHashSetWithExpectedSize(
>     org.apache.hadoop.hdfs.server.namenode  (11 usages found)
>         FSImageTestUtil.java  (2 usages found)
>             assertFileContentsSame(File...)  (1 usage found)
>                 418 if (Sets.newHashSet(md5s.values()).size() > 1) {
>             assertFileContentsDifferent(int, File...)  (1 usage found)
>                 435 if (Sets.newHashSet(md5s.values()).size() != 
> expectedUniqueHashes) {
>         TestFsck.java  (6 usages found)
>             testFsckMove()  (5 usages found)
>                 388 new CorruptedTestFile(fileNames[0], Sets.newHashSet(0),
>                 390 new CorruptedTestFile(fileNames[1], Sets.newHashSet(2, 3),
>                 392 new CorruptedTestFile(fileNames[2], Sets.newHashSet(4),
>                 394 new CorruptedTestFile(fileNames[3], Sets.newHashSet(0, 1, 
> 2, 3),
>                 396 new CorruptedTestFile(fileNames[4], Sets.newHashSet(1, 2, 
> 3, 4),
>             testFsckMoveAfterCorruption()  (1 usage found)
>                 2217 Sets.newHashSet(0), dfsClient, numDatanodes, 
> dfsBlockSize);
>         TestNameNodeRecovery.java  (3 usages found)
>             getValidTxIds()  (1 usage found)
>                 303 return Sets.newHashSet(0L);
>             getValidTxIds()  (1 usage found)
>                 345 return Sets.newHashSet(0L);
>             getValidTxIds()  (1 usage found)
>                 391 return Sets.newHashSet(1L , 2L, 3L, 5L, 6L, 7L, 8L, 9L, 
> 10L);
>     org.apache.hadoop.mapred  (1 usage found)
>         TestMRTimelineEventHandling.java  (1 usage found)
>             checkNewTimelineEvent(ApplicationId, ApplicationReport, String)  
> (1 usage found)
>                 302 Set<String> cfgsToCheck = Sets.newHashSet("dummy_conf1", 
> "dummy_conf2",
>     org.apache.hadoop.mapreduce.lib.input  (2 usages found)
>         TestFileInputFormat.java  (2 usages found)
>             verifyFileStatuses(List<Path>, List<FileStatus>, FileSystem)  (1 
> usage found)
>                 408 Set<Path> expectedPathSet = 
> Sets.newHashSet(fqExpectedPaths);
>             verifySplits(List<String>, List<InputSplit>)  (1 usage found)
>                 426 Set<String> expectedSet = Sets.newHashSet(expected);
>     org.apache.hadoop.mapreduce.v2.app.webapp  (1 usage found)
>         TestAMWebServices.java  (1 usage found)
>             configureServlets()  (1 usage found)
>                 78 appContext.setBlacklistedNodes(Sets.newHashSet("badnode1", 
> "badnode2"));
>     org.apache.hadoop.mapreduce.v2.hs.webapp  (4 usages found)
>         TestHsWebServicesLogs.java  (4 usages found)
>             testGetAggregatedLogsMetaForFinishedApp()  (1 usage found)
>                 302 Set<String> expectedIdStrings = Sets.newHashSet(
>             testGetAggregatedLogsMetaForRunningApp()  (1 usage found)
>                 335 Set<String> expectedIdStrings = Sets.newHashSet(
>             testGetAggregatedLogsMetaForFinishedAppAttempt()  (1 usage found)
>                 368 Set<String> expectedIdStrings = Sets.newHashSet(
>             testGetAggregatedLogsMetaForRunningAppAttempt()  (1 usage found)
>                 401 Set<String> expectedIdStrings = Sets.newHashSet(
>     org.apache.hadoop.metrics2.lib  (2 usages found)
>         MutableRates.java  (1 usage found)
>             47 private final Set<Class<?>> protocolCache = Sets.newHashSet();
>         MutableRatesWithAggregation.java  (1 usage found)
>             55 private final Set<Class<?>> protocolCache = Sets.newHashSet();
>     org.apache.hadoop.tools  (2 usages found)
>         CopyListing.java  (2 usages found)
>             validateFinalListing(Path, DistCpContext)  (2 usages found)
>                 166 Set<URI> aclSupportCheckFsSet = Sets.newHashSet();
>                 167 Set<URI> xAttrSupportCheckFsSet = Sets.newHashSet();
>     org.apache.hadoop.tools.dynamometer  (3 usages found)
>         TestDynamometerInfra.java  (3 usages found)
>             setupClass()  (3 usages found)
>                 272 Sets.newHashSet(NAMENODE_NODELABEL, DATANODE_NODELABEL));
>                 275 Sets.newHashSet(NAMENODE_NODELABEL));
>                 277 Sets.newHashSet(DATANODE_NODELABEL));
>     org.apache.hadoop.yarn.api  (1 usage found)
>         BasePBImplRecordsTest.java  (1 usage found)
>             genTypeValue(Type)  (1 usage found)
>                 115 ret = Sets.newHashSet(genTypeValue(params[0]));
>     org.apache.hadoop.yarn.api.protocolrecords.impl.pb  (1 usage found)
>         GetNodesToLabelsResponsePBImpl.java  (1 usage found)
>             initNodeToLabels()  (1 usage found)
>                 70 Sets.newHashSet(c.getNodeLabelsList()));
>     org.apache.hadoop.yarn.api.resource  (3 usages found)
>         TestPlacementConstraintParser.java  (3 usages found)
>             testTargetExpressionParser()  (1 usage found)
>                 116 Set<TargetExpression> expectedTargetExpressions = 
> Sets.newHashSet(
>             testCardinalityConstraintParser()  (1 usage found)
>                 169 Set<TargetExpression> expectedTargetExpressions = 
> Sets.newHashSet(
>             testParseAllocationTagNameSpace()  (1 usage found)
>                 583 Set<TargetExpression> expectedTargetExpressions = 
> Sets.newHashSet(
>     org.apache.hadoop.yarn.client.cli  (10 usages found)
>         TestYarnCLI.java  (10 usages found)
>             testGetApplications()  (10 usages found)
>                 410 Sets.newHashSet("tag1", "tag3"), false, 
> Priority.UNDEFINED, "", "");
>                 421 null, Sets.newHashSet("tag2", "tag3"), false, 
> Priority.UNDEFINED,
>                 431 null, Sets.newHashSet("tag1", "tag4"), false, 
> Priority.UNDEFINED,
>                 441 "NON-MAPREDUCE", null, Sets.newHashSet("tag1"), false,
>                 451 Sets.newHashSet("tag2", "tag4"), false, 
> Priority.UNDEFINED, "", "");
>                 756 Set<String> appTag1 = Sets.newHashSet("tag1");
>                 829 Set<String> appType9 = Sets.newHashSet("YARN");
>                 830 Set<String> appTag2 = Sets.newHashSet("tag3");
>                 858 Set<String> appType10 = Sets.newHashSet("HIVE");
>                 859 Set<String> appTag3 = Sets.newHashSet("tag4");
>     org.apache.hadoop.yarn.logaggregation  (1 usage found)
>         AggregatedLogFormat.java  (1 usage found)
>             getFileCandidates(Set<File>, boolean)  (1 usage found)
>                 366 return Sets.newHashSet(mask);
>     org.apache.hadoop.yarn.logaggregation.filecontroller  (1 usage found)
>         LogAggregationFileController.java  (1 usage found)
>             cleanOldLogs(Path, NodeId, UserGroupInformation)  (1 usage found)
>                 545 status = Sets.newHashSet(mask);
>     org.apache.hadoop.yarn.logaggregation.filecontroller.ifile  (1 usage 
> found)
>         LogAggregationIndexedFileController.java  (1 usage found)
>             parseCheckSumFiles(List<FileStatus>)  (1 usage found)
>                 718 status = Sets.newHashSet(mask);
>     org.apache.hadoop.yarn.nodelabels  (7 usages found)
>         NodeLabelTestBase.java  (1 usage found)
>             toSet(E...)  (1 usage found)
>                 123 Set<E> set = Sets.newHashSet(elements);
>         TestCommonNodeLabelsManager.java  (6 usages found)
>             testAddRemovelabel()  (5 usages found)
>                 65 verifyNodeLabelAdded(Sets.newHashSet("hello"), 
> mgr.lastAddedlabels);
>                 69 verifyNodeLabelAdded(Sets.newHashSet("hello1", "world1"), 
> mgr.lastAddedlabels);
>                 72 Sets.newHashSet("hello", "world", "hello1", "world1")));
>                 103 assertCollectionEquals(Sets.newHashSet("hello"), 
> mgr.lastRemovedlabels);
>                 109 
> Assert.assertTrue(mgr.lastRemovedlabels.containsAll(Sets.newHashSet(
>             testAddlabelWithCase()  (1 usage found)
>                 118 verifyNodeLabelAdded(Sets.newHashSet("HeLlO"), 
> mgr.lastAddedlabels);
>     org.apache.hadoop.yarn.nodelabels.store.op  (1 usage found)
>         RemoveClusterLabelOp.java  (1 usage found)
>             write(OutputStream, CommonNodeLabelsManager)  (1 usage found)
>                 48 
> .newInstance(Sets.newHashSet(labels.iterator()))).getProto()
>     org.apache.hadoop.yarn.server.api.protocolrecords  (1 usage found)
>         TestProtocolRecords.java  (1 usage found)
>             testNodeHeartBeatRequest()  (1 usage found)
>                 185 Sets.newHashSet(NodeAttribute.newInstance("attributeA",
>     org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb  (1 usage found)
>         ReplaceLabelsOnNodeRequestPBImpl.java  (1 usage found)
>             initNodeToLabels()  (1 usage found)
>                 66 Sets.newHashSet(c.getNodeLabelsList()));
>     org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer  (2 
> usages found)
>         TestResourceLocalizationService.java  (2 usages found)
>             doLocalization(ResourceLocalizationService, DrainDispatcher, 
> DummyExecutor, DeletionService)  (1 usage found)
>                 1400 Sets.newHashSet(new Path(locPath1), new Path(locPath1 + 
> "_tmp"),
>             doLocalizationAfterCleanup(ResourceLocalizationService, 
> DrainDispatcher, DummyExecutor, DeletionService)  (1 usage found)
>                 1547 Sets.newHashSet(new Path(locPath1), new Path(locPath1 + 
> "_tmp"),
>     org.apache.hadoop.yarn.server.nodemanager.containermanager.logaggregation 
>  (1 usage found)
>         AppLogAggregatorImpl.java  (1 usage found)
>             doContainerLogAggregation(LogAggregationFileController, boolean, 
> boolean)  (1 usage found)
>                 674 this.uploadedFileMeta = Sets.newHashSet(mask);
>     
> org.apache.hadoop.yarn.server.nodemanager.containermanager.resourceplugin.com.nec
>   (1 usage found)
>         TestNECVEPlugin.java  (1 usage found)
>             testFindDevicesWithUdev()  (1 usage found)
>                 388 .thenReturn(Sets.newHashSet(testDevice));
>     
> org.apache.hadoop.yarn.server.nodemanager.containermanager.resourceplugin.fpga
>   (1 usage found)
>         FpgaDiscoverer.java  (1 usage found)
>             discover()  (1 usage found)
>                 123 Set<String> minors = Sets.newHashSet(allowed.split(","));
>     
> org.apache.hadoop.yarn.server.nodemanager.containermanager.resourceplugin.gpu 
>  (1 usage found)
>         GpuDiscoverer.java  (1 usage found)
>             lookupBinaryInDefaultDirsInternal()  (1 usage found)
>                 328 Set<String> triedBinaryPaths = Sets.newHashSet();
>     org.apache.hadoop.yarn.server.resourcemanager  (5 usages found)
>         TestAppManager.java  (1 usage found)
>             testEscapeApplicationSummary()  (1 usage found)
>                 977 
> when(app.getApplicationTags()).thenReturn(Sets.newHashSet("tag2", "tag1"));
>         TestClientRMService.java  (3 usages found)
>             testGetApplications()  (3 usages found)
>                 1442 tagSet = Sets.newHashSet(tags.get(0));
>                 1447 tagSet = Sets.newHashSet(tags.get(1));
>                 1452 tagSet = Sets.newHashSet(tags.get(2));
>         TestRMRestart.java  (1 usage found)
>             toSet(E...)  (1 usage found)
>                 2587 Set<E> set = Sets.newHashSet(elements);
>     org.apache.hadoop.yarn.server.resourcemanager.nodelabels  (11 usages 
> found)
>         TestNodeAttributesManager.java  (11 usages found)
>             testAddNodeAttributes()  (2 usages found)
>                 132 .getClusterNodeAttributes(Sets.newHashSet(PREFIXES[0]));
>                 138 
> .getClusterNodeAttributes(Sets.newHashSet("non_exist_prefix"));
>             testRemoveNodeAttributes()  (4 usages found)
>                 219 .getClusterNodeAttributes(Sets.newHashSet(PREFIXES[0]));
>                 222 .getClusterNodeAttributes(Sets.newHashSet(PREFIXES[1]));
>                 225 .getClusterNodeAttributes(Sets.newHashSet(PREFIXES[2]));
>                 263 .getClusterNodeAttributes(Sets.newHashSet(PREFIXES[0]));
>             testReplaceNodeAttributes()  (5 usages found)
>                 299 Sets.newHashSet(NodeAttribute.PREFIX_DISTRIBUTED, 
> PREFIXES[0]));
>                 313 Sets.newHashSet(NodeAttribute.PREFIX_DISTRIBUTED, 
> PREFIXES[0]));
>                 340 Sets.newHashSet(NodeAttribute.PREFIX_DISTRIBUTED));
>                 357 .getClusterNodeAttributes(Sets.newHashSet(PREFIXES[1]));
>                 360 .getClusterNodeAttributes(Sets.newHashSet(
>     org.apache.hadoop.yarn.server.resourcemanager.scheduler  (5 usages found)
>         TestAbstractYarnScheduler.java  (3 usages found)
>             testContainerReleaseWithAllocationTags()  (2 usages found)
>                 469 Sets.newHashSet(testTag1),
>                 477 Sets.newHashSet(testTag2),
>             testNodeRemovedWithAllocationTags()  (1 usage found)
>                 578 Sets.newHashSet(testTag1),
>         TestSchedulerUtils.java  (2 usages found)
>             testValidateResourceRequestWithErrorLabelsPermission()  (1 usage 
> found)
>                 246 Set<String> queueAccessibleNodeLabels = Sets.newHashSet();
>             testNormalizeNodeLabelExpression()  (1 usage found)
>                 795 Set<String> queueAccessibleNodeLabels = Sets.newHashSet();
>     org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity  (8 
> usages found)
>         CapacitySchedulerTestBase.java  (1 usage found)
>             toSet(E...)  (1 usage found)
>                 56 Set<E> set = Sets.newHashSet(elements);
>         TestApplicationLimits.java  (1 usage found)
>             toSet(String...)  (1 usage found)
>                 790 Set<String> set = Sets.newHashSet(elements);
>         TestCapacityScheduler.java  (1 usage found)
>             testParseQueueWithAbsoluteResource()  (1 usage found)
>                 1042 Sets.newHashSet(labelName));
>         TestCapacitySchedulerMaxParallelApps.java  (1 usage found)
>             executeCommonStepsAndChecks()  (1 usage found)
>                 200 Sets.newHashSet(
>         TestCapacitySchedulerNodeLabelUpdate.java  (1 usage found)
>             toSet(String...)  (1 usage found)
>                 144 Set<String> set = Sets.newHashSet(elements);
>         TestNodeLabelContainerAllocation.java  (1 usage found)
>             toSet(E...)  (1 usage found)
>                 157 Set<E> set = Sets.newHashSet(elements);
>         TestUtils.java  (1 usage found)
>             toSet(E...)  (1 usage found)
>                 262 Set<E> set = Sets.newHashSet(elements);
>         TestWorkPreservingRMRestartForNodeLabel.java  (1 usage found)
>             toSet(E...)  (1 usage found)
>                 77 Set<E> set = Sets.newHashSet(elements);
>     org.apache.hadoop.yarn.server.resourcemanager.scheduler.constraint  (3 
> usages found)
>         TestPlacementConstraintManagerService.java  (3 usages found)
>             testGetRequestConstraint()  (3 usages found)
>                 209 Sets.newHashSet("not_exist_tag"), null);
>                 228 Sets.newHashSet(sourceTag1), null);
>                 256 Sets.newHashSet(sourceTag1), c1);
>     org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair  (2 usages 
> found)
>         TestFairScheduler.java  (1 usage found)
>             testGetAppsInQueue()  (1 usage found)
>                 4455 Set<ApplicationAttemptId> appAttIds = 
> Sets.newHashSet(apps.get(0), apps.get(1));
>         TestQueueManager.java  (1 usage found)
>             updateConfiguredLeafQueues(QueueManager, String...)  (1 usage 
> found)
>                 185 .addAll(Sets.newHashSet(confLeafQueues));
>     org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.allocation  
> (1 usage found)
>         AllocationFileParser.java  (1 usage found)
>             81 Sets.newHashSet(QUEUE_MAX_RESOURCES_DEFAULT, 
> USER_MAX_APPS_DEFAULT,
>     org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.converter  
> (8 usages found)
>         TestFSQueueConverter.java  (8 usages found)
>             testConvertQueueHierarchy()  (1 usage found)
>                 168 Sets.newHashSet("root",
>             testQueueMaxAMShare()  (1 usage found)
>                 192 Sets.newHashSet("root.admins.bob", "root.admins.alice"));
>             testQueueMaxParallelApps()  (1 usage found)
>                 208 Sets.newHashSet("root.admins.alice"));
>             testQueueMaxAllocations()  (1 usage found)
>                 232 Sets.newHashSet("root.admins", "root.users.john"));
>             testQueuePreemptionDisabled()  (1 usage found)
>                 251 Sets.newHashSet("root.admins.alice", "root.users.joe"));
>             testQueueAutoCreateChildQueue()  (2 usages found)
>                 319 Set<String> parentQueues = Sets.newHashSet(
>                 323 Set<String> leafQueues = Sets.newHashSet(
>             64 Sets.newHashSet("root",
>     org.apache.hadoop.yarn.server.resourcemanager.webapp  (25 usages found)
>         ApplicationsRequestBuilder.java  (5 usages found)
>             34 private Set<String> statesQuery = Sets.newHashSet();
>             35 private Set<String> users = Sets.newHashSetWithExpectedSize(1);
>             36 private Set<String> queues = 
> Sets.newHashSetWithExpectedSize(1);
>             45 private Set<String> appTypes = Sets.newHashSet();
>             46 private Set<String> appTags = Sets.newHashSet();
>         RMWebAppFilter.java  (1 usage found)
>             71 private static final Set<String> NON_REDIRECTED_URIS = 
> Sets.newHashSet(
>         TestApplicationsRequestBuilder.java  (16 usages found)
>             testRequestWithValidStateQuery()  (1 usage found)
>                 86 
> Sets.newHashSet(YarnApplicationState.NEW_SAVING.toString());
>             testRequestWithEmptyStateQueries()  (1 usage found)
>                 96 .withStatesQuery(Sets.newHashSet()).build();
>             testRequestWithInvalidStateQueries()  (1 usage found)
>                 106 .withStatesQuery(Sets.newHashSet("a1", "a2", "")).build();
>             testRequestWithValidStateQueries()  (2 usages found)
>                 127 
> Sets.newHashSet(YarnApplicationState.NEW_SAVING.toString(),
>                 133 
> Sets.newHashSet(YarnApplicationState.NEW_SAVING.toString(),
>             testRequestWithUserQuery()  (1 usage found)
>                 165 expectedRequest.setUsers(Sets.newHashSet("user1"));
>             testRequestWithQueueQueryExistingQueue()  (1 usage found)
>                 196 expectedRequest.setQueues(Sets.newHashSet("queue1"));
>             testRequestWithQueueQueryNotExistingQueue()  (1 usage found)
>                 212 expectedRequest.setQueues(Sets.newHashSet("queue1"));
>             testRequestWithEmptyApplicationTypesQuery()  (2 usages found)
>                 487 .withApplicationTypes(Sets.newHashSet()).build();
>                 490 expectedRequest.setApplicationTypes(Sets.newHashSet());
>             testRequestWithValidApplicationTypesQuery()  (2 usages found)
>                 497 .withApplicationTypes(Sets.newHashSet("type1")).build();
>                 500 
> expectedRequest.setApplicationTypes(Sets.newHashSet("type1"));
>             testRequestWithEmptyApplicationTagsQuery()  (2 usages found)
>                 513 .withApplicationTags(Sets.newHashSet()).build();
>                 516 expectedRequest.setApplicationTags(Sets.newHashSet());
>             testRequestWithValidApplicationTagsQuery()  (2 usages found)
>                 523 .withApplicationTags(Sets.newHashSet("tag1")).build();
>                 526 
> expectedRequest.setApplicationTags(Sets.newHashSet("tag1"));
>         TestRMWebServiceAppsNodelabel.java  (1 usage found)
>             toSet(E...)  (1 usage found)
>                 242 Set<E> set = Sets.newHashSet(elements);
>         TestRMWebServicesApps.java  (1 usage found)
>             getApplicationIds(JSONArray)  (1 usage found)
>                 107 Set<String> ids = Sets.newHashSet();
>         TestRMWebServicesForCSWithPartitions.java  (1 usage found)
>             testPartitionInSchedulerActivities()  (1 usage found)
>                 273 .of(NodeId.newInstance("127.0.0.1", 0), 
> Sets.newHashSet(LABEL_LX)));
>     org.apache.hadoop.yarn.server.resourcemanager.webapp.fairscheduler  (4 
> usages found)
>         FairSchedulerJsonVerifications.java  (2 usages found)
>             FairSchedulerJsonVerifications(List<String>)  (1 usage found)
>                 49 this.customResourceTypes = 
> Sets.newHashSet(customResourceTypes);
>             42 Sets.newHashSet("minResources", "amUsedResources", 
> "amMaxResources",
>         FairSchedulerXmlVerifications.java  (2 usages found)
>             FairSchedulerXmlVerifications(List<String>)  (1 usage found)
>                 53 this.customResourceTypes = 
> Sets.newHashSet(customResourceTypes);
>             46 private static final Set<String> RESOURCE_FIELDS = 
> Sets.newHashSet(
>     org.apache.hadoop.yarn.server.resourcemanager.webapp.helper  (1 usage 
> found)
>         ResourceRequestsXmlVerifications.java  (1 usage found)
>             extractActualCustomResourceType(Element, List<String>)  (1 usage 
> found)
>                 85 Sets.newHashSet(expectedResourceTypes));
>     org.apache.hadoop.yarn.server.timeline  (3 usages found)
>         EntityGroupPlugInForTest.java  (3 usages found)
>             getTimelineEntityGroupId(String, NameValuePair, 
> Collection<NameValuePair>)  (1 usage found)
>                 39 return Sets.newHashSet(getStandardTimelineGroupId(appId));
>             getTimelineEntityGroupId(String, String)  (1 usage found)
>                 47 return Sets.newHashSet(getStandardTimelineGroupId(appId));
>             getTimelineEntityGroupId(String, SortedSet<String>, Set<String>)  
> (1 usage found)
>                 54 return Sets.newHashSet();
>     org.apache.hadoop.yarn.server.timelineservice.collector  (1 usage found)
>         TestTimelineCollector.java  (1 usage found)
>             testClearPreviousEntitiesOnAggregation()  (1 usage found)
>                 306 assertEquals(Sets.newHashSet("type"), 
> aggregationGroups.keySet());
>     
> org.apache.hadoop.yarn.server.timelineservice.documentstore.reader.cosmosdb  
> (1 usage found)
>         CosmosDBDocumentStoreReader.java  (1 usage found)
>             fetchEntityTypes(String, TimelineReaderContext)  (1 usage found)
>                 118 return Sets.newHashSet(client.queryDocuments(
>     org.apache.hadoop.yarn.server.timelineservice.reader  (38 usages found)
>         TestTimelineReaderWebServicesHBaseStorage.java  (16 usages found)
>             loadData()  (16 usages found)
>                 266 Sets.newHashSet("entity21", "entity22", "entity23", 
> "entity24"));
>                 267 isRelatedTo1.put("type4", Sets.newHashSet("entity41", 
> "entity42"));
>                 268 isRelatedTo1.put("type1", Sets.newHashSet("entity14", 
> "entity15"));
>                 270 Sets.newHashSet("entity31", "entity35", "entity32", 
> "entity33"));
>                 274 Sets.newHashSet("entity21", "entity22", "entity23", 
> "entity24"));
>                 275 relatesTo1.put("type4", Sets.newHashSet("entity41", 
> "entity42"));
>                 276 relatesTo1.put("type1", Sets.newHashSet("entity14", 
> "entity15"));
>                 278 Sets.newHashSet("entity31", "entity35", "entity32", 
> "entity33"));
>                 327 Sets.newHashSet("entity21", "entity22", "entity23", 
> "entity24"));
>                 328 isRelatedTo2.put("type5", Sets.newHashSet("entity51", 
> "entity52"));
>                 329 isRelatedTo2.put("type6", Sets.newHashSet("entity61", 
> "entity66"));
>                 330 isRelatedTo2.put("type3", Sets.newHashSet("entity31"));
>                 334 Sets.newHashSet("entity21", "entity22", "entity23", 
> "entity24"));
>                 335 relatesTo2.put("type5", Sets.newHashSet("entity51", 
> "entity52"));
>                 336 relatesTo2.put("type6", Sets.newHashSet("entity61", 
> "entity66"));
>                 337 relatesTo2.put("type3", Sets.newHashSet("entity31"));
>         TestTimelineReaderWebServicesUtils.java  (22 usages found)
>             testRelationFiltersParsing()  (22 usages found)
>                 721 "type1", Sets.newHashSet((Object)"entity11")),
>                 723 "type2", Sets.newHashSet((Object)"entity21", "entity22"))
>                 737 "type1", Sets.newHashSet((Object)"entity11")),
>                 739 "type2", Sets.newHashSet((Object)"entity21", "entity22"))
>                 743 "type3", Sets.newHashSet(
>                 746 "type1", Sets.newHashSet((Object)"entity11", "entity12"))
>                 758 "type1", Sets.newHashSet((Object)"entity11")),
>                 760 "type2", Sets.newHashSet((Object)"entity21", "entity22")),
>                 762 "type5", Sets.newHashSet((Object)"entity51"))
>                 766 "type3", Sets.newHashSet(
>                 769 "type1", Sets.newHashSet((Object)"entity11", "entity12"))
>                 784 "type1", Sets.newHashSet((Object)"entity11")),
>                 786 "type2", Sets.newHashSet(
>                 789 "type5", Sets.newHashSet((Object)"entity51"))
>                 793 "type3", Sets.newHashSet(
>                 796 "type1", Sets.newHashSet(
>                 803 "type11", Sets.newHashSet((Object)"entity111"))
>                 807 "type4", Sets.newHashSet((Object)"entity43", "entity44",
>                 810 "type7", Sets.newHashSet((Object)"entity71"))
>                 817 "type2", Sets.newHashSet((Object)"entity2")),
>                 819 "type8", Sets.newHashSet((Object)"entity88"))
>                 822 Sets.newHashSet((Object)"e", "e1"))
>     org.apache.hadoop.yarn.service  (1 usage found)
>         TestApiServer.java  (1 usage found)
>             testUpgradeSingleInstance()  (1 usage found)
>                 533 mockServerClient.setExpectedInstances(Sets.newHashSet(
>     org.apache.hadoop.yarn.service.utils  (2 usages found)
>         ServiceApiUtil.java  (2 usages found)
>             validateAndResolveCompsUpgrade(Service, Collection<String>)  (1 
> usage found)
>                 625 HashSet<String> requestedComps = 
> Sets.newHashSet(compNames);
>             validateAndResolveCompsStable(Service, Collection<String>)  (1 
> usage found)
>                 651 HashSet<String> requestedComps = 
> Sets.newHashSet(compNames);
>     org.apache.hadoop.yarn.service.webapp  (1 usage found)
>         ApiServer.java  (1 usage found)
>             updateComponent(HttpServletRequest, String, String, Component)  
> (1 usage found)
>                 374 Sets.newHashSet(componentName));
>     org.apache.hadoop.yarn.webapp.hamlet  (2 usages found)
>         HamletGen.java  (2 usages found)
>             67 final Set<String> endTagOptional = Sets.newHashSet();
>             68 final Set<String> inlineElements = Sets.newHashSet();
>     org.apache.hadoop.yarn.webapp.hamlet2  (2 usages found)
>         HamletGen.java  (2 usages found)
>             65 final Set<String> endTagOptional = Sets.newHashSet();
>             66 final Set<String> inlineElements = Sets.newHashSet();
>     patches  (4 usages found)
>         HADOOP-17101.001.patch  (2 usages found)
>             226      Set<Path> expectedPathSet = 
> Sets.newHashSet(fqExpectedPaths);
>             244      Set<String> expectedSet = Sets.newHashSet(expected);
>         HADOOP-17101.002.patch  (2 usages found)
>             456      Set<Path> expectedPathSet = 
> Sets.newHashSet(fqExpectedPaths);
>             474      Set<String> expectedSet = Sets.newHashSet(expected);
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org

Reply via email to