Parcourir la source

ZOOKEEPER-2630: Use interface type instead of implementation type whe…

Use interface type instead of implementation type when appropriate.

There are a couple of places in code base where we declare a field / variable as implementation type (i.e. HashMap, HashSet) instead of interface type (i.e. Map, Set), while in other places we do the opposite by declaring as interface type. A quick check indicates that most if not all of these places could be updated so we have a consistent style over the code base (prefer using interface type), which is also a good coding style to stick per best practice.

Checked and fixed Set, Map and List interface usages.

Author: Tamas Penzes <tamaas@cloudera.com>

Reviewers: Abe Fine <afine@apache.org>, Michael Han <hanm@apache.org>

Closes #354 from tamaashu/ZOOKEEPER-2630
Tamas Penzes il y a 7 ans
Parent
commit
1165794be9
54 fichiers modifiés avec 159 ajouts et 121 suppressions
  1. 1 1
      docs/zookeeperReconfig.html
  2. 4 2
      src/contrib/fatjar/src/java/org/apache/zookeeper/util/FatJarMain.java
  3. 3 2
      src/contrib/loggraph/src/java/org/apache/zookeeper/graph/FilterOp.java
  4. 2 1
      src/contrib/loggraph/src/java/org/apache/zookeeper/graph/JsonGenerator.java
  5. 2 1
      src/contrib/loggraph/src/java/org/apache/zookeeper/graph/LogEntry.java
  6. 2 1
      src/contrib/loggraph/src/java/org/apache/zookeeper/graph/MeasureThroughput.java
  7. 2 1
      src/contrib/loggraph/src/java/org/apache/zookeeper/graph/servlets/Throughput.java
  8. 1 1
      src/contrib/zooinspector/src/java/org/apache/zookeeper/inspector/gui/ZooInspectorConnectionPropertiesDialog.java
  9. 1 1
      src/contrib/zooinspector/src/java/org/apache/zookeeper/inspector/gui/ZooInspectorPanel.java
  10. 1 1
      src/docs/src/documentation/content/xdocs/zookeeperReconfig.xml
  11. 4 4
      src/java/main/org/apache/jute/compiler/CGenerator.java
  12. 3 3
      src/java/main/org/apache/jute/compiler/CSharpGenerator.java
  13. 4 4
      src/java/main/org/apache/jute/compiler/CppGenerator.java
  14. 3 2
      src/java/main/org/apache/jute/compiler/JFile.java
  15. 5 3
      src/java/main/org/apache/jute/compiler/JRecord.java
  16. 4 4
      src/java/main/org/apache/jute/compiler/JavaGenerator.java
  17. 2 2
      src/java/main/org/apache/zookeeper/Environment.java
  18. 2 1
      src/java/main/org/apache/zookeeper/common/PathTrie.java
  19. 5 5
      src/java/main/org/apache/zookeeper/server/DataTree.java
  20. 2 2
      src/java/main/org/apache/zookeeper/server/NettyServerCnxnFactory.java
  21. 3 3
      src/java/main/org/apache/zookeeper/server/PrepRequestProcessor.java
  22. 20 20
      src/java/main/org/apache/zookeeper/server/WatchManager.java
  23. 2 2
      src/java/main/org/apache/zookeeper/server/ZooKeeperServer.java
  24. 2 1
      src/java/main/org/apache/zookeeper/server/auth/ProviderRegistry.java
  25. 2 1
      src/java/main/org/apache/zookeeper/server/quorum/AuthFastLeaderElection.java
  26. 2 1
      src/java/main/org/apache/zookeeper/server/quorum/CommitProcessor.java
  27. 4 4
      src/java/main/org/apache/zookeeper/server/quorum/FastLeaderElection.java
  28. 2 1
      src/java/main/org/apache/zookeeper/server/quorum/Leader.java
  29. 2 2
      src/java/main/org/apache/zookeeper/server/quorum/flexible/QuorumMaj.java
  30. 2 1
      src/java/systest/org/apache/zookeeper/test/system/BaseSysTest.java
  31. 2 2
      src/java/systest/org/apache/zookeeper/test/system/InstanceContainer.java
  32. 4 3
      src/java/systest/org/apache/zookeeper/test/system/InstanceManager.java
  33. 2 1
      src/java/systest/org/apache/zookeeper/test/system/QuorumPeerInstance.java
  34. 9 7
      src/java/test/org/apache/zookeeper/server/quorum/CommitProcessorConcurrencyTest.java
  35. 2 1
      src/java/test/org/apache/zookeeper/server/quorum/FLEBackwardElectionRoundTest.java
  36. 2 1
      src/java/test/org/apache/zookeeper/server/quorum/LearnerHandlerTest.java
  37. 2 1
      src/java/test/org/apache/zookeeper/server/quorum/QuorumRequestPipelineTest.java
  38. 2 1
      src/java/test/org/apache/zookeeper/server/quorum/ReconfigFailureCasesTest.java
  39. 4 3
      src/java/test/org/apache/zookeeper/server/quorum/ReconfigRecoveryTest.java
  40. 1 1
      src/java/test/org/apache/zookeeper/test/ACLTest.java
  41. 3 1
      src/java/test/org/apache/zookeeper/test/AsyncTest.java
  42. 1 1
      src/java/test/org/apache/zookeeper/test/ClientBase.java
  43. 2 1
      src/java/test/org/apache/zookeeper/test/CnxManagerTest.java
  44. 4 2
      src/java/test/org/apache/zookeeper/test/FLERestartTest.java
  45. 4 3
      src/java/test/org/apache/zookeeper/test/FLETest.java
  46. 2 1
      src/java/test/org/apache/zookeeper/test/FLEZeroWeightTest.java
  47. 2 1
      src/java/test/org/apache/zookeeper/test/IntegrityCheck.java
  48. 2 1
      src/java/test/org/apache/zookeeper/test/LocalSessionsOnlyTest.java
  49. 2 1
      src/java/test/org/apache/zookeeper/test/OOMTest.java
  50. 3 2
      src/java/test/org/apache/zookeeper/test/QuorumBase.java
  51. 1 1
      src/java/test/org/apache/zookeeper/test/ReconfigTest.java
  52. 1 1
      src/java/test/org/apache/zookeeper/test/SessionTest.java
  53. 2 1
      src/java/test/org/apache/zookeeper/test/TruncateTest.java
  54. 6 5
      src/recipes/queue/src/java/org/apache/zookeeper/recipes/queue/DistributedQueue.java

+ 1 - 1
docs/zookeeperReconfig.html

@@ -1011,7 +1011,7 @@ System.out.println(configStr);</pre>
           example, you may specify a Hierarchical Quorum System even if the
           current ensemble uses a Majority Quorum System.</p>
 <p>Bulk mode - example using the Java API:</p>
-<pre class="code">ArrayList&lt;String&gt; newMembers = new ArrayList&lt;String&gt;();
+<pre class="code">List&lt;String&gt; newMembers = new ArrayList&lt;String&gt;();
 newMembers.add("server.1=1111:1234:1235;1236");
 newMembers.add("server.2=1112:1237:1238;1239");
 newMembers.add("server.3=1114:1240:1241:observer;1242");

+ 4 - 2
src/contrib/fatjar/src/java/org/apache/zookeeper/util/FatJarMain.java

@@ -26,6 +26,8 @@ import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * This is a generic Main class that is completely driven by the
@@ -48,8 +50,8 @@ public class FatJarMain {
         String clazz;
         String desc;
     }
