zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rake...@apache.org
Subject zookeeper git commit: ZOOKEEPER-2732: Cleanup findbug warnings in branch-3.4: Performance Warnings
Date Mon, 22 May 2017 04:25:12 GMT
Repository: zookeeper
Updated Branches:
  refs/heads/branch-3.4 3c4f01f64 -> 6522d3f4d


ZOOKEEPER-2732: Cleanup findbug warnings in branch-3.4: Performance Warnings

rakeshadr Apologies for recreating this, I accidentally pushed a bad branch in https://github.com/apache/zookeeper/pull/231
and GitHub will not let me reset the head for that PR. This should be rebased and ready to
be merged.

Author: Abraham Fine <afine@apache.org>

Reviewers: Rakesh Radhakrishnan <rakeshr@apache.org>

Closes #258 from afine/ZOOKEEPER-2732


Project: http://git-wip-us.apache.org/repos/asf/zookeeper/repo
Commit: http://git-wip-us.apache.org/repos/asf/zookeeper/commit/6522d3f4
Tree: http://git-wip-us.apache.org/repos/asf/zookeeper/tree/6522d3f4
Diff: http://git-wip-us.apache.org/repos/asf/zookeeper/diff/6522d3f4

Branch: refs/heads/branch-3.4
Commit: 6522d3f4d2bc7de363b3c2f562a2e48cafa86d45
Parents: 3c4f01f
Author: Abraham Fine <afine@apache.org>
Authored: Sun May 21 15:55:35 2017 -0700
Committer: Rakesh Radhakrishnan <rakeshr@apache.org>
Committed: Sun May 21 15:55:35 2017 -0700

----------------------------------------------------------------------
 src/java/main/org/apache/zookeeper/ZooKeeperMain.java   |  4 ++--
 src/java/main/org/apache/zookeeper/server/DataTree.java | 10 +++++-----
 .../zookeeper/server/quorum/FastLeaderElection.java     |  6 +++---
 .../zookeeper/server/quorum/QuorumCnxManager.java       |  2 +-
 .../server/quorum/flexible/QuorumHierarchical.java      | 12 +++++++-----
 5 files changed, 18 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zookeeper/blob/6522d3f4/src/java/main/org/apache/zookeeper/ZooKeeperMain.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/ZooKeeperMain.java b/src/java/main/org/apache/zookeeper/ZooKeeperMain.java
