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-1013: Fix findbugs errors on latest master
Date Thu, 23 Mar 2017 14:55:16 GMT
Repository: bookkeeper
Updated Branches:
  refs/heads/master f20568eaa -> 3d3340be7


BOOKKEEPER-1013: Fix findbugs errors on latest master

- 100% synchronization on _explicitLac_ on FileInfo
- 100% synchronization on _length_ on LedgerHandle
- fixed the print format issue on journal dir names array
- fix checkpointsource list hashCode, equals()

Author: Sijie Guo <sijie@apache.org>

Reviewers: Enrico Olivelli <eolivelli@gmail.com>

Closes #118 from sijie/sijie/bk_1013


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

Branch: refs/heads/master
Commit: 3d3340be7d754af1738a117ee07e3bed04ec5547
Parents: f20568e
Author: Sijie Guo <sijie@apache.org>
Authored: Thu Mar 23 10:55:12 2017 -0400
Committer: Sijie Guo <sijie@apache.org>
Committed: Thu Mar 23 10:55:12 2017 -0400

----------------------------------------------------------------------
 .../bookkeeper/bookie/CheckpointSourceList.java    | 17 ++++++++++++++++-
 .../org/apache/bookkeeper/bookie/FileInfo.java     |  7 ++++---
 .../org/apache/bookkeeper/client/LedgerHandle.java |  2 +-
 .../bookkeeper/client/ReadOnlyLedgerHandle.java    | 10 ++++++----
 .../bookkeeper/conf/ServerConfiguration.java       |  3 ---
 .../org/apache/bookkeeper/proto/BookieServer.java  |  3 ++-
 .../bookkeeper/proto/PerChannelBookieClient.java   |  1 -
 .../bookkeeper/util/OrderedSafeExecutor.java       |  1 -
 8 files changed, 29 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/3d3340be/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/CheckpointSourceList.java
----------------------------------------------------------------------
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/CheckpointSourceList.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/CheckpointSourceList.java
index 3715ed2..ca42297 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/CheckpointSourceList.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/CheckpointSourceList.java
@@ -22,6 +22,7 @@ import static com.google.common.base.Preconditions.checkArgument;
 import java.io.IOException;
 import java.util.List;
 