-    static HashMap<String, Cmd> cmds = new HashMap<String, Cmd>();
-    static ArrayList<String> order = new ArrayList<String>();
+    static Map<String, Cmd> cmds = new HashMap<String, Cmd>();
+    static List<String> order = new ArrayList<String>();
     
     /**
      * @param args the first parameter of args will be used as an

+ 3 - 2
src/contrib/loggraph/src/java/org/apache/zookeeper/graph/FilterOp.java

@@ -18,11 +18,12 @@
 package org.apache.zookeeper.graph;
 
 import java.util.ArrayList;
+import java.util.List;
 import org.apache.zookeeper.graph.filterops.*;
 
 public abstract class FilterOp {
-    protected ArrayList<FilterOp> subOps;
-    protected ArrayList<Arg> args;
+    protected List<FilterOp> subOps;
+    protected List<Arg> args;
 
     public enum ArgType {
 	STRING, NUMBER, SYMBOL

+ 2 - 1
src/contrib/loggraph/src/java/org/apache/zookeeper/graph/JsonGenerator.java

@@ -31,10 +31,11 @@ import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.ListIterator;
+import java.util.Set;
 
 public class JsonGenerator {
     private JSONObject root;
-    private HashSet<Integer> servers;
+    private Set<Integer> servers;
 
     private class Message {
 	private int from;

+ 2 - 1
src/contrib/loggraph/src/java/org/apache/zookeeper/graph/LogEntry.java

@@ -19,9 +19,10 @@ package org.apache.zookeeper.graph;
 
 import java.io.Serializable;
 import java.util.HashMap;
+import java.util.Map;
 
 public abstract class LogEntry implements Serializable {
-    private HashMap attributes;
+    private Map attributes;
 
     public enum Type { UNKNOWN, LOG4J, TXN };
         

+ 2 - 1
src/contrib/loggraph/src/java/org/apache/zookeeper/graph/MeasureThroughput.java

@@ -24,6 +24,7 @@ import java.io.DataOutputStream;
 import java.io.PrintStream;
 
 import java.util.HashSet;
+import java.util.Set;
 
 public class MeasureThroughput {
     private static final int MS_PER_SEC = 1000;
@@ -45,7 +46,7 @@ public class MeasureThroughput {
 	long currentsec = 0;
 	long currentmin = 0;
 	long currenthour = 0;
-	HashSet<Long> zxids_ms = new HashSet<Long>();
+	Set<Long> zxids_ms = new HashSet<Long>();
 	long zxid_sec = 0;
 	long zxid_min = 0;
 	long zxid_hour = 0;

+ 2 - 1
src/contrib/loggraph/src/java/org/apache/zookeeper/graph/servlets/Throughput.java

@@ -25,6 +25,7 @@ import java.io.PrintStream;
 
 import java.util.HashSet;
 import java.util.LinkedHashMap;
+import java.util.Set;
 
 import org.apache.zookeeper.graph.*;
 import org.slf4j.Logger;
@@ -80,7 +81,7 @@ public class Throughput extends JsonServlet
 	
 	long current = 0;
 	long currentms = 0;
-	HashSet<Long> zxids_ms = new HashSet<Long>();
+	Set<Long> zxids_ms = new HashSet<Long>();
 	long zxidcount = 0;
 
 	JSONArray events = new JSONArray();

+ 1 - 1
src/contrib/zooinspector/src/java/org/apache/zookeeper/inspector/gui/ZooInspectorConnectionPropertiesDialog.java

@@ -51,7 +51,7 @@ import org.apache.zookeeper.inspector.manager.Pair;
  */
 public class ZooInspectorConnectionPropertiesDialog extends JDialog {
 
-    private final HashMap<String, JComponent> components;
+    private final Map<String, JComponent> components;
 
     /**
      * @param lastConnectionProps

+ 1 - 1
src/contrib/zooinspector/src/java/org/apache/zookeeper/inspector/gui/ZooInspectorPanel.java

@@ -64,7 +64,7 @@ public class ZooInspectorPanel extends JPanel implements
         this.zooInspectorManager = zooInspectorManager;
         this.iconResource = iconResource;
         toolbar = new Toolbar(iconResource);
-        final ArrayList<ZooInspectorNodeViewer> nodeViewers = new ArrayList<ZooInspectorNodeViewer>();
+        final List<ZooInspectorNodeViewer> nodeViewers = new ArrayList<ZooInspectorNodeViewer>();
         try {
             List<String> defaultNodeViewersClassNames = this.zooInspectorManager
                     .getDefaultNodeViewerConfiguration();

+ 1 - 1
src/docs/src/documentation/content/xdocs/zookeeperReconfig.xml

@@ -693,7 +693,7 @@ System.out.println(configStr);]]></programlisting>
           example, you may specify a Hierarchical Quorum System even if the
           current ensemble uses a Majority Quorum System.</para>
         <para>Bulk mode - example using the Java API:</para>
-        <programlisting><![CDATA[ArrayList<String> newMembers = new ArrayList<String>();
+        <programlisting><![CDATA[List<String> newMembers = new ArrayList<String>();
 newMembers.add("server.1=1111:1234:1235;1236");
 newMembers.add("server.2=1112:1237:1238;1239");
 newMembers.add("server.3=1114:1240:1241:observer;1242");

+ 4 - 4
src/java/main/org/apache/jute/compiler/CGenerator.java

@@ -18,19 +18,19 @@
 
 package org.apache.jute.compiler;
 
-import java.util.ArrayList;
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.util.Iterator;
+import java.util.List;
 
 /**
  * C++ Code generator front-end for Hadoop record I/O.
  */
 class CGenerator {
     private String mName;
-    private ArrayList<JFile> mInclFiles;
-    private ArrayList<JRecord> mRecList;
+    private List<JFile> mInclFiles;
+    private List<JRecord> mRecList;
     private final File outputDirectory;
 
     /** Creates a new instance of CppGenerator
@@ -40,7 +40,7 @@ class CGenerator {
      * @param rlist List of records defined within this file
      * @param outputDirectory
      */
-    CGenerator(String name, ArrayList<JFile> ilist, ArrayList<JRecord> rlist,
+    CGenerator(String name, List<JFile> ilist, List<JRecord> rlist,
             File outputDirectory)
     {
         this.outputDirectory = outputDirectory;

+ 3 - 3
src/java/main/org/apache/jute/compiler/CSharpGenerator.java

@@ -20,10 +20,10 @@ package org.apache.jute.compiler;
 
 import java.io.File;
 import java.io.IOException;
-import java.util.ArrayList;
+import java.util.List;
 
 public class CSharpGenerator {
-    private ArrayList<JRecord> mRecList;
+    private List<JRecord> mRecList;
     private final File outputDirectory;
 
     /** Creates a new instance of CSharpGenerator
@@ -33,7 +33,7 @@ public class CSharpGenerator {
      * @param rlist List of records defined within this file
      * @param outputDirectory
      */
-    CSharpGenerator(String name, ArrayList<JFile> ilist, ArrayList<JRecord> rlist,
+    CSharpGenerator(String name, List<JFile> ilist, List<JRecord> rlist,
             File outputDirectory)
      {
         this.outputDirectory = outputDirectory;

+ 4 - 4
src/java/main/org/apache/jute/compiler/CppGenerator.java

@@ -18,19 +18,19 @@
 
 package org.apache.jute.compiler;
 
-import java.util.ArrayList;
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.util.Iterator;
+import java.util.List;
 
 /**
  * C++ Code generator front-end for Hadoop record I/O.
  */
 class CppGenerator {
     private String mName;
-    private ArrayList<JFile> mInclFiles;
-    private ArrayList<JRecord> mRecList;
+    private List<JFile> mInclFiles;
+    private List<JRecord> mRecList;
     private final File outputDirectory;
 
     /** Creates a new instance of CppGenerator
@@ -40,7 +40,7 @@ class CppGenerator {
      * @param rlist List of records defined within this file
      * @param outputDirectory
      */
-    CppGenerator(String name, ArrayList<JFile> ilist, ArrayList<JRecord> rlist,
+    CppGenerator(String name, List<JFile> ilist, List<JRecord> rlist,
             File outputDirectory)
      {
         this.outputDirectory = outputDirectory;

+ 3 - 2
src/java/main/org/apache/jute/compiler/JFile.java

@@ -21,6 +21,7 @@ package org.apache.jute.compiler;
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.List;
 
 /**
  * Container for the Hadoop Record DDL.
@@ -31,8 +32,8 @@ import java.util.ArrayList;
 public class JFile {
     
     private String mName;
-    private ArrayList<JFile> mInclFiles;
-    private ArrayList<JRecord> mRecords;
+    private List<JFile> mInclFiles;
+    private List<JRecord> mRecords;
     
     /** Creates a new instance of JFile
      *

+ 5 - 3
src/java/main/org/apache/jute/compiler/JRecord.java

@@ -24,6 +24,8 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
 
 /**
  *
@@ -33,7 +35,7 @@ public class JRecord extends JCompType {
     private String mFQName;
     private String mName;
     private String mModule;
-    private ArrayList<JField> mFields;
+    private List<JField> mFields;
 
     /**
      * Creates a new instance of JRecord
@@ -83,7 +85,7 @@ public class JRecord extends JCompType {
         return namespace.toString();
     }
 
-    public ArrayList<JField> getFields() {
+    public List<JField> getFields() {
         return mFields;
     }
 
@@ -139,7 +141,7 @@ public class JRecord extends JCompType {
         return "    a_.WriteRecord("+fname+",\""+tag+"\");\n";
     }
 
-    static HashMap<String, String> vectorStructs = new HashMap<String, String>();
+    static Map<String, String> vectorStructs = new HashMap<String, String>();
     public void genCCode(FileWriter h, FileWriter c) throws IOException {
         for (JField f : mFields) {
             if (f.getType() instanceof JVector) {

+ 4 - 4
src/java/main/org/apache/jute/compiler/JavaGenerator.java

@@ -20,14 +20,14 @@ package org.apache.jute.compiler;
 
 import java.io.File;
 import java.io.IOException;
-import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.List;
 
 /**
  * Java Code generator front-end for Hadoop record I/O.
  */
 class JavaGenerator {
-    private ArrayList<JRecord> mRecList;
+    private List<JRecord> mRecList;
     private final File outputDirectory;
     
     /** Creates a new instance of JavaGenerator
@@ -37,8 +37,8 @@ class JavaGenerator {
      * @param records List of records defined within this file
      * @param outputDirectory 
      */
-    JavaGenerator(String name, ArrayList<JFile> incl,
-            ArrayList<JRecord> records, File outputDirectory)
+    JavaGenerator(String name, List<JFile> incl,
+            List<JRecord> records, File outputDirectory)
     {
         mRecList = records;
         this.outputDirectory = outputDirectory;

+ 2 - 2
src/java/main/org/apache/zookeeper/Environment.java

@@ -48,12 +48,12 @@ public class Environment {
         }
     }
 
-    private static void put(ArrayList<Entry> l, String k, String v) {
+    private static void put(List<Entry> l, String k, String v) {
         l.add(new Entry(k,v));
     }
 
     public static List<Entry> list() {
-        ArrayList<Entry> l = new ArrayList<Entry>();
+        List<Entry> l = new ArrayList<Entry>();
         put(l, "zookeeper.version", Version.getFullVersion());
 
         try {

+ 2 - 1
src/java/main/org/apache/zookeeper/common/PathTrie.java

@@ -21,6 +21,7 @@ package org.apache.zookeeper.common;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -53,7 +54,7 @@ public class PathTrie {
     
     static class TrieNode {
         boolean property = false;
-        final HashMap<String, TrieNode> children;
+        final Map<String, TrieNode> children;
         TrieNode parent = null;
         /**
          * create a trienode with parent

+ 5 - 5
src/java/main/org/apache/zookeeper/server/DataTree.java

@@ -150,7 +150,7 @@ public class DataTree {
         if (retv == null) {
             return new HashSet<String>();
         }
-        HashSet<String> cloned = null;
+        Set<String> cloned = null;
         synchronized (retv) {
             cloned = (HashSet<String>) retv.clone();
         }
@@ -549,7 +549,7 @@ public class DataTree {
             } else if (ephemeralType == EphemeralType.TTL) {
                 ttls.remove(path);
             } else if (eowner != 0) {
-                HashSet<String> nodes = ephemerals.get(eowner);
+                Set<String> nodes = ephemerals.get(eowner);
                 if (nodes != null) {
                     synchronized (nodes) {
                         nodes.remove(path);
@@ -1002,7 +1002,7 @@ public class DataTree {
         // so there is no need for synchronization. The list is not
         // changed here. Only create and delete change the list which
         // are again called from FinalRequestProcessor in sequence.
-        HashSet<String> list = ephemerals.remove(session);
+        Set<String> list = ephemerals.remove(session);
         if (list != null) {
             for (String path : list) {
                 try {
@@ -1286,7 +1286,7 @@ public class DataTree {
         for (Entry<Long, HashSet<String>> entry : ephemerals.entrySet()) {
             pwriter.print("0x" + Long.toHexString(entry.getKey()));
             pwriter.println(":");
-            HashSet<String> tmp = entry.getValue();
+            Set<String> tmp = entry.getValue();
             if (tmp != null) {
                 synchronized (tmp) {
                     for (String path : tmp) {
@@ -1303,7 +1303,7 @@ public class DataTree {
      * @return map of session ID to sets of ephemeral znodes
      */
     public Map<Long, Set<String>> getEphemerals() {
-        HashMap<Long, Set<String>> ephemeralsCopy = new HashMap<Long, Set<String>>();
+        Map<Long, Set<String>> ephemeralsCopy = new HashMap<Long, Set<String>>();
         for (Entry<Long, HashSet<String>> e : ephemerals.entrySet()) {
             synchronized (e.getValue()) {
                 ephemeralsCopy.put(e.getKey(), new HashSet<String>(e.getValue()));

+ 2 - 2
src/java/main/org/apache/zookeeper/server/NettyServerCnxnFactory.java

@@ -74,7 +74,7 @@ public class NettyServerCnxnFactory extends ServerCnxnFactory {
     ServerBootstrap bootstrap;
     Channel parentChannel;
     ChannelGroup allChannels = new DefaultChannelGroup("zkServerCnxns");
-    HashMap<InetAddress, Set<NettyServerCnxn>> ipMap =
+    Map<InetAddress, Set<NettyServerCnxn>> ipMap =
         new HashMap<InetAddress, Set<NettyServerCnxn>>( );
     InetSocketAddress localAddress;
     int maxClientCnxns = 60;
@@ -547,7 +547,7 @@ public class NettyServerCnxnFactory extends ServerCnxnFactory {
 
     @Override
     public Iterable<Map<String, Object>> getAllConnectionInfo(boolean brief) {
-        HashSet<Map<String,Object>> info = new HashSet<Map<String,Object>>();
+        Set<Map<String,Object>> info = new HashSet<Map<String,Object>>();
         // No need to synchronize since cnxns is backed by a ConcurrentHashMap
         for (ServerCnxn c : cnxns) {
             info.add(c.getConnectionInfo(brief));

+ 3 - 3
src/java/main/org/apache/zookeeper/server/PrepRequestProcessor.java

@@ -201,7 +201,7 @@ public class PrepRequestProcessor extends ZooKeeperCriticalThread implements
      *         rolled back in any failure.
      */
     private Map<String, ChangeRecord> getPendingChanges(MultiTransactionRecord multiRequest) {
-        HashMap<String, ChangeRecord> pendingChangeRecords = new HashMap<String, ChangeRecord>();
+        Map<String, ChangeRecord> pendingChangeRecords = new HashMap<String, ChangeRecord>();
 
         for (Op op : multiRequest) {
             String path = op.getPath();
@@ -911,7 +911,7 @@ public class PrepRequestProcessor extends ZooKeeperCriticalThread implements
 
     private List<ACL> removeDuplicates(List<ACL> acl) {
 
-        LinkedList<ACL> retval = new LinkedList<ACL>();
+        List<ACL> retval = new LinkedList<ACL>();
         if (acl != null) {
             for (ACL a : acl) {
                 if (!retval.contains(a)) {
@@ -958,7 +958,7 @@ public class PrepRequestProcessor extends ZooKeeperCriticalThread implements
         // check for well formed ACLs
         // This resolves https://issues.apache.org/jira/browse/ZOOKEEPER-1877
         List<ACL> uniqacls = removeDuplicates(acls);
-        LinkedList<ACL> rv = new LinkedList<ACL>();
+        List<ACL> rv = new LinkedList<ACL>();
         if (uniqacls == null || uniqacls.size() == 0) {
             throw new KeeperException.InvalidACLException(path);
         }

+ 20 - 20
src/java/main/org/apache/zookeeper/server/WatchManager.java

@@ -40,11 +40,11 @@ import org.slf4j.LoggerFactory;
 class WatchManager {
     private static final Logger LOG = LoggerFactory.getLogger(WatchManager.class);
 
-    private final HashMap<String, HashSet<Watcher>> watchTable =
-        new HashMap<String, HashSet<Watcher>>();
+    private final Map<String, Set<Watcher>> watchTable =
+        new HashMap<String, Set<Watcher>>();
 
-    private final HashMap<Watcher, HashSet<String>> watch2Paths =
-        new HashMap<Watcher, HashSet<String>>();
+    private final Map<Watcher, Set<String>> watch2Paths =
+        new HashMap<Watcher, Set<String>>();
 
     synchronized int size(){
         int result = 0;
@@ -55,7 +55,7 @@ class WatchManager {
     }
 
     synchronized void addWatch(String path, Watcher watcher) {
-        HashSet<Watcher> list = watchTable.get(path);
+        Set<Watcher> list = watchTable.get(path);
         if (list == null) {
             // don't waste memory if there are few watches on a node
             // rehash when the 4th entry is added, doubling size thereafter
@@ -65,7 +65,7 @@ class WatchManager {
         }
         list.add(watcher);
 
-        HashSet<String> paths = watch2Paths.get(watcher);
+        Set<String> paths = watch2Paths.get(watcher);
         if (paths == null) {
             // cnxns typically have many watches, so use default cap here
             paths = new HashSet<String>();
@@ -75,12 +75,12 @@ class WatchManager {
     }
 
     synchronized void removeWatcher(Watcher watcher) {
-        HashSet<String> paths = watch2Paths.remove(watcher);
+        Set<String> paths = watch2Paths.remove(watcher);
         if (paths == null) {
             return;
         }
         for (String p : paths) {
-            HashSet<Watcher> list = watchTable.get(p);
+            Set<Watcher> list = watchTable.get(p);
             if (list != null) {
                 list.remove(watcher);
                 if (list.size() == 0) {
@@ -97,7 +97,7 @@ class WatchManager {
     Set<Watcher> triggerWatch(String path, EventType type, Set<Watcher> supress) {
         WatchedEvent e = new WatchedEvent(type,
                 KeeperState.SyncConnected, path);
-        HashSet<Watcher> watchers;
+        Set<Watcher> watchers;
         synchronized (this) {
             watchers = watchTable.remove(path);
             if (watchers == null || watchers.isEmpty()) {
@@ -109,7 +109,7 @@ class WatchManager {
                 return null;
             }
             for (Watcher w : watchers) {
-                HashSet<String> paths = watch2Paths.get(w);
+                Set<String> paths = watch2Paths.get(w);
                 if (paths != null) {
                     paths.remove(path);
                 }
@@ -135,7 +135,7 @@ class WatchManager {
             .append(watchTable.size()).append(" paths\n");
 
         int total = 0;
-        for (HashSet<String> paths : watch2Paths.values()) {
+        for (Set<String> paths : watch2Paths.values()) {
             total += paths.size();
         }
         sb.append("Total watches:").append(total);
@@ -151,7 +151,7 @@ class WatchManager {
      */
     synchronized void dumpWatches(PrintWriter pwriter, boolean byPath) {
         if (byPath) {
-            for (Entry<String, HashSet<Watcher>> e : watchTable.entrySet()) {
+            for (Entry<String, Set<Watcher>> e : watchTable.entrySet()) {
                 pwriter.println(e.getKey());
                 for (Watcher w : e.getValue()) {
                     pwriter.print("\t0x");
@@ -160,7 +160,7 @@ class WatchManager {
                 }
             }
         } else {
-            for (Entry<Watcher, HashSet<String>> e : watch2Paths.entrySet()) {
+            for (Entry<Watcher, Set<String>> e : watch2Paths.entrySet()) {
                 pwriter.print("0x");
                 pwriter.println(Long.toHexString(((ServerCnxn)e.getKey()).getSessionId()));
                 for (String path : e.getValue()) {
@@ -181,7 +181,7 @@ class WatchManager {
      * @return true if the watcher exists, false otherwise
      */
     synchronized boolean containsWatcher(String path, Watcher watcher) {
-        HashSet<String> paths = watch2Paths.get(watcher);
+        Set<String> paths = watch2Paths.get(watcher);
         if (paths == null || !paths.contains(path)) {
             return false;
         }
@@ -198,12 +198,12 @@ class WatchManager {
      * @return true if the watcher successfully removed, false otherwise
      */
     synchronized boolean removeWatcher(String path, Watcher watcher) {
-        HashSet<String> paths = watch2Paths.get(watcher);
+        Set<String> paths = watch2Paths.get(watcher);
         if (paths == null || !paths.remove(path)) {
             return false;
         }
 
-        HashSet<Watcher> list = watchTable.get(path);
+        Set<Watcher> list = watchTable.get(path);
         if (list == null || !list.remove(watcher)) {
             return false;
         }
@@ -223,9 +223,9 @@ class WatchManager {
      */
     synchronized WatchesReport getWatches() {
         Map<Long, Set<String>> id2paths = new HashMap<Long, Set<String>>();
-        for (Entry<Watcher, HashSet<String>> e: watch2Paths.entrySet()) {
+        for (Entry<Watcher, Set<String>> e: watch2Paths.entrySet()) {
             Long id = ((ServerCnxn) e.getKey()).getSessionId();
-            HashSet<String> paths = new HashSet<String>(e.getValue());
+            Set<String> paths = new HashSet<String>(e.getValue());
             id2paths.put(id, paths);
         }
         return new WatchesReport(id2paths);
@@ -239,7 +239,7 @@ class WatchManager {
      */
     synchronized WatchesPathReport getWatchesByPath() {
         Map<String, Set<Long>> path2ids = new HashMap<String, Set<Long>>();
-        for (Entry<String, HashSet<Watcher>> e : watchTable.entrySet()) {
+        for (Entry<String, Set<Watcher>> e : watchTable.entrySet()) {
             Set<Long> ids = new HashSet<Long>(e.getValue().size());
             path2ids.put(e.getKey(), ids);
             for (Watcher watcher : e.getValue()) {
@@ -257,7 +257,7 @@ class WatchManager {
      */
     synchronized WatchesSummary getWatchesSummary() {
         int totalWatches = 0;
-        for (HashSet<String> paths : watch2Paths.values()) {
+        for (Set<String> paths : watch2Paths.values()) {
             totalWatches += paths.size();
         }
         return new WatchesSummary (watch2Paths.size(), watchTable.size(),

+ 2 - 2
src/java/main/org/apache/zookeeper/server/ZooKeeperServer.java

@@ -115,7 +115,7 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
     private final AtomicInteger requestsInProcess = new AtomicInteger(0);
     final List<ChangeRecord> outstandingChanges = new ArrayList<ChangeRecord>();
     // this data structure must be accessed under the outstandingChanges lock
-    final HashMap<String, ChangeRecord> outstandingChangesForPath =
+    final Map<String, ChangeRecord> outstandingChangesForPath =
         new HashMap<String, ChangeRecord>();
 
     protected ServerCnxnFactory serverCnxnFactory;
@@ -284,7 +284,7 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
         }
         
         // Clean up dead sessions
-        LinkedList<Long> deadSessions = new LinkedList<Long>();
+        List<Long> deadSessions = new LinkedList<Long>();
         for (Long session : zkDb.getSessions()) {
             if (zkDb.getSessionWithTimeOuts().get(session) == null) {
                 deadSessions.add(session);

+ 2 - 1
src/java/main/org/apache/zookeeper/server/auth/ProviderRegistry.java

@@ -20,6 +20,7 @@ package org.apache.zookeeper.server.auth;
 
 import java.util.Enumeration;
 import java.util.HashMap;
+import java.util.Map;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -30,7 +31,7 @@ public class ProviderRegistry {
     private static final Logger LOG = LoggerFactory.getLogger(ProviderRegistry.class);
 
     private static boolean initialized = false;
-    private static HashMap<String, AuthenticationProvider> authenticationProviders =
+    private static Map<String, AuthenticationProvider> authenticationProviders =
         new HashMap<>();
 
     //VisibleForTesting

+ 2 - 1
src/java/main/org/apache/zookeeper/server/quorum/AuthFastLeaderElection.java

@@ -27,6 +27,7 @@ import java.nio.ByteBuffer;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.LinkedBlockingQueue;
@@ -801,7 +802,7 @@ public class AuthFastLeaderElection implements Election {
 
     }
 
-    private boolean termPredicate(HashMap<InetSocketAddress, Vote> votes,
+    private boolean termPredicate(Map<InetSocketAddress, Vote> votes,
             long l, long zxid) {
 
 

+ 2 - 1
src/java/main/org/apache/zookeeper/server/quorum/CommitProcessor.java

@@ -21,6 +21,7 @@ package org.apache.zookeeper.server.quorum;
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.LinkedList;
+import java.util.Map;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.LinkedBlockingQueue;
 
@@ -94,7 +95,7 @@ public class CommitProcessor extends ZooKeeperCriticalThread implements
      * Requests that we are holding until commit comes in. Keys represent
      * session ids, each value is a linked list of the session's requests.
      */
-    protected final HashMap<Long, LinkedList<Request>> pendingRequests =
+    protected final Map<Long, LinkedList<Request>> pendingRequests =
             new HashMap<Long, LinkedList<Request>>(10000);
 
     /** The number of requests currently being processed */

+ 4 - 4
src/java/main/org/apache/zookeeper/server/quorum/FastLeaderElection.java

@@ -733,7 +733,7 @@ public class FastLeaderElection implements Election {
      * @param vote
      *            Identifier of the vote received last
      */
-    private boolean termPredicate(HashMap<Long, Vote> votes, Vote vote) {
+    private boolean termPredicate(Map<Long, Vote> votes, Vote vote) {
         SyncedLearnerTracker voteSet = new SyncedLearnerTracker();
         voteSet.addQuorumVerifier(self.getQuorumVerifier());
         if (self.getLastSeenQuorumVerifier() != null
@@ -767,7 +767,7 @@ public class FastLeaderElection implements Election {
      * @param   electionEpoch   epoch id
      */
     private boolean checkLeader(
-            HashMap<Long, Vote> votes,
+            Map<Long, Vote> votes,
             long leader,
             long electionEpoch){
 
@@ -880,9 +880,9 @@ public class FastLeaderElection implements Election {
            self.start_fle = Time.currentElapsedTime();
         }
         try {
-            HashMap<Long, Vote> recvset = new HashMap<Long, Vote>();
+            Map<Long, Vote> recvset = new HashMap<Long, Vote>();
 
-            HashMap<Long, Vote> outofelection = new HashMap<Long, Vote>();
+            Map<Long, Vote> outofelection = new HashMap<Long, Vote>();
 
             int notTimeout = finalizeWait;
 

+ 2 - 1
src/java/main/org/apache/zookeeper/server/quorum/Leader.java

@@ -32,6 +32,7 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.ConcurrentHashMap;
@@ -148,7 +149,7 @@ public class Leader {
     }
 
     // Pending sync requests. Must access under 'this' lock.
-    private final HashMap<Long,List<LearnerSyncRequest>> pendingSyncs =
+    private final Map<Long,List<LearnerSyncRequest>> pendingSyncs =
         new HashMap<Long,List<LearnerSyncRequest>>();
 
     synchronized public int getNumPendingSyncs() {

+ 2 - 2
src/java/main/org/apache/zookeeper/server/quorum/flexible/QuorumMaj.java

@@ -35,8 +35,8 @@ import org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException;
  */
 public class QuorumMaj implements QuorumVerifier {
     private Map<Long, QuorumServer> allMembers = new HashMap<Long, QuorumServer>();
-    private HashMap<Long, QuorumServer> votingMembers = new HashMap<Long, QuorumServer>();
-    private HashMap<Long, QuorumServer> observingMembers = new HashMap<Long, QuorumServer>();
+    private Map<Long, QuorumServer> votingMembers = new HashMap<Long, QuorumServer>();
+    private Map<Long, QuorumServer> observingMembers = new HashMap<Long, QuorumServer>();
     private long version = 0;
     private int half;
 

+ 2 - 1
src/java/systest/org/apache/zookeeper/test/system/BaseSysTest.java

@@ -24,6 +24,7 @@ import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.UnknownHostException;
 import java.util.HashMap;
+import java.util.Map;
 
 import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.Watcher;
@@ -143,7 +144,7 @@ public class BaseSysTest {
 
     private QuorumPeer qps[];
     private File qpsDirs[];
-    HashMap<Long,QuorumServer> peers;
+    Map<Long,QuorumServer> peers;
     private void fakeConfigureServers(int count) throws IOException {
         peers = new HashMap<Long,QuorumServer>();
         qps = new QuorumPeer[count];

+ 2 - 2
src/java/systest/org/apache/zookeeper/test/system/InstanceContainer.java

@@ -225,7 +225,7 @@ public class InstanceContainer implements Watcher, AsyncCallback.ChildrenCallbac
         }
     }
 
-    HashMap<String, Instance> instances = new HashMap<String, Instance>();
+    Map<String, Instance> instances = new HashMap<String, Instance>();
 
     @Override
     public void processResult(int rc, String path, Object ctx, List<String> children) {
@@ -234,7 +234,7 @@ public class InstanceContainer implements Watcher, AsyncCallback.ChildrenCallbac
             zk.getChildren(assignmentsNode, true, this, null);
             return;
         }
-        HashMap<String, Instance> newList = new HashMap<String, Instance>();
+        Map<String, Instance> newList = new HashMap<String, Instance>();
         // check for differences
         Stat stat = new Stat();
         for(String child: children) {

+ 4 - 3
src/java/systest/org/apache/zookeeper/test/system/InstanceManager.java

@@ -23,6 +23,7 @@ import java.util.Arrays;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.Map.Entry;
 
 import org.slf4j.Logger;
@@ -79,8 +80,8 @@ public class InstanceManager implements AsyncCallback.ChildrenCallback, Watcher
             System.err.println("Preferred List is empty");
         }
     }
-    private HashMap<String, HashSet<Assigned>> assignments = new HashMap<String, HashSet<Assigned>>();
-    private HashMap<String, Assigned> instanceToAssignment = new HashMap<String, Assigned>();
+    private Map<String, HashSet<Assigned>> assignments = new HashMap<String, HashSet<Assigned>>();
+    private Map<String, Assigned> instanceToAssignment = new HashMap<String, Assigned>();
     public InstanceManager(ZooKeeper zk, String prefix) throws KeeperException, InterruptedException {
         this.zk = zk;
         this.prefixNode = prefix;
@@ -137,7 +138,7 @@ public class InstanceManager implements AsyncCallback.ChildrenCallback, Watcher
         if (LOG.isDebugEnabled()) {
             LOG.debug("Got " + children + " children from " + path);
         }
-        HashMap<String, HashSet<Assigned>> newAssignments = new HashMap<String, HashSet<Assigned>>();
+        Map<String, HashSet<Assigned>> newAssignments = new HashMap<String, HashSet<Assigned>>();
         for(String c: children) {
             HashSet<Assigned> a = assignments.remove(c);
             if (a != null) {

+ 2 - 1
src/java/systest/org/apache/zookeeper/test/system/QuorumPeerInstance.java

@@ -26,6 +26,7 @@ import java.net.InetSocketAddress;
 import java.net.ServerSocket;
 import java.net.Socket;
 import java.util.HashMap;
+import java.util.Map;
 import java.util.Properties;
 
 import org.slf4j.Logger;
@@ -55,7 +56,7 @@ class QuorumPeerInstance implements Instance {
     InetSocketAddress clientAddr;
     InetSocketAddress quorumLeaderAddr;
     InetSocketAddress quorumLeaderElectionAddr;
-    HashMap<Long, QuorumServer> peers;
+    Map<Long, QuorumServer> peers;
     File snapDir, logDir;
 
     public QuorumPeerInstance() {

+ 9 - 7
src/java/test/org/apache/zookeeper/server/quorum/CommitProcessorConcurrencyTest.java

@@ -24,6 +24,8 @@ import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.LinkedBlockingQueue;
 
@@ -175,8 +177,8 @@ public class CommitProcessorConcurrencyTest extends ZKTestCase {
     public void processAsMuchUncommittedRequestsAsPossibleTest()
             throws Exception {
         final String path = "/testAsMuchAsPossible";
-        LinkedList<Request> shouldBeProcessed = new LinkedList<Request>();
-        HashSet<Request> shouldNotBeProcessed = new HashSet<Request>();
+        List<Request> shouldBeProcessed = new LinkedList<Request>();
+        Set<Request> shouldNotBeProcessed = new HashSet<Request>();
         for (int sessionId = 1; sessionId <= 5; ++sessionId) {
             for (int readReqId = 1; readReqId <= sessionId; ++readReqId) {
                 Request readReq = newRequest(new GetDataRequest(path, false),
@@ -221,8 +223,8 @@ public class CommitProcessorConcurrencyTest extends ZKTestCase {
     public void processAllFollowingUncommittedAfterFirstCommitTest()
             throws Exception {
         final String path = "/testUncommittedFollowingCommited";
-        HashSet<Request> shouldBeInPending = new HashSet<Request>();
-        HashSet<Request> shouldBeProcessedAfterPending = new HashSet<Request>();
+        Set<Request> shouldBeInPending = new HashSet<Request>();
+        Set<Request> shouldBeProcessedAfterPending = new HashSet<Request>();
 
         Request writeReq = newRequest(
                 new CreateRequest(path, new byte[0], Ids.OPEN_ACL_UNSAFE,
@@ -282,7 +284,7 @@ public class CommitProcessorConcurrencyTest extends ZKTestCase {
     public void noStarvationOfNonLocalCommittedRequestsTest() throws Exception {
         final String path = "/noStarvationOfCommittedRequests";
         processor.queuedRequests = new MockRequestsQueue();
-        HashSet<Request> nonLocalCommits = new HashSet<Request>();
+        Set<Request> nonLocalCommits = new HashSet<Request>();
         for (int i = 0; i < 10; i++) {
             Request nonLocalCommitReq = newRequest(
                     new CreateRequest(path, new byte[0], Ids.OPEN_ACL_UNSAFE,
@@ -320,7 +322,7 @@ public class CommitProcessorConcurrencyTest extends ZKTestCase {
                 OpCode.create, 0x3, 1);
         processor.queuedRequests.add(firstCommittedReq);
         processor.committedRequests.add(firstCommittedReq);
-        HashSet<Request> allReads = new HashSet<Request>();
+        Set<Request> allReads = new HashSet<Request>();
 
         // +1 read request to queuedRequests
         Request firstRead = newRequest(new GetDataRequest(path, false),
@@ -335,7 +337,7 @@ public class CommitProcessorConcurrencyTest extends ZKTestCase {
                 OpCode.create, 0x99, 2);
         processor.committedRequests.add(secondCommittedReq);
 
-        HashSet<Request> waitingCommittedRequests = new HashSet<Request>();
+        Set<Request> waitingCommittedRequests = new HashSet<Request>();
         // +99 non local committed requests
         for (int writeReqId = 3; writeReqId < 102; ++writeReqId) {
             Request writeReq = newRequest(

+ 2 - 1
src/java/test/org/apache/zookeeper/server/quorum/FLEBackwardElectionRoundTest.java

@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.nio.ByteBuffer;
 import java.util.HashMap;
+import java.util.Map;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -42,7 +43,7 @@ public class FLEBackwardElectionRoundTest extends ZKTestCase {
     protected static final Logger LOG = LoggerFactory.getLogger(FLELostMessageTest.class);
 
     int count;
-    HashMap<Long,QuorumServer> peers;
+    Map<Long,QuorumServer> peers;
     File tmpdir[];
     int port[];
 

+ 2 - 1
src/java/test/org/apache/zookeeper/server/quorum/LearnerHandlerTest.java

@@ -28,6 +28,7 @@ import java.io.IOException;
 import java.net.Socket;
 import java.util.Iterator;
 import java.util.LinkedList;
+import java.util.List;
 import java.util.Queue;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 
@@ -90,7 +91,7 @@ public class LearnerHandlerTest extends ZKTestCase {
             return 0;
         }
 
-        public LinkedList<Proposal> getCommittedLog() {
+        public List<Proposal> getCommittedLog() {
             return committedLog;
         }
 

+ 2 - 1
src/java/test/org/apache/zookeeper/server/quorum/QuorumRequestPipelineTest.java

@@ -21,6 +21,7 @@ package org.apache.zookeeper.server.quorum;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashSet;
+import java.util.Set;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
@@ -47,7 +48,7 @@ public class QuorumRequestPipelineTest extends QuorumBase {
     protected final CountDownLatch callComplete = new CountDownLatch(1);
     protected boolean complete = false;
     protected final static String PARENT_PATH = "/foo";
-    protected final static HashSet<String> CHILDREN = new HashSet<String>(Arrays.asList("1", "2", "3"));
+    protected final static Set<String> CHILDREN = new HashSet<String>(Arrays.asList("1", "2", "3"));
     protected final static String AUTH_PROVIDER = "digest";
     protected final static byte[] AUTH = "hello".getBytes();
     protected final static byte[] DATA = "Hint Water".getBytes();

+ 2 - 1
src/java/test/org/apache/zookeeper/server/quorum/ReconfigFailureCasesTest.java

@@ -24,6 +24,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.KeeperException.NewConfigNoQuorum;
@@ -226,7 +227,7 @@ public class ReconfigFailureCasesTest extends QuorumPeerTestBase {
         int[][] ports = ReconfigRecoveryTest.generatePorts(SERVER_COUNT);
 
         // generate old config string
-        HashSet<Integer> observers = new HashSet<Integer>();
+        Set<Integer> observers = new HashSet<Integer>();
         observers.add(3);
         StringBuilder sb = ReconfigRecoveryTest.generateConfig(SERVER_COUNT, ports, observers);
         String currentQuorumCfgSection = sb.toString();

+ 4 - 3
src/java/test/org/apache/zookeeper/server/quorum/ReconfigRecoveryTest.java

@@ -22,6 +22,7 @@ import static org.apache.zookeeper.test.ClientBase.CONNECTION_TIMEOUT;
 
 import java.util.ArrayList;
 import java.util.HashSet;
+import java.util.Set;
 
 import org.apache.zookeeper.PortAssignment;
 import org.apache.zookeeper.ZooKeeper;
@@ -399,7 +400,7 @@ public class ReconfigRecoveryTest extends QuorumPeerTestBase {
         String currentQuorumCfgSection, nextQuorumCfgSection;
 
         // generate old config string
-        HashSet<Integer> observers = new HashSet<Integer>();
+        Set<Integer> observers = new HashSet<Integer>();
         observers.add(2);
         StringBuilder sb = generateConfig(3, ports, observers);
         currentQuorumCfgSection = sb.toString();
@@ -473,7 +474,7 @@ public class ReconfigRecoveryTest extends QuorumPeerTestBase {
         String currentQuorumCfg, nextQuorumCfgSection;
 
         // generate old config string
-        HashSet<Integer> observers = new HashSet<Integer>();
+        Set<Integer> observers = new HashSet<Integer>();
         observers.add(2);
 
         StringBuilder sb = generateConfig(3, ports, observers);
@@ -570,7 +571,7 @@ public class ReconfigRecoveryTest extends QuorumPeerTestBase {
      * observerIds correspond to observers, other ids are for participants.
      */
     public static StringBuilder generateConfig(int numServers, int[][] ports,
-            HashSet<Integer> observerIds) {
+            Set<Integer> observerIds) {
         StringBuilder sb = new StringBuilder();
         for (int i = 0; i < numServers; i++) {
             String server = "server." + i + "=localhost:" + ports[i][0] + ":"

+ 1 - 1
src/java/test/org/apache/zookeeper/test/ACLTest.java

@@ -127,7 +127,7 @@ public class ACLTest extends ZKTestCase implements Watcher {
                 id.setId("1.1.1."+j);
                 id.setScheme("ip");
                 acl.setId(id);
-                ArrayList<ACL> list = new ArrayList<ACL>();
+                List<ACL> list = new ArrayList<ACL>();
                 list.add(acl);
                 zk.create(path, path.getBytes(), list, CreateMode.PERSISTENT);
             }

+ 3 - 1
src/java/test/org/apache/zookeeper/test/AsyncTest.java

@@ -20,6 +20,7 @@ package org.apache.zookeeper.test;
 
 
 import java.util.LinkedList;
+import java.util.List;
 
 import org.apache.zookeeper.AsyncCallback.DataCallback;
 import org.apache.zookeeper.AsyncCallback.StringCallback;
@@ -67,7 +68,8 @@ public class AsyncTest extends ZKTestCase
         return zk;
     }
 
-    LinkedList<Integer> results = new LinkedList<Integer>();
+    List<Integer> results = new LinkedList<Integer>();
+
     @Test
     public void testAsync() throws Exception
     {

+ 1 - 1
src/java/test/org/apache/zookeeper/test/ClientBase.java

@@ -211,7 +211,7 @@ public abstract class ClientBase extends ZKTestCase {
         return createClient(watcher, hostPort);
     }
 
-    private LinkedList<ZooKeeper> allClients;
+    private List<ZooKeeper> allClients;
     private boolean allClientsSetup = false;
 
     protected TestableZooKeeper createClient(CountdownWatcher watcher, String hp)

+ 2 - 1
src/java/test/org/apache/zookeeper/test/CnxManagerTest.java

@@ -29,6 +29,7 @@ import java.nio.channels.SocketChannel;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.Map;
 import java.util.Random;
 import java.util.concurrent.TimeUnit;
 import java.net.Socket;
@@ -54,7 +55,7 @@ public class CnxManagerTest extends ZKTestCase {
     protected static final int THRESHOLD = 4;
 
     int count;
-    HashMap<Long,QuorumServer> peers;
+    Map<Long,QuorumServer> peers;
     File peerTmpdir[];
     int peerQuorumPort[];
     int peerClientPort[];

+ 4 - 2
src/java/test/org/apache/zookeeper/test/FLERestartTest.java

@@ -23,6 +23,8 @@ import java.net.InetSocketAddress;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
 import java.util.concurrent.Semaphore;
 
 import org.slf4j.Logger;
@@ -43,8 +45,8 @@ public class FLERestartTest extends ZKTestCase {
     protected static final Logger LOG = LoggerFactory.getLogger(FLETest.class);
 
     private int count;
-    private HashMap<Long,QuorumServer> peers;
-    private ArrayList<FLERestartThread> restartThreads;
+    private Map<Long,QuorumServer> peers;
+    private List<FLERestartThread> restartThreads;
     private File tmpdir[];
     private int port[];
     private Semaphore finish;

+ 4 - 3
src/java/test/org/apache/zookeeper/test/FLETest.java

@@ -23,6 +23,7 @@ import java.net.InetSocketAddress;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Map;
 import java.util.Random;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
@@ -64,10 +65,10 @@ public class FLETest extends ZKTestCase {
     }
 
     int count;
-    HashMap<Long,QuorumServer> peers;
+    Map<Long,QuorumServer> peers;
     ArrayList<LEThread> threads;
-    HashMap<Integer, HashSet<TestVote> > voteMap;
-    HashMap<Long, LEThread> quora;
+    Map<Integer, HashSet<TestVote> > voteMap;
+    Map<Long, LEThread> quora;
     File tmpdir[];
     int port[];
     int successCount;

+ 2 - 1
src/java/test/org/apache/zookeeper/test/FLEZeroWeightTest.java

@@ -22,6 +22,7 @@ import java.io.File;
 import java.net.InetSocketAddress;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.Map;
 import java.util.Properties;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -44,7 +45,7 @@ public class FLEZeroWeightTest extends ZKTestCase {
     Properties qp;
 
     int count;
-    HashMap<Long,QuorumServer> peers;
+    Map<Long,QuorumServer> peers;
     ArrayList<LEThread> threads;
     File tmpdir[];
     int port[];

+ 2 - 1
src/java/test/org/apache/zookeeper/test/IntegrityCheck.java

@@ -33,6 +33,7 @@ package org.apache.zookeeper.test;
  */
 import java.util.Date;
 import java.util.HashMap;
+import java.util.Map;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -49,7 +50,7 @@ public class IntegrityCheck implements StatCallback, DataCallback {
 
     ZooKeeper zk;
 
-    HashMap<String, byte[]> lastValue = new HashMap<String, byte[]>();
+    Map<String, byte[]> lastValue = new HashMap<String, byte[]>();
 
     int count;
 

+ 2 - 1
src/java/test/org/apache/zookeeper/test/LocalSessionsOnlyTest.java

@@ -19,6 +19,7 @@
 package org.apache.zookeeper.test;
 
 import java.util.HashMap;
+import java.util.Map;
 import java.util.Map.Entry;
 
 import org.apache.zookeeper.CreateMode;
@@ -107,7 +108,7 @@ public class LocalSessionsOnlyTest extends ZKTestCase {
         zk.close();
 
         // Validate data on both follower and leader
-        HashMap<String, Integer> peers = new HashMap<String, Integer>();
+        Map<String, Integer> peers = new HashMap<String, Integer>();
         peers.put("leader", leaderIdx);
         peers.put("follower", followerIdx);
         for (Entry<String, Integer> entry: peers.entrySet()) {

+ 2 - 1
src/java/test/org/apache/zookeeper/test/OOMTest.java

@@ -23,6 +23,7 @@ import static org.apache.zookeeper.test.ClientBase.CONNECTION_TIMEOUT;
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
@@ -47,7 +48,7 @@ public class OOMTest extends ZKTestCase implements Watcher {
         File tmpDir = ClientBase.createTmpDir();
         // Grab some memory so that it is easier to cause an
         // OOM condition;
-        ArrayList<byte[]> hog = new ArrayList<byte[]>();
+        List<byte[]> hog = new ArrayList<byte[]>();
         while (true) {
             try {
                 hog.add(new byte[1024 * 1024 * 2]);

+ 3 - 2
src/java/test/org/apache/zookeeper/test/QuorumBase.java

@@ -24,6 +24,7 @@ import java.net.InetSocketAddress;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.LinkedHashSet;
+import java.util.Map;
 import java.util.Set;
 
 import org.slf4j.Logger;
@@ -136,7 +137,7 @@ public class QuorumBase extends ClientBase {
         int tickTime = 2000;
         int initLimit = 3;
         int syncLimit = 3;
-        HashMap<Long,QuorumServer> peers = new HashMap<Long,QuorumServer>();
+        Map<Long,QuorumServer> peers = new HashMap<Long,QuorumServer>();
         peers.put(Long.valueOf(1), new QuorumServer(1, 
                 new InetSocketAddress(LOCALADDR, port1),
                 new InetSocketAddress(LOCALADDR, portLE1),
@@ -293,7 +294,7 @@ public class QuorumBase extends ClientBase {
         setupServer(5);
     }
 
-    HashMap<Long,QuorumServer> peers = null;
+    Map<Long,QuorumServer> peers = null;
     public void setupServer(int i) throws IOException {
         int tickTime = 2000;
         int initLimit = 3;

+ 1 - 1
src/java/test/org/apache/zookeeper/test/ReconfigTest.java

@@ -479,7 +479,7 @@ public class ReconfigTest extends ZKTestCase implements DataCallback{
         // lets remove someone who's not the leader
         leavingServers.add(getLeaderId(qu) == 5 ? "4": "5");
  
-        LinkedList<Integer> results = new LinkedList<Integer>();
+        List<Integer> results = new LinkedList<Integer>();
         
         zkAdminArr[1].reconfigure(null, leavingServers, null, -1, this, results);
         

+ 1 - 1
src/java/test/org/apache/zookeeper/test/SessionTest.java

@@ -414,7 +414,7 @@ public class SessionTest extends ZKTestCase {
     }
 
     private class DupWatcher extends CountdownWatcher {
-        public LinkedList<WatchedEvent> states = new LinkedList<WatchedEvent>();
+        public List<WatchedEvent> states = new LinkedList<WatchedEvent>();
         public void process(WatchedEvent event) {
             super.process(event);
             if (event.getType() == EventType.None) {

+ 2 - 1
src/java/test/org/apache/zookeeper/test/TruncateTest.java

@@ -22,6 +22,7 @@ import java.io.File;
 import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.util.HashMap;
+import java.util.Map;
 
 import org.apache.jute.Record;
 import org.apache.zookeeper.CreateMode;
@@ -190,7 +191,7 @@ public class TruncateTest extends ZKTestCase {
         int port3 = PortAssignment.unique();
         
         // Start up two of the quorum and add 10 txns
-        HashMap<Long,QuorumServer> peers = new HashMap<Long,QuorumServer>();
+        Map<Long,QuorumServer> peers = new HashMap<Long,QuorumServer>();
         peers.put(Long.valueOf(1), new QuorumServer(1,
                        new InetSocketAddress("127.0.0.1", PortAssignment.unique()),
                        new InetSocketAddress("127.0.0.1", PortAssignment.unique()),

+ 6 - 5
src/recipes/queue/src/java/org/apache/zookeeper/recipes/queue/DistributedQueue.java

@@ -19,6 +19,7 @@
 package org.apache.zookeeper.recipes.queue;
 
 import java.util.List;
+import java.util.Map;
 import java.util.NoSuchElementException;
 import java.util.TreeMap;
 import java.util.concurrent.CountDownLatch;
@@ -68,8 +69,8 @@ public class DistributedQueue {
      * @param watcher optional watcher on getChildren() operation.
      * @return map from id to child name for all children
      */
-    private TreeMap<Long,String> orderedChildren(Watcher watcher) throws KeeperException, InterruptedException {
-        TreeMap<Long,String> orderedChildren = new TreeMap<Long,String>();
+    private Map<Long,String> orderedChildren(Watcher watcher) throws KeeperException, InterruptedException {
+        Map<Long,String> orderedChildren = new TreeMap<Long,String>();
 
         List<String> childNames = null;
         try{
@@ -147,7 +148,7 @@ public class DistributedQueue {
      * @throws InterruptedException
      */
     public byte[] element() throws NoSuchElementException, KeeperException, InterruptedException {
-        TreeMap<Long,String> orderedChildren;
+        Map<Long,String> orderedChildren;
 
         // element, take, and remove follow the same pattern.
         // We want to return the child node with the smallest sequence number.
@@ -184,7 +185,7 @@ public class DistributedQueue {
      * @throws InterruptedException
      */
     public byte[] remove() throws NoSuchElementException, KeeperException, InterruptedException {
-        TreeMap<Long,String> orderedChildren;
+        Map<Long,String> orderedChildren;
         // Same as for element.  Should refactor this.
         while(true){
             try{
@@ -234,7 +235,7 @@ public class DistributedQueue {
      * @throws InterruptedException
      */
     public byte[] take() throws KeeperException, InterruptedException {
-        TreeMap<Long,String> orderedChildren;
+        Map<Long,String> orderedChildren;
         // Same as for element.  Should refactor this.
         while(true){
             LatchChildWatcher childWatcher = new LatchChildWatcher();