index 26721f5..48aaa73 100644
--- a/src/java/main/org/apache/zookeeper/ZooKeeperMain.java
+++ b/src/java/main/org/apache/zookeeper/ZooKeeperMain.java
@@ -90,8 +90,8 @@ public class ZooKeeperMain {
 
     static void usage() {
         System.err.println("ZooKeeper -server host:port cmd args");
-        for (String cmd : commandMap.keySet()) {
-            System.err.println("\t"+cmd+ " " + commandMap.get(cmd));
+        for (Map.Entry<String, String> entry : commandMap.entrySet()) {
+            System.err.println("\t" + entry.getKey() + " " + entry.getValue());
         }
     }
 

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/6522d3f4/src/java/main/org/apache/zookeeper/server/DataTree.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/server/DataTree.java b/src/java/main/org/apache/zookeeper/server/DataTree.java
index 656e4e9..f2537f3 100644
--- a/src/java/main/org/apache/zookeeper/server/DataTree.java
+++ b/src/java/main/org/apache/zookeeper/server/DataTree.java
@@ -1133,13 +1133,13 @@ public class DataTree {
      * @param pwriter the output to write to
      */
     public void dumpEphemerals(PrintWriter pwriter) {
-        Set<Long> keys = ephemerals.keySet();
+        Set<Map.Entry<Long, HashSet<String>>> entrySet = ephemerals.entrySet();
         pwriter.println("Sessions with Ephemerals ("
-                + keys.size() + "):");
-        for (long k : keys) {
-            pwriter.print("0x" + Long.toHexString(k));
+                + entrySet.size() + "):");
+        for (Map.Entry<Long, HashSet<String>> entry : entrySet) {
+            pwriter.print("0x" + Long.toHexString(entry.getKey()));
             pwriter.println(":");
-            HashSet<String> tmp = ephemerals.get(k);
+            HashSet<String> tmp = entry.getValue();
             if (tmp != null) {
                 synchronized (tmp) {
                     for (String path : tmp) {

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/6522d3f4/src/java/main/org/apache/zookeeper/server/quorum/FastLeaderElection.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/server/quorum/FastLeaderElection.java b/src/java/main/org/apache/zookeeper/server/quorum/FastLeaderElection.java
index dc5f099..066f385 100644
--- a/src/java/main/org/apache/zookeeper/server/quorum/FastLeaderElection.java
+++ b/src/java/main/org/apache/zookeeper/server/quorum/FastLeaderElection.java
@@ -122,15 +122,15 @@ public class FastLeaderElection implements Election {
          * epoch of the proposed leader
          */
         long peerEpoch;
-        
+
         @Override
         public String toString() {
-            return new String(Long.toHexString(version) + " (message format version), " 
+            return Long.toHexString(version) + " (message format version), "
                     + leader + " (n.leader), 0x"
                     + Long.toHexString(zxid) + " (n.zxid), 0x"
                     + Long.toHexString(electionEpoch) + " (n.round), " + state
                     + " (n.state), " + sid + " (n.sid), 0x"
-                    + Long.toHexString(peerEpoch) + " (n.peerEpoch) ");
+                    + Long.toHexString(peerEpoch) + " (n.peerEpoch) ";
         }
     }
     

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/6522d3f4/src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java b/src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java
index 33f1943..2b131c4 100644
--- a/src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java
+++ b/src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java
@@ -196,7 +196,7 @@ public class QuorumCnxManager {
         this.lastMessageSent = new ConcurrentHashMap<Long, ByteBuffer>();
         String cnxToValue = System.getProperty("zookeeper.cnxTimeout");
         if(cnxToValue != null){
-            this.cnxTO = new Integer(cnxToValue); 
+            this.cnxTO = Integer.parseInt(cnxToValue);
         }
 
         this.mySid = mySid;

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/6522d3f4/src/java/main/org/apache/zookeeper/server/quorum/flexible/QuorumHierarchical.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/server/quorum/flexible/QuorumHierarchical.java
b/src/java/main/org/apache/zookeeper/server/quorum/flexible/QuorumHierarchical.java
index d37881f..428391e 100644
--- a/src/java/main/org/apache/zookeeper/server/quorum/flexible/QuorumHierarchical.java
+++ b/src/java/main/org/apache/zookeeper/server/quorum/flexible/QuorumHierarchical.java
@@ -206,8 +206,9 @@ public class QuorumHierarchical implements QuorumVerifier {
      * different places, so we have a separate method.
      */
     private void computeGroupWeight(){
-        for(long sid : serverGroup.keySet()){
-            Long gid = serverGroup.get(sid);
+        for(Entry<Long, Long> entry : serverGroup.entrySet()){
+            Long sid = entry.getKey();
+            Long gid = entry.getValue();
             if(!groupWeight.containsKey(gid))
                 groupWeight.put(gid, serverWeight.get(sid));
             else {
@@ -254,9 +255,10 @@ public class QuorumHierarchical implements QuorumVerifier {
          * Check if all groups have majority
          */
         int majGroupCounter = 0;
-        for(long gid : expansion.keySet()) {
-            LOG.debug("Group info: " + expansion.get(gid) + ", " + gid + ", " + groupWeight.get(gid));
-            if(expansion.get(gid) > (groupWeight.get(gid) / 2) )
+        for(Entry<Long, Long> entry : expansion.entrySet()) {
+            Long gid = entry.getKey();
+            LOG.debug("Group info: " + entry.getValue() + ", " + gid + ", " + groupWeight.get(gid));
+            if(entry.getValue() > (groupWeight.get(gid) / 2) )
                 majGroupCounter++;
         }
         


Mime
View raw message