bookkeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From si...@apache.org
Subject bookkeeper git commit: BOOKKEEPER-1038: Fix findbugs warnings and upgrade to 3.0.4
Date Thu, 20 Apr 2017 17:55:21 GMT
Repository: bookkeeper
Updated Branches:
  refs/heads/master de59bd2ad -> 83d5d9e2a


BOOKKEEPER-1038: Fix findbugs warnings and upgrade to 3.0.4

- upgrade to findbugs 3.0.4
- fix DLS_DEAD_LOCAL_STORE At BookieInfoReader.java (introduce a constant)
- fix EQ_OVERRIDING_EQUALS_NOT_SYMMETRIC At PerChannelBookieClient.java (introduce a V3CompletionKey)

Author: eolivelli <eolivelli@apache.org>

Reviewers: Sijie Guo <sijie@apache.org>

Closes #131 from eolivelli/BOOKKEEPER-1038-findbugs


Project: http://git-wip-us.apache.org/repos/asf/bookkeeper/repo
Commit: http://git-wip-us.apache.org/repos/asf/bookkeeper/commit/83d5d9e2
Tree: http://git-wip-us.apache.org/repos/asf/bookkeeper/tree/83d5d9e2
Diff: http://git-wip-us.apache.org/repos/asf/bookkeeper/diff/83d5d9e2

Branch: refs/heads/master
Commit: 83d5d9e2a51c8c135bfc97d3831beccebe11a69a
Parents: de59bd2
Author: eolivelli <eolivelli@apache.org>
Authored: Thu Apr 20 10:55:16 2017 -0700
Committer: Sijie Guo <sijie@apache.org>
Committed: Thu Apr 20 10:55:16 2017 -0700

----------------------------------------------------------------------
 .../bookkeeper/client/BookieInfoReader.java     |  8 ++--
 .../proto/PerChannelBookieClient.java           | 42 ++++++++++++--------
 pom.xml                                         |  2 +-
 3 files changed, 31 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/83d5d9e2/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookieInfoReader.java