+import com.google.common.base.Objects;
 import com.google.common.collect.Lists;
 
 public class CheckpointSourceList implements CheckpointSource {
@@ -69,6 +70,20 @@ public class CheckpointSourceList implements CheckpointSource {
         }
 
         @Override
+        public int hashCode() {
+            return Objects.hashCode(source, checkpoints);
+        }
+
+        @Override
+        public boolean equals(Object o) {
+            if (!(o instanceof CheckpointList)) {
+                return false;
+            }
+            Checkpoint other = (Checkpoint) o;
+            return 0 == compareTo(other);
+        }
+
+        @Override
         public int compareTo(Checkpoint o) {
             if (o == Checkpoint.MAX) {
                 return -1;
@@ -94,4 +109,4 @@ public class CheckpointSourceList implements CheckpointSource {
 
     }
 
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/3d3340be/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/FileInfo.java
----------------------------------------------------------------------
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/FileInfo.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/FileInfo.java
index 307b46b..adf148c 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/FileInfo.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/FileInfo.java
@@ -115,9 +115,9 @@ class FileInfo {
     }
 
     public ByteBuffer getExplicitLac() {
-        LOG.debug("fileInfo:GetLac: {}", explicitLac);
         ByteBuffer retLac = null;
         synchronized(this) {
+            LOG.debug("fileInfo:GetLac: {}", explicitLac);
             if (explicitLac != null) {
                 retLac = ByteBuffer.allocate(explicitLac.capacity());
                 explicitLac.rewind();//copy from the beginning
@@ -137,12 +137,13 @@ class FileInfo {
             explicitLac.put(lac);
             explicitLac.rewind();
             
-            long ledgerId = explicitLac.getLong();            
+            // skip the ledger id
+            explicitLac.getLong();            
             long explicitLacValue = explicitLac.getLong();
             setLastAddConfirmed(explicitLacValue);
             explicitLac.rewind();
+            LOG.debug("fileInfo:SetLac: {}", explicitLac);
         }
-        LOG.debug("fileInfo:SetLac: {}", explicitLac);
     }
 
     synchronized public void readHeader() throws IOException {

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/3d3340be/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java
----------------------------------------------------------------------
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java
index 290caa9..b68bb11 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java
@@ -245,7 +245,7 @@ public class LedgerHandle implements AutoCloseable {
      * @param delta
      * @return the length of the ledger after the addition
      */
-    long addToLength(long delta) {
+    synchronized long addToLength(long delta) {
         this.length += delta;
         return this.length;
     }

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/3d3340be/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/ReadOnlyLedgerHandle.java
----------------------------------------------------------------------
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/ReadOnlyLedgerHandle.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/ReadOnlyLedgerHandle.java
index 1834eff..ae17c7f 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/ReadOnlyLedgerHandle.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/ReadOnlyLedgerHandle.java
@@ -54,11 +54,13 @@ class ReadOnlyLedgerHandle extends LedgerHandle implements LedgerMetadataListene
                     ReadOnlyLedgerHandle.this.metadata.getVersion().compare(this.m.getVersion());
             if (Version.Occurred.BEFORE == occurred) {
                 LOG.info("Updated ledger metadata for ledger {} to {}.", ledgerId, this.m);
-                if (this.m.isClosed()) {
-                        ReadOnlyLedgerHandle.this.lastAddConfirmed = this.m.getLastEntryId();
-                        ReadOnlyLedgerHandle.this.length = this.m.getLength();
+                synchronized (ReadOnlyLedgerHandle.this) {
+                    if (this.m.isClosed()) {
+                            ReadOnlyLedgerHandle.this.lastAddConfirmed = this.m.getLastEntryId();
+                            ReadOnlyLedgerHandle.this.length = this.m.getLength();
+                    }
+                    ReadOnlyLedgerHandle.this.metadata = this.m;
                 }
-                ReadOnlyLedgerHandle.this.metadata = this.m;
             }
         }
 

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/3d3340be/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ServerConfiguration.java
----------------------------------------------------------------------
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ServerConfiguration.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ServerConfiguration.java
index 986f9ed..2f8bb9a 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ServerConfiguration.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ServerConfiguration.java
@@ -628,9 +628,6 @@ public class ServerConfiguration extends AbstractConfiguration {
      */
     public File[] getJournalDirs() {
         String[] journalDirNames = getJournalDirNames();
-        if (null == journalDirNames) {
-            return null;
-        }
         File[] journalDirs = new File[journalDirNames.length];
         for(int i=0 ;i<journalDirNames.length; i++) {
             journalDirs[i] = new File(journalDirNames[i]);

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/3d3340be/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieServer.java
----------------------------------------------------------------------
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieServer.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieServer.java
index b38c22a..7f437ff 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieServer.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieServer.java
@@ -25,6 +25,7 @@ import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.UnknownHostException;
 import java.lang.Integer;
+import java.util.Arrays;
 
 import org.apache.bookkeeper.bookie.Bookie;
 import org.apache.bookkeeper.bookie.ReadOnlyBookie;
@@ -420,7 +421,7 @@ public class BookieServer {
         String hello = String.format(
                            "Hello, I'm your bookie, listening on port %1$s. ZKServers are
on %2$s. Journals are in %3$s. Ledgers are stored in %4$s.",
                            conf.getBookiePort(), conf.getZkServers(),
-                           conf.getJournalDirNames(), sb);
+                           Arrays.asList(conf.getJournalDirNames()), sb);
         LOG.info(hello);
         try {
             // Initialize Stats Provider

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/3d3340be/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 9d32ff8..580a905 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
@@ -387,7 +387,6 @@ 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 int entrySize = toSend.readableBytes();
         final CompletionKey completionKey = new CompletionKey(txnId, OperationType.WRITE_LAC);
         // writeLac is mostly like addEntry hence uses addEntryTimeout
         completionObjects.put(completionKey,

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/3d3340be/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/OrderedSafeExecutor.java
----------------------------------------------------------------------
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/OrderedSafeExecutor.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/OrderedSafeExecutor.java
index 64e524d..7b4499f 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/OrderedSafeExecutor.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/OrderedSafeExecutor.java
@@ -183,7 +183,6 @@ public class OrderedSafeExecutor {
                         .setNameFormat(name + "-orderedsafeexecutor-" + i + "-%d")
                         .setThreadFactory(threadFactory)
                         .build());
-            threads[i].setMaximumPoolSize(1);
 
             // Save thread ids
             final int idx = i;


Mime
View raw message