----------------------------------------------------------------------
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookieInfoReader.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookieInfoReader.java
index 7ef1b76..7708140 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookieInfoReader.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookieInfoReader.java
@@ -40,6 +40,10 @@ import org.slf4j.LoggerFactory;
 
 public class BookieInfoReader {
     private static final Logger LOG = LoggerFactory.getLogger(BookieInfoReader.class);
+    private static final long GET_BOOKIE_INFO_REQUEST_FLAGS
+        = BookkeeperProtocol.GetBookieInfoRequest.Flags.TOTAL_DISK_CAPACITY_VALUE |
+                               BookkeeperProtocol.GetBookieInfoRequest.Flags.FREE_DISK_SPACE_VALUE;
+
     private final ScheduledExecutorService scheduler;
     private final BookKeeper bk;
     private final ClientConfiguration conf;
@@ -163,13 +167,11 @@ public class BookieInfoReader {
         }
 
         BookieClient bkc = bk.getBookieClient();
-        final long requested = BookkeeperProtocol.GetBookieInfoRequest.Flags.TOTAL_DISK_CAPACITY_VALUE
|
-                               BookkeeperProtocol.GetBookieInfoRequest.Flags.FREE_DISK_SPACE_VALUE;
         totalSent.set(0);
         completedCnt.set(0);
         LOG.debug("Getting bookie info for: {}", joinedBookies);
         for (BookieSocketAddress b : joinedBookies) {
-            bkc.getBookieInfo(b, requested,
+            bkc.getBookieInfo(b, GET_BOOKIE_INFO_REQUEST_FLAGS,
                     new GetBookieInfoCallback() {
                         void processReadInfoComplete(int rc, BookieInfo bInfo, Object ctx)
{
                             BookieSocketAddress b = (BookieSocketAddress) ctx;

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/83d5d9e2/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PerChannelBookieClient.java
----------------------------------------------------------------------
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PerChannelBookieClient.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PerChannelBookieClient.java
index be169b6..7db620d 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PerChannelBookieClient.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PerChannelBookieClient.java
@@ -404,7 +404,7 @@ public class PerChannelBookieClient extends SimpleChannelHandler implements
Chan
 
     void writeLac(final long ledgerId, final byte[] masterKey, final long lac, ChannelBuffer
toSend, WriteLacCallback cb, Object ctx) {
         final long txnId = getTxnId();
-        final CompletionKey completionKey = new CompletionKey(txnId, OperationType.WRITE_LAC);
+        final CompletionKey completionKey = new V3CompletionKey(txnId, OperationType.WRITE_LAC);
         // writeLac is mostly like addEntry hence uses addEntryTimeout
         completionObjects.put(completionKey,
                 new WriteLacCompletion(writeLacOpLogger, cb, ctx, lac, scheduleTimeout(completionKey,
addEntryTimeout)));
@@ -486,7 +486,7 @@ public class PerChannelBookieClient extends SimpleChannelHandler implements
Chan
 
         } else {
             final long txnId = getTxnId();
-            completion = new CompletionKey(txnId, OperationType.ADD_ENTRY);
+            completion = new V3CompletionKey(txnId, OperationType.ADD_ENTRY);
             // Build the request and calculate the total size to be included in the packet.
             BKPacketHeader.Builder headerBuilder = BKPacketHeader.newBuilder()
                     .setVersion(ProtocolVersion.VERSION_THREE)
@@ -558,7 +558,7 @@ public class PerChannelBookieClient extends SimpleChannelHandler implements
Chan
                     BookieProtocol.FLAG_DO_FENCING, masterKey);
         } else {
             final long txnId = getTxnId();
-            completion = new CompletionKey(txnId, OperationType.READ_ENTRY);
+            completion = new V3CompletionKey(txnId, OperationType.READ_ENTRY);
 
             // Build the request and calculate the total size to be included in the packet.
             BKPacketHeader.Builder headerBuilder = BKPacketHeader.newBuilder()
@@ -627,7 +627,7 @@ public class PerChannelBookieClient extends SimpleChannelHandler implements
Chan
             completion = new V2CompletionKey(ledgerId, (long) 0, OperationType.READ_LAC);
         } else {
             final long txnId = getTxnId();
-            completion = new CompletionKey(txnId, OperationType.READ_LAC);
+            completion = new V3CompletionKey(txnId, OperationType.READ_LAC);
 
             // Build the request and calculate the total size to be included in the packet.
             BKPacketHeader.Builder headerBuilder = BKPacketHeader.newBuilder()
@@ -685,7 +685,7 @@ public class PerChannelBookieClient extends SimpleChannelHandler implements
Chan
             completion = new V2CompletionKey(ledgerId, entryId, OperationType.READ_ENTRY);
         } else {
             final long txnId = getTxnId();
-            completion = new CompletionKey(txnId, OperationType.READ_ENTRY);
+            completion = new V3CompletionKey(txnId, OperationType.READ_ENTRY);
 
             // Build the request and calculate the total size to be included in the packet.
             BKPacketHeader.Builder headerBuilder = BKPacketHeader.newBuilder()
@@ -741,7 +741,7 @@ public class PerChannelBookieClient extends SimpleChannelHandler implements
Chan
 
     public void getBookieInfo(final long requested, GetBookieInfoCallback cb, Object ctx)
{
         final long txnId = getTxnId();
-        final CompletionKey completionKey = new CompletionKey(txnId, OperationType.GET_BOOKIE_INFO);
+        final CompletionKey completionKey = new V3CompletionKey(txnId, OperationType.GET_BOOKIE_INFO);
         completionObjects.put(completionKey,
                 new GetBookieInfoCompletion(this, getBookieInfoOpLogger, cb, ctx,
                                    scheduleTimeout(completionKey, getBookieInfoTimeout)));
@@ -1594,7 +1594,7 @@ public class PerChannelBookieClient extends SimpleChannelHandler implements
Chan
 
     // visable for testing
     CompletionKey newCompletionKey(long txnId, OperationType operationType) {
-        return new CompletionKey(txnId, operationType);
+        return new V3CompletionKey(txnId, operationType);
     }
 
     Timeout scheduleTimeout(CompletionKey key, long timeout) {
@@ -1605,23 +1605,18 @@ public class PerChannelBookieClient extends SimpleChannelHandler implements
Chan
         }
     }
 
-    class CompletionKey implements TimerTask {
-        final long txnId;
-        final OperationType operationType;
-        final long requestAt;
+    class V3CompletionKey extends CompletionKey {
 
-        CompletionKey(long txnId, OperationType operationType) {
-            this.txnId = txnId;
-            this.operationType = operationType;
-            this.requestAt = MathUtils.nowInNano();
+        public V3CompletionKey(long txnId, OperationType operationType) {
+            super(txnId, operationType);
         }
 
         @Override
         public boolean equals(Object obj) {
-            if (!(obj instanceof CompletionKey)) {
+            if (!(obj instanceof V3CompletionKey)) {
                 return false;
             }
-            CompletionKey that = (CompletionKey) obj;
+            V3CompletionKey that = (V3CompletionKey) obj;
             return this.txnId == that.txnId && this.operationType == that.operationType;
         }
 
@@ -1635,6 +1630,19 @@ public class PerChannelBookieClient extends SimpleChannelHandler implements
Chan
             return String.format("TxnId(%d), OperationType(%s)", txnId, operationType);
         }
 
+    }
+
+    abstract class CompletionKey implements TimerTask {
+        final long txnId;
+        final OperationType operationType;
+        final long requestAt;
+
+        CompletionKey(long txnId, OperationType operationType) {
+            this.txnId = txnId;
+            this.operationType = operationType;
+            this.requestAt = MathUtils.nowInNano();
+        }
+
         private long elapsedTime() {
             return MathUtils.elapsedNanos(requestAt);
         }

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/83d5d9e2/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 10e0f67..d3387ce 100644
--- a/pom.xml
+++ b/pom.xml
@@ -52,7 +52,7 @@
       <plugin>
         <groupId>org.codehaus.mojo</groupId>
         <artifactId>findbugs-maven-plugin</artifactId>
-        <version>3.0.3</version>
+        <version>3.0.4</version>
       </plugin>
       <plugin>
         <artifactId>maven-compiler-plugin</artifactId>


Mime
View raw message