This is an automated email from the ASF dual-hosted git repository.
zhaijia pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git
The following commit(s) were added to refs/heads/master by this push:
new 257c216 ISSUE #230: Enable checkstyle for more packages
257c216 is described below
commit 257c21630ab93b6adccbf955899451bd550a1d07
Author: Aaron Coburn <[email protected]>
AuthorDate: Sat Dec 2 19:47:01 2017 +0800
ISSUE #230: Enable checkstyle for more packages
Part of #230, this enables the checkstyle plugin for the `replication` and
`server.http.service` packages.
Descriptions of the changes in this PR:
Most of the changes here are merely cosmetic. The only change of any
significance is in the `RecoveryBookieService.RecoveryRequestJsonBody` class in
which the JSON object fields had to be changed in order to conform to the
Checkstyle rules: `bookie_src` to `bookieSrc` and `delete_cookie` to
`deleteCookie`. Using a Jackson annotation (`JsonProperty`), however, means
that these field names continue to be parsed and serialized as `bookie_src` and
`delete_cookie`, respectively.
Author: Jia Zhai <[email protected]>
Author: Aaron Coburn <[email protected]>
Reviewers: Jia Zhai <None>, Sijie Guo <[email protected]>
This closes #800 from acoburn/checkstyle_replication, closes #230
---
.../org/apache/bookkeeper/replication/Auditor.java | 68 +++++++++++-----------
.../bookkeeper/replication/AuditorElector.java | 39 ++++++-------
.../bookkeeper/replication/AutoRecoveryMain.java | 16 ++---
.../replication/BookieLedgerIndexer.java | 3 +-
.../replication/ReplicationEnableCb.java | 4 +-
.../replication/ReplicationException.java | 6 +-
.../bookkeeper/replication/ReplicationStats.java | 45 +++++++-------
.../bookkeeper/replication/ReplicationWorker.java | 54 +++++++++--------
.../bookkeeper/replication/package-info.java | 23 ++++++++
.../server/http/service/ConfigurationService.java | 9 +--
.../server/http/service/DecommissionService.java | 6 +-
.../server/http/service/DeleteLedgerService.java | 5 +-
.../server/http/service/ExpandStorageService.java | 7 ++-
.../server/http/service/GetLastLogMarkService.java | 13 +++--
.../server/http/service/GetLedgerMetaService.java | 4 +-
.../server/http/service/ListBookieInfoService.java | 9 ++-
.../server/http/service/ListBookiesService.java | 19 +++---
.../server/http/service/ListDiskFilesService.java | 24 ++++----
.../server/http/service/ListLedgerService.java | 31 +++++-----
.../service/ListUnderReplicatedLedgerService.java | 9 ++-
.../service/LostBookieRecoveryDelayService.java | 8 ++-
.../http/service/ReadLedgerEntryService.java | 9 +--
.../server/http/service/RecoveryBookieService.java | 30 ++++++----
.../server/http/service/TriggerAuditService.java | 5 +-
.../server/http/service/WhoIsAuditorService.java | 7 ++-
.../resources/bookkeeper/server-suppressions.xml | 2 -
26 files changed, 260 insertions(+), 195 deletions(-)
diff --git
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/Auditor.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/Auditor.java
index 7a10e0b..778ce8a 100644
---
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/Auditor.java
+++
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/Auditor.java
@@ -24,6 +24,7 @@ import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Stopwatch;
import com.google.common.collect.Sets;
import com.google.common.util.concurrent.SettableFuture;
+
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
@@ -37,6 +38,7 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
+
import org.apache.bookkeeper.client.BKException;
import org.apache.bookkeeper.client.BookKeeper;
import org.apache.bookkeeper.client.BookKeeperAdmin;
@@ -96,7 +98,7 @@ public class Auditor {
private volatile Future<?> auditTask;
private Set<String> bookiesToBeAudited = Sets.newHashSet();
private volatile int lostBookieRecoveryDelayBeforeChange;
-
+
public Auditor(final String bookieIdentifier, ServerConfiguration conf,
ZooKeeper zkc, StatsLogger statsLogger) throws
UnavailableException {
this.conf = conf;
@@ -141,7 +143,8 @@ public class Auditor {
ClientConfiguration clientConfiguration = new
ClientConfiguration(conf);
clientConfiguration.setClientRole(ClientConfiguration.CLIENT_ROLE_SYSTEM);
- LOG.info("AuthProvider used by the Auditor is
"+clientConfiguration.getClientAuthProviderFactoryClass());
+ LOG.info("AuthProvider used by the Auditor is {}",
+ clientConfiguration.getClientAuthProviderFactoryClass());
this.bkc = new BookKeeper(clientConfiguration, zkc);
this.admin = new BookKeeperAdmin(bkc, statsLogger);
if (this.ledgerUnderreplicationManager
@@ -149,8 +152,8 @@ public class Auditor {
LOG.info("Initializing lostBookieRecoveryDelay zNode to the
conif value: {}",
conf.getLostBookieRecoveryDelay());
} else {
- LOG.info(
- "Valid lostBookieRecoveryDelay zNode is available, so
not creating lostBookieRecoveryDelay zNode as part of Auditor initialization ");
+ LOG.info("Valid lostBookieRecoveryDelay zNode is available, so
not creating "
+ + "lostBookieRecoveryDelay zNode as part of Auditor
initialization ");
}
lostBookieRecoveryDelayBeforeChange =
this.ledgerUnderreplicationManager.getLostBookieRecoveryDelay();
} catch (CompatibilityException ce) {
@@ -229,9 +232,10 @@ public class Auditor {
}
if (bookiesToBeAudited.size() > 1) {
// if more than one bookie is down, start the
audit immediately;
- LOG.info("Multiple bookie failure; not delaying
bookie audit. Bookies lost now: "
- + CollectionUtils.subtract(knownBookies,
availableBookies)
- +"; All lost bookies: " +
bookiesToBeAudited.toString());
+ LOG.info("Multiple bookie failure; not delaying
bookie audit. "
+ + "Bookies lost now: {}; All lost bookies:
{}",
+ CollectionUtils.subtract(knownBookies,
availableBookies),
+ bookiesToBeAudited);
if (auditTask != null && auditTask.cancel(false)) {
auditTask = null;
numDelayedBookieAuditsCancelled.inc();
@@ -242,7 +246,7 @@ public class Auditor {
}
if (auditTask == null) {
// if there is no scheduled audit, schedule one
- auditTask = executor.schedule( new Runnable() {
+ auditTask = executor.schedule(new Runnable() {
public void run() {
startAudit(false);
auditTask = null;
@@ -250,8 +254,8 @@ public class Auditor {
}
}, lostBookieRecoveryDelay, TimeUnit.SECONDS);
numBookieAuditsDelayed.inc();
- LOG.info("Delaying bookie audit by " +
lostBookieRecoveryDelay
- + "secs for " +
bookiesToBeAudited.toString());
+ LOG.info("Delaying bookie audit by {} secs for
{}", lostBookieRecoveryDelay,
+ bookiesToBeAudited);
}
} catch (BKException bke) {
LOG.error("Exception getting bookie list", bke);
@@ -282,7 +286,7 @@ public class Auditor {
// after new lostBookieRecoveryDelay period
if (auditTask != null) {
LOG.info("lostBookieRecoveryDelay period has been
changed so canceling the pending AuditTask");
- auditTask.cancel(false);
+ auditTask.cancel(false);
numDelayedBookieAuditsCancelled.inc();
}
@@ -291,12 +295,13 @@ public class Auditor {
if ((lostBookieRecoveryDelay == 0)
|| (lostBookieRecoveryDelay ==
lostBookieRecoveryDelayBeforeChange)) {
LOG.info(
- "lostBookieRecoveryDelay has been set to 0 or
reset to its previos value, so starting AuditTask. "
- + "Current lostBookieRecoveryDelay: {},
previous lostBookieRecoveryDelay: {}",
+ "lostBookieRecoveryDelay has been set to 0 or
reset to its previous value, "
+ + "so starting AuditTask. Current
lostBookieRecoveryDelay: {}, "
+ + "previous lostBookieRecoveryDelay: {}",
lostBookieRecoveryDelay,
lostBookieRecoveryDelayBeforeChange);
startAudit(false);
auditTask = null;
- bookiesToBeAudited.clear();
+ bookiesToBeAudited.clear();
} else if (auditTask != null) {
LOG.info("lostBookieRecoveryDelay has been set to {},
so rescheduling AuditTask accordingly",
lostBookieRecoveryDelay);
@@ -308,13 +313,13 @@ public class Auditor {
}
}, lostBookieRecoveryDelay, TimeUnit.SECONDS);
numBookieAuditsDelayed.inc();
- }
+ }
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
LOG.error("Interrupted while for LedgersReplication to be
enabled ", ie);
} catch (UnavailableException ue) {
LOG.error("Exception while reading from ZK", ue);
- } finally{
+ } finally {
if (lostBookieRecoveryDelay != -1) {
lostBookieRecoveryDelayBeforeChange =
lostBookieRecoveryDelay;
}
@@ -362,8 +367,7 @@ public class Auditor {
} catch (IOException ioe) {
LOG.error("I/O exception running periodic
check", ioe);
} catch (ReplicationException.UnavailableException
ue) {
- LOG.error("Underreplication manager
unavailable "
- +"running periodic check", ue);
+ LOG.error("Underreplication manager
unavailable running periodic check", ue);
}
}
}, interval, interval, TimeUnit.SECONDS);
@@ -377,7 +381,7 @@ public class Auditor {
LOG.error("Couldn't get bookie list, exiting", bke);
submitShutdownTask();
}
-
+
try {
this.ledgerUnderreplicationManager
.notifyLostBookieRecoveryDelayChanged(new
LostBookieRecoveryDelayChangedCb());
@@ -389,11 +393,11 @@ public class Auditor {
long bookieCheckInterval =
conf.getAuditorPeriodicBookieCheckInterval();
if (bookieCheckInterval == 0) {
LOG.info("Auditor periodic bookie checking disabled, running
once check now anyhow");
- executor.submit(BOOKIE_CHECK);
+ executor.submit(bookieCheck);
} else {
LOG.info("Auditor periodic bookie checking enabled"
+ " 'auditorPeriodicBookieCheckInterval' {} seconds",
bookieCheckInterval);
- executor.scheduleAtFixedRate(BOOKIE_CHECK, 0,
bookieCheckInterval, TimeUnit.SECONDS);
+ executor.scheduleAtFixedRate(bookieCheck, 0,
bookieCheckInterval, TimeUnit.SECONDS);
}
}
}
@@ -410,7 +414,7 @@ public class Auditor {
Auditor.this.submitLostBookieRecoveryDelayChangedEvent();
}
}
-
+
private void waitIfLedgerReplicationDisabled() throws UnavailableException,
InterruptedException {
ReplicationEnableCb cb = new ReplicationEnableCb();
@@ -439,7 +443,7 @@ public class Auditor {
}
/**
- * Start running the actual audit task
+ * Start running the actual audit task.
*
* @param shutDownTask
* A boolean that indicates whether or not to schedule shutdown task
on any failure
@@ -482,7 +486,7 @@ public class Auditor {
if (!ledgerUnderreplicationManager.isLedgerReplicationEnabled()) {
// has been disabled while we were generating the index
// discard this run, and schedule a new one
- executor.submit(BOOKIE_CHECK);
+ executor.submit(bookieCheck);
return;
}
} catch (UnavailableException ue) {
@@ -529,11 +533,10 @@ public class Auditor {
if (null == ledgers || ledgers.size() == 0) {
// there is no ledgers available for this bookie and just
// ignoring the bookie failures
- LOG.info("There is no ledgers for the failed bookie: " + bookieIP);
+ LOG.info("There is no ledgers for the failed bookie: {}",
bookieIP);
return;
}
- LOG.info("Following ledgers: " + ledgers + " of bookie: " + bookieIP
- + " are identified as underreplicated");
+ LOG.info("Following ledgers: {} of bookie: {} are identified as
underreplicated", ledgers, bookieIP);
numUnderReplicatedLedger.registerSuccessfulValue(ledgers.size());
for (Long ledgerId : ledgers) {
try {
@@ -548,7 +551,7 @@ public class Auditor {
}
/**
- * Process the result returned from checking a ledger
+ * Process the result returned from checking a ledger.
*/
private class ProcessLostFragmentsCb implements
GenericCallback<Set<LedgerFragment>> {
final LedgerHandle lh;
@@ -625,8 +628,7 @@ public class Auditor {
return;
}
} catch (ReplicationException.UnavailableException ue) {
- LOG.error("Underreplication manager unavailable "
- +"running periodic check", ue);
+ LOG.error("Underreplication manager unavailable
running periodic check", ue);
processDone.countDown();
return;
}
@@ -699,7 +701,7 @@ public class Auditor {
}
/**
- * Shutdown the auditor
+ * Shutdown the auditor.
*/
public void shutdown() {
LOG.info("Shutting down auditor");
@@ -721,7 +723,7 @@ public class Auditor {
}
/**
- * Return true if auditor is running otherwise return false
+ * Return true if auditor is running otherwise return false.
*
* @return auditor status
*/
@@ -729,7 +731,7 @@ public class Auditor {
return !executor.isShutdown();
}
- private final Runnable BOOKIE_CHECK = new Runnable() {
+ private final Runnable bookieCheck = new Runnable() {
public void run() {
if (auditTask == null) {
startAudit(true);
diff --git
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AuditorElector.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AuditorElector.java
index fe6c10b..aca74c5 100644
---
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AuditorElector.java
+++
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AuditorElector.java
@@ -20,44 +20,43 @@
*/
package org.apache.bookkeeper.replication;
+import static com.google.common.base.Charsets.UTF_8;
+import static
org.apache.bookkeeper.replication.ReplicationStats.ELECTION_ATTEMPTS;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.protobuf.TextFormat;
+
+import java.io.IOException;
+import java.io.Serializable;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
-import java.io.Serializable;
-import java.io.IOException;
-
-import org.apache.bookkeeper.proto.DataFormats.AuditorVoteFormat;
-import com.google.common.annotations.VisibleForTesting;
-import java.util.concurrent.Executors;
import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicBoolean;
-import org.apache.bookkeeper.net.BookieSocketAddress;
import org.apache.bookkeeper.conf.ServerConfiguration;
+import org.apache.bookkeeper.net.BookieSocketAddress;
+import org.apache.bookkeeper.proto.DataFormats.AuditorVoteFormat;
import
org.apache.bookkeeper.replication.ReplicationException.UnavailableException;
import org.apache.bookkeeper.stats.Counter;
import org.apache.bookkeeper.stats.NullStatsLogger;
import org.apache.bookkeeper.stats.StatsLogger;
import org.apache.bookkeeper.util.BookKeeperConstants;
+import org.apache.bookkeeper.util.ZkUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
-import org.apache.zookeeper.ZooKeeper;
import org.apache.zookeeper.Watcher.Event.EventType;
import org.apache.zookeeper.Watcher.Event.KeeperState;
-import com.google.protobuf.TextFormat;
-import static com.google.common.base.Charsets.UTF_8;
-
+import org.apache.zookeeper.ZooKeeper;
+import org.apache.zookeeper.data.ACL;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static
org.apache.bookkeeper.replication.ReplicationStats.ELECTION_ATTEMPTS;
-import org.apache.bookkeeper.util.ZkUtils;
-import org.apache.zookeeper.data.ACL;
-
/**
* Performing auditor election using Apache ZooKeeper. Using ZooKeeper as a
* coordination service, when a bookie bids for auditor, it creates an
ephemeral
@@ -97,7 +96,7 @@ public class AuditorElector {
/**
- * AuditorElector for performing the auditor election
+ * AuditorElector for performing the auditor election.
*
* @param bookieId
* - bookie identifier, comprises HostAddress:Port
@@ -114,7 +113,7 @@ public class AuditorElector {
}
/**
- * AuditorElector for performing the auditor election
+ * AuditorElector for performing the auditor election.
*
* @param bookieId
* - bookie identifier, comprises HostAddress:Port
@@ -141,7 +140,7 @@ public class AuditorElector {
executor = Executors.newSingleThreadExecutor(new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
- return new Thread(r, "AuditorElector-"+bookieId);
+ return new Thread(r, "AuditorElector-" + bookieId);
}
});
}
@@ -310,7 +309,7 @@ public class AuditorElector {
}
/**
- * Query zookeeper for the currently elected auditor
+ * Query zookeeper for the currently elected auditor.
* @return the bookie id of the current auditor
*/
public static BookieSocketAddress getCurrentAuditor(ServerConfiguration
conf, ZooKeeper zk)
@@ -335,7 +334,7 @@ public class AuditorElector {
}
/**
- * Shutting down AuditorElector
+ * Shutting down AuditorElector.
*/
public void shutdown() throws InterruptedException {
synchronized (this) {
diff --git
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AutoRecoveryMain.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AutoRecoveryMain.java
index c818c62..d25e4d3 100644
---
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AutoRecoveryMain.java
+++
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AutoRecoveryMain.java
@@ -20,21 +20,26 @@
*/
package org.apache.bookkeeper.replication;
+import static org.apache.bookkeeper.replication.ReplicationStats.AUDITOR_SCOPE;
+import static
org.apache.bookkeeper.replication.ReplicationStats.REPLICATION_WORKER_SCOPE;
+
import com.google.common.annotations.VisibleForTesting;
+
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.HashSet;
import java.util.Set;
+
import org.apache.bookkeeper.bookie.Bookie;
import org.apache.bookkeeper.bookie.BookieCriticalThread;
import org.apache.bookkeeper.bookie.ExitCode;
import org.apache.bookkeeper.conf.ServerConfiguration;
-import org.apache.bookkeeper.server.http.BKHttpServiceProvider;
import org.apache.bookkeeper.http.HttpServer;
import org.apache.bookkeeper.http.HttpServerLoader;
import
org.apache.bookkeeper.replication.ReplicationException.CompatibilityException;
import
org.apache.bookkeeper.replication.ReplicationException.UnavailableException;
+import org.apache.bookkeeper.server.http.BKHttpServiceProvider;
import org.apache.bookkeeper.stats.NullStatsLogger;
import org.apache.bookkeeper.stats.StatsLogger;
import org.apache.bookkeeper.zookeeper.ZooKeeperClient;
@@ -51,11 +56,8 @@ import org.apache.zookeeper.ZooKeeper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.apache.bookkeeper.replication.ReplicationStats.AUDITOR_SCOPE;
-import static
org.apache.bookkeeper.replication.ReplicationStats.REPLICATION_WORKER_SCOPE;
-
/**
- * Class to start/stop the AutoRecovery daemons Auditor and ReplicationWorker
+ * Class to start/stop the AutoRecovery daemons Auditor and ReplicationWorker.
*/
public class AutoRecoveryMain {
private static final Logger LOG = LoggerFactory
@@ -107,8 +109,8 @@ public class AutoRecoveryMain {
deathWatcher = new AutoRecoveryDeathWatcher(this);
}
- public AutoRecoveryMain(ServerConfiguration conf, ZooKeeper zk) throws
IOException, InterruptedException, KeeperException,
- UnavailableException, CompatibilityException {
+ public AutoRecoveryMain(ServerConfiguration conf, ZooKeeper zk) throws
IOException, InterruptedException,
+ KeeperException, UnavailableException, CompatibilityException {
this.conf = conf;
this.zk = zk;
auditorElector = new
AuditorElector(Bookie.getBookieAddress(conf).toString(), conf, zk);
diff --git
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/BookieLedgerIndexer.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/BookieLedgerIndexer.java
index e28137e..b7b4285 100644
---
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/BookieLedgerIndexer.java
+++
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/BookieLedgerIndexer.java
@@ -61,8 +61,7 @@ public class BookieLedgerIndexer {
public Map<String, Set<Long>> getBookieToLedgerIndex()
throws BKAuditException {
// bookie vs ledgers map
- final ConcurrentHashMap<String, Set<Long>> bookie2ledgersMap
- = new ConcurrentHashMap<String, Set<Long>>();
+ final ConcurrentHashMap<String, Set<Long>> bookie2ledgersMap = new
ConcurrentHashMap<String, Set<Long>>();
final CountDownLatch ledgerCollectorLatch = new CountDownLatch(1);
Processor<Long> ledgerProcessor = new Processor<Long>() {
diff --git
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationEnableCb.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationEnableCb.java
index b50927c..36672b3 100644
---
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationEnableCb.java
+++
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationEnableCb.java
@@ -27,7 +27,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Callback which is getting notified when the replication process is enabled
+ * Callback which is getting notified when the replication process is enabled.
*/
public class ReplicationEnableCb implements GenericCallback<Void> {
@@ -45,7 +45,7 @@ public class ReplicationEnableCb implements
GenericCallback<Void> {
/**
* This is a blocking call and causes the current thread to wait until the
- * replication process is enabled
+ * replication process is enabled.
*
* @throws InterruptedException
* interrupted while waiting
diff --git
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationException.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationException.java
index 2ff7b94..1afee69 100644
---
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationException.java
+++
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationException.java
@@ -19,7 +19,7 @@
package org.apache.bookkeeper.replication;
/**
- * Exceptions for use within the replication service
+ * Exceptions for use within the replication service.
*/
public abstract class ReplicationException extends Exception {
protected ReplicationException(String message, Throwable cause) {
@@ -31,7 +31,7 @@ public abstract class ReplicationException extends Exception {
}
/**
- * The replication service has become unavailable
+ * The replication service has become unavailable.
*/
public static class UnavailableException extends ReplicationException {
private static final long serialVersionUID = 31872209L;
@@ -62,7 +62,7 @@ public abstract class ReplicationException extends Exception {
}
/**
- * Exception while auditing bookie-ledgers
+ * Exception while auditing bookie-ledgers.
*/
public static class BKAuditException extends ReplicationException {
private static final long serialVersionUID = 95551905L;
diff --git
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationStats.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationStats.java
index 0b48e33..4f48b78 100644
---
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationStats.java
+++
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationStats.java
@@ -20,31 +20,34 @@
*/
package org.apache.bookkeeper.replication;
+/**
+ * Replication statistics.
+ */
public interface ReplicationStats {
- public final static String REPLICATION_SCOPE = "replication";
+ String REPLICATION_SCOPE = "replication";
- public final static String AUDITOR_SCOPE = "auditor";
- public final static String ELECTION_ATTEMPTS = "election_attempts";
- public final static String NUM_UNDER_REPLICATED_LEDGERS =
"NUM_UNDER_REPLICATED_LEDGERS";
- public final static String URL_PUBLISH_TIME_FOR_LOST_BOOKIE =
"URL_PUBLISH_TIME_FOR_LOST_BOOKIE";
- public final static String BOOKIE_TO_LEDGERS_MAP_CREATION_TIME =
"BOOKIE_TO_LEDGERS_MAP_CREATION_TIME";
- public final static String CHECK_ALL_LEDGERS_TIME =
"CHECK_ALL_LEDGERS_TIME";
- public final static String NUM_FRAGMENTS_PER_LEDGER =
"NUM_FRAGMENTS_PER_LEDGER";
- public final static String NUM_BOOKIES_PER_LEDGER =
"NUM_BOOKIES_PER_LEDGER";
- public final static String NUM_LEDGERS_CHECKED = "NUM_LEDGERS_CHECKED";
- public final static String NUM_BOOKIE_AUDITS_DELAYED =
"NUM_BOOKIE_AUDITS_DELAYED";
- public final static String NUM_DELAYED_BOOKIE_AUDITS_DELAYES_CANCELLED =
"NUM_DELAYED_BOOKIE_AUDITS_CANCELLED";
+ String AUDITOR_SCOPE = "auditor";
+ String ELECTION_ATTEMPTS = "election_attempts";
+ String NUM_UNDER_REPLICATED_LEDGERS = "NUM_UNDER_REPLICATED_LEDGERS";
+ String URL_PUBLISH_TIME_FOR_LOST_BOOKIE =
"URL_PUBLISH_TIME_FOR_LOST_BOOKIE";
+ String BOOKIE_TO_LEDGERS_MAP_CREATION_TIME =
"BOOKIE_TO_LEDGERS_MAP_CREATION_TIME";
+ String CHECK_ALL_LEDGERS_TIME = "CHECK_ALL_LEDGERS_TIME";
+ String NUM_FRAGMENTS_PER_LEDGER = "NUM_FRAGMENTS_PER_LEDGER";
+ String NUM_BOOKIES_PER_LEDGER = "NUM_BOOKIES_PER_LEDGER";
+ String NUM_LEDGERS_CHECKED = "NUM_LEDGERS_CHECKED";
+ String NUM_BOOKIE_AUDITS_DELAYED = "NUM_BOOKIE_AUDITS_DELAYED";
+ String NUM_DELAYED_BOOKIE_AUDITS_DELAYES_CANCELLED =
"NUM_DELAYED_BOOKIE_AUDITS_CANCELLED";
- public final static String REPLICATION_WORKER_SCOPE = "replication_worker";
- public final static String REREPLICATE_OP = "rereplicate";
- public final static String NUM_FULL_OR_PARTIAL_LEDGERS_REPLICATED =
"NUM_FULL_OR_PARTIAL_LEDGERS_REPLICATED";
- public final static String NUM_ENTRIES_READ = "NUM_ENTRIES_READ";
- public final static String NUM_BYTES_READ = "NUM_BYTES_READ";
- public final static String NUM_ENTRIES_WRITTEN = "NUM_ENTRIES_WRITTEN";
- public final static String NUM_BYTES_WRITTEN = "NUM_BYTES_WRITTEN";
- public final static String REPLICATE_EXCEPTION = "exceptions";
+ String REPLICATION_WORKER_SCOPE = "replication_worker";
+ String REREPLICATE_OP = "rereplicate";
+ String NUM_FULL_OR_PARTIAL_LEDGERS_REPLICATED =
"NUM_FULL_OR_PARTIAL_LEDGERS_REPLICATED";
+ String NUM_ENTRIES_READ = "NUM_ENTRIES_READ";
+ String NUM_BYTES_READ = "NUM_BYTES_READ";
+ String NUM_ENTRIES_WRITTEN = "NUM_ENTRIES_WRITTEN";
+ String NUM_BYTES_WRITTEN = "NUM_BYTES_WRITTEN";
+ String REPLICATE_EXCEPTION = "exceptions";
- public final static String BK_CLIENT_SCOPE = "bk_client";
+ String BK_CLIENT_SCOPE = "bk_client";
}
diff --git
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationWorker.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationWorker.java
index cd79afd..b3adc0a 100644
---
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationWorker.java
+++
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationWorker.java
@@ -19,25 +19,29 @@
*/
package org.apache.bookkeeper.replication;
+import static
org.apache.bookkeeper.replication.ReplicationStats.BK_CLIENT_SCOPE;
+import static
org.apache.bookkeeper.replication.ReplicationStats.NUM_FULL_OR_PARTIAL_LEDGERS_REPLICATED;
+import static
org.apache.bookkeeper.replication.ReplicationStats.REPLICATE_EXCEPTION;
+import static
org.apache.bookkeeper.replication.ReplicationStats.REREPLICATE_OP;
+
import com.google.common.base.Stopwatch;
+
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
+import java.util.SortedMap;
import java.util.Timer;
import java.util.TimerTask;
-import java.util.SortedMap;
-import java.util.ArrayList;
-import java.util.Collection;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
+
import org.apache.bookkeeper.bookie.BookieThread;
import org.apache.bookkeeper.client.BKException;
-import
org.apache.bookkeeper.client.BKException.BKBookieHandleNotAvailableException;
-import org.apache.bookkeeper.client.BKException.BKLedgerRecoveryException;
import org.apache.bookkeeper.client.BKException.BKNoSuchLedgerExistsException;
import org.apache.bookkeeper.client.BKException.BKNotEnoughBookiesException;
-import org.apache.bookkeeper.client.BKException.BKReadException;
import org.apache.bookkeeper.client.BookKeeper;
import org.apache.bookkeeper.client.BookKeeperAdmin;
import org.apache.bookkeeper.client.LedgerChecker;
@@ -61,11 +65,6 @@ import org.apache.zookeeper.ZooKeeper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static
org.apache.bookkeeper.replication.ReplicationStats.BK_CLIENT_SCOPE;
-import static
org.apache.bookkeeper.replication.ReplicationStats.NUM_FULL_OR_PARTIAL_LEDGERS_REPLICATED;
-import static
org.apache.bookkeeper.replication.ReplicationStats.REPLICATE_EXCEPTION;
-import static
org.apache.bookkeeper.replication.ReplicationStats.REREPLICATE_OP;
-
/**
* ReplicationWorker will take the fragments one by one from
* ZKLedgerUnderreplicationManager and replicates to it.
@@ -89,7 +88,7 @@ public class ReplicationWorker implements Runnable {
private final StatsLogger statsLogger;
private final OpStatsLogger rereplicateOpStats;
private final Counter numLedgersReplicated;
- private final Map<String,Counter> exceptionCounters;
+ private final Map<String, Counter> exceptionCounters;
/**
* Replication worker for replicating the ledger fragments from
@@ -154,7 +153,9 @@ public class ReplicationWorker implements Runnable {
this.exceptionCounters = new HashMap<String, Counter>();
}
- /** Start the replication worker */
+ /**
+ * Start the replication worker.
+ */
public void start() {
this.workerThread.start();
}
@@ -192,7 +193,7 @@ public class ReplicationWorker implements Runnable {
/**
* Replicates the under replicated fragments from failed bookie ledger to
- * targetBookie
+ * targetBookie.
*/
private void rereplicate() throws InterruptedException, BKException,
UnavailableException {
@@ -298,18 +299,18 @@ public class ReplicationWorker implements Runnable {
* taken. This is fine, until enough bookies fail to cause a quorum to
become
* unavailable, by which time the ledger is unrecoverable.
*
- * For example, if in a E3Q2, only 1 entry is written and the last bookie
+ * <p>For example, if in a E3Q2, only 1 entry is written and the last
bookie
* in the ensemble fails, nothing has been written to it, so nothing needs
to be
* recovered. But if the second to last bookie fails, we've now lost
quorum for
* the second entry, so it's impossible to see if the second has been
written or
* not.
*
- * To avoid this situation, we need to check if bookies in the final open
ensemble
+ * <p>To avoid this situation, we need to check if bookies in the final
open ensemble
* are unavailable, and take action if so. The action to take is to close
the ledger,
* after a grace period as the writting client may replace the faulty
bookie on its
* own.
*
- * Missing bookies in closed ledgers are fine, as we know the last
confirmed add, so
+ * <p>Missing bookies in closed ledgers are fine, as we know the last
confirmed add, so
* we can tell which entries are supposed to exist and rereplicate them if
necessary.
*/
private boolean isLastSegmentOpenAndMissingBookies(LedgerHandle lh) throws
BKException {
@@ -318,8 +319,7 @@ public class ReplicationWorker implements Runnable {
return false;
}
- SortedMap<Long, ArrayList<BookieSocketAddress>> ensembles
- = admin.getLedgerMetadata(lh).getEnsembles();
+ SortedMap<Long, ArrayList<BookieSocketAddress>> ensembles =
admin.getLedgerMetadata(lh).getEnsembles();
ArrayList<BookieSocketAddress> finalEnsemble =
ensembles.get(ensembles.lastKey());
Collection<BookieSocketAddress> available =
admin.getAvailableBookies();
for (BookieSocketAddress b : finalEnsemble) {
@@ -330,7 +330,9 @@ public class ReplicationWorker implements Runnable {
return false;
}
- /** Gets the under replicated fragments */
+ /**
+ * Gets the under replicated fragments.
+ */
private Set<LedgerFragment> getUnderreplicatedFragments(LedgerHandle lh)
throws InterruptedException {
CheckerCallback checkerCb = new CheckerCallback();
@@ -342,7 +344,7 @@ public class ReplicationWorker implements Runnable {
/**
* Schedules a timer task for releasing the lock which will be scheduled
* after open ledger fragment replication time. Ledger will be fenced if it
- * is still in open state when timer task fired
+ * is still in open state when timer task fired.
*/
private void deferLedgerLockRelease(final long ledgerId) {
long gracePeriod = this.openLedgerRereplicationGracePeriod;
@@ -405,7 +407,7 @@ public class ReplicationWorker implements Runnable {
}
/**
- * Stop the replication worker service
+ * Stop the replication worker service.
*/
public void shutdown() {
LOG.info("Shutting down replication worker");
@@ -443,13 +445,15 @@ public class ReplicationWorker implements Runnable {
}
/**
- * Gives the running status of ReplicationWorker
+ * Gives the running status of ReplicationWorker.
*/
boolean isRunning() {
return workerRunning && workerThread.isAlive();
}
- /** Ledger checker call back */
+ /**
+ * Ledger checker call back.
+ */
private static class CheckerCallback implements
GenericCallback<Set<LedgerFragment>> {
private Set<LedgerFragment> result = null;
@@ -463,7 +467,7 @@ public class ReplicationWorker implements Runnable {
/**
* Wait until operation complete call back comes and return the ledger
- * fragments set
+ * fragments set.
*/
Set<LedgerFragment> waitAndGetResult() throws InterruptedException {
latch.await();
diff --git
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/package-info.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/package-info.java
new file mode 100644
index 0000000..161ae91
--- /dev/null
+++
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/package-info.java
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+/**
+ * Classes for replicating Bookkeeper data.
+ */
+package org.apache.bookkeeper.replication;
diff --git
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ConfigurationService.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ConfigurationService.java
index 0a8e8a3..983da4a 100644
---
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ConfigurationService.java
+++
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ConfigurationService.java
@@ -18,7 +18,8 @@
*/
package org.apache.bookkeeper.server.http.service;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -38,7 +39,7 @@ public class ConfigurationService implements
HttpEndpointService {
protected ServerConfiguration conf;
public ConfigurationService(ServerConfiguration conf) {
- Preconditions.checkNotNull(conf);
+ checkNotNull(conf);
this.conf = conf;
}
@@ -53,14 +54,14 @@ public class ConfigurationService implements
HttpEndpointService {
return response;
} else if (HttpServer.Method.PUT == request.getMethod()) {
String requestBody = request.getBody();
- if(null == requestBody) {
+ if (null == requestBody) {
response.setCode(HttpServer.StatusCode.NOT_FOUND);
response.setBody("Request body not found. should contains k-v
pairs");
return response;
}
@SuppressWarnings("unchecked")
HashMap<String, Object> configMap = JsonUtil.fromJson(requestBody,
HashMap.class);
- for(Map.Entry<String, Object> entry: configMap.entrySet()) {
+ for (Map.Entry<String, Object> entry: configMap.entrySet()) {
conf.setProperty(entry.getKey(), entry.getValue());
}
diff --git
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/DecommissionService.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/DecommissionService.java
index dd3f764..ea05f6e 100644
---
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/DecommissionService.java
+++
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/DecommissionService.java
@@ -18,9 +18,11 @@
*/
package org.apache.bookkeeper.server.http.service;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import java.util.HashMap;
import java.util.concurrent.ExecutorService;
+
import org.apache.bookkeeper.client.BookKeeperAdmin;
import org.apache.bookkeeper.conf.ServerConfiguration;
import org.apache.bookkeeper.http.HttpServer;
@@ -46,7 +48,7 @@ public class DecommissionService implements
HttpEndpointService {
public DecommissionService(ServerConfiguration conf, BookKeeperAdmin bka,
ExecutorService executor) {
- Preconditions.checkNotNull(conf);
+ checkNotNull(conf);
this.conf = conf;
this.bka = bka;
this.executor = executor;
diff --git
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/DeleteLedgerService.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/DeleteLedgerService.java
index 6b25e1e..2593e94 100644
---
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/DeleteLedgerService.java
+++
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/DeleteLedgerService.java
@@ -18,7 +18,8 @@
*/
package org.apache.bookkeeper.server.http.service;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import java.util.Map;
import org.apache.bookkeeper.client.BookKeeper;
import org.apache.bookkeeper.conf.ClientConfiguration;
@@ -42,7 +43,7 @@ public class DeleteLedgerService implements
HttpEndpointService {
protected ServerConfiguration conf;
public DeleteLedgerService(ServerConfiguration conf) {
- Preconditions.checkNotNull(conf);
+ checkNotNull(conf);
this.conf = conf;
}
diff --git
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ExpandStorageService.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ExpandStorageService.java
index 9ff5411..b79fb41 100644
---
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ExpandStorageService.java
+++
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ExpandStorageService.java
@@ -18,11 +18,14 @@
*/
package org.apache.bookkeeper.server.http.service;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import com.google.common.collect.Lists;
+
import java.io.File;
import java.util.Arrays;
import java.util.List;
+
import org.apache.bookkeeper.bookie.Bookie;
import org.apache.bookkeeper.bookie.BookieException;
import org.apache.bookkeeper.conf.ServerConfiguration;
@@ -51,7 +54,7 @@ public class ExpandStorageService implements
HttpEndpointService {
private ZooKeeper zk;
public ExpandStorageService(ServerConfiguration conf, ZooKeeper zk) {
- Preconditions.checkNotNull(conf);
+ checkNotNull(conf);
this.conf = conf;
this.zk = zk;
}
diff --git
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/GetLastLogMarkService.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/GetLastLogMarkService.java
index 92ad78d..31268cd 100644
---
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/GetLastLogMarkService.java
+++
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/GetLastLogMarkService.java
@@ -18,12 +18,15 @@
*/
package org.apache.bookkeeper.server.http.service;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
+
import java.io.File;
import java.util.List;
import java.util.Map;
+
import org.apache.bookkeeper.bookie.Journal;
import org.apache.bookkeeper.bookie.LedgerDirsManager;
import org.apache.bookkeeper.bookie.LogMark;
@@ -41,9 +44,9 @@ import org.slf4j.LoggerFactory;
* HttpEndpointService that handle Bookkeeper get last log mark related http
request.
* The GET method will get the last log position of each journal.
*
- * output would be like this:
+ * <p>output would be like this:
* {
- * "<Journal_id>" : "<Pos>",
+ * "<Journal_id>" : "<Pos>",
* ...
* }
*/
@@ -54,7 +57,7 @@ public class GetLastLogMarkService implements
HttpEndpointService {
protected ServerConfiguration conf;
public GetLastLogMarkService(ServerConfiguration conf) {
- Preconditions.checkNotNull(conf);
+ checkNotNull(conf);
this.conf = conf;
}
@@ -67,7 +70,7 @@ public class GetLastLogMarkService implements
HttpEndpointService {
/**
* output:
* {
- * "<Journal_id>" : "<Pos>",
+ * "<Journal_id>" : "<Pos>",
* ...
* }
*/
diff --git
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/GetLedgerMetaService.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/GetLedgerMetaService.java
index 43889d3..c92ad81 100644
---
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/GetLedgerMetaService.java
+++
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/GetLedgerMetaService.java
@@ -19,8 +19,8 @@
package org.apache.bookkeeper.server.http.service;
import static com.google.common.base.Charsets.UTF_8;
+import static com.google.common.base.Preconditions.checkNotNull;
-import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
import java.util.Map;
import org.apache.bookkeeper.client.LedgerMetadata;
@@ -48,7 +48,7 @@ public class GetLedgerMetaService implements
HttpEndpointService {
protected ZooKeeper zk;
public GetLedgerMetaService(ServerConfiguration conf, ZooKeeper zk) {
- Preconditions.checkNotNull(conf);
+ checkNotNull(conf);
this.conf = conf;
this.zk = zk;
}
diff --git
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ListBookieInfoService.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ListBookieInfoService.java
index d0979c7..72897cf 100644
---
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ListBookieInfoService.java
+++
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ListBookieInfoService.java
@@ -18,12 +18,15 @@
*/
package org.apache.bookkeeper.server.http.service;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import com.google.common.collect.Maps;
+
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.LinkedHashMap;
import java.util.Map;
+
import org.apache.bookkeeper.client.BookKeeper;
import org.apache.bookkeeper.client.BookieInfoReader;
import org.apache.bookkeeper.conf.ClientConfiguration;
@@ -40,7 +43,7 @@ import org.slf4j.LoggerFactory;
/**
* HttpEndpointService that handle Bookkeeper list bookie info related http
request.
*
- * The GET method will get the disk usage of all bookies in this bookkeeper
cluster.
+ * <p>The GET method will get the disk usage of all bookies in this bookkeeper
cluster.
* Output would be like this:
* {
* "bookieAddress" : {free: xxx, total: xxx}",
@@ -56,7 +59,7 @@ public class ListBookieInfoService implements
HttpEndpointService {
protected ServerConfiguration conf;
public ListBookieInfoService(ServerConfiguration conf) {
- Preconditions.checkNotNull(conf);
+ checkNotNull(conf);
this.conf = conf;
}
diff --git
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ListBookiesService.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ListBookiesService.java
index f0275a1..b28c715 100644
---
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ListBookiesService.java
+++
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ListBookiesService.java
@@ -18,11 +18,14 @@
*/
package org.apache.bookkeeper.server.http.service;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import com.google.common.collect.Maps;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
+
import org.apache.bookkeeper.client.BookKeeperAdmin;
import org.apache.bookkeeper.conf.ServerConfiguration;
import org.apache.bookkeeper.http.HttpServer;
@@ -46,7 +49,7 @@ public class ListBookiesService implements
HttpEndpointService {
protected BookKeeperAdmin bka;
public ListBookiesService(ServerConfiguration conf, BookKeeperAdmin bka) {
- Preconditions.checkNotNull(conf);
+ checkNotNull(conf);
this.conf = conf;
this.bka = bka;
}
@@ -60,13 +63,13 @@ public class ListBookiesService implements
HttpEndpointService {
Map<String, String> params = request.getParams();
// default print rw
- boolean readOnly = (params != null) &&
- params.containsKey("type") &&
- params.get("type").equals("ro");
+ boolean readOnly = (params != null)
+ && params.containsKey("type")
+ && params.get("type").equals("ro");
// default not print hostname
- boolean printHostname = (params != null) &&
- params.containsKey("print_hostnames") &&
- params.get("print_hostnames").equals("true");
+ boolean printHostname = (params != null)
+ && params.containsKey("print_hostnames")
+ && params.get("print_hostnames").equals("true");
if (readOnly) {
bookies.addAll(bka.getReadOnlyBookies());
diff --git
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ListDiskFilesService.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ListDiskFilesService.java
index d557f98..260b82d 100644
---
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ListDiskFilesService.java
+++
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ListDiskFilesService.java
@@ -18,13 +18,15 @@
*/
package org.apache.bookkeeper.server.http.service;
+import static com.google.common.base.Preconditions.checkNotNull;
import static org.apache.bookkeeper.bookie.BookieShell.listFilesAndSort;
-import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
+
import java.io.File;
import java.util.List;
import java.util.Map;
+
import org.apache.bookkeeper.conf.ServerConfiguration;
import org.apache.bookkeeper.http.HttpServer;
import org.apache.bookkeeper.http.service.HttpEndpointService;
@@ -37,7 +39,7 @@ import org.slf4j.LoggerFactory;
/**
* HttpEndpointService that handle Bookkeeper list disk files related http
request.
*
- * The GET method will list all bookie files of type journal|entrylog|index in
this bookie.
+ * <p>The GET method will list all bookie files of type journal|entrylog|index
in this bookie.
* The output would be like this:
* {
* "journal files" : "filename1 \t ...",
@@ -52,7 +54,7 @@ public class ListDiskFilesService implements
HttpEndpointService {
protected ServerConfiguration conf;
public ListDiskFilesService(ServerConfiguration conf) {
- Preconditions.checkNotNull(conf);
+ checkNotNull(conf);
this.conf = conf;
}
@@ -72,14 +74,14 @@ public class ListDiskFilesService implements
HttpEndpointService {
*/
Map<String, String> output = Maps.newHashMap();
- boolean journal = params != null &&
- params.containsKey("file_type")
+ boolean journal = params != null
+ && params.containsKey("file_type")
&& params.get("file_type").equals("journal");
- boolean entrylog = params != null &&
- params.containsKey("file_type")
+ boolean entrylog = params != null
+ && params.containsKey("file_type")
&& params.get("file_type").equals("entrylog");
- boolean index = params != null &&
- params.containsKey("file_type")
+ boolean index = params != null
+ && params.containsKey("file_type")
&& params.get("file_type").equals("index");
boolean all = false;
@@ -102,7 +104,7 @@ public class ListDiskFilesService implements
HttpEndpointService {
List<File> ledgerFiles = listFilesAndSort(ledgerDirs, "log");
StringBuffer files = new StringBuffer();
for (File ledgerFile : ledgerFiles) {
- files.append(ledgerFile.getName()+ "\t");
+ files.append(ledgerFile.getName() + "\t");
}
output.put("entrylog files", files.toString());
}
@@ -112,7 +114,7 @@ public class ListDiskFilesService implements
HttpEndpointService {
List<File> indexFiles = listFilesAndSort(indexDirs, "idx");
StringBuffer files = new StringBuffer();
for (File indexFile : indexFiles) {
- files.append(indexFile.getName()+ "\t");
+ files.append(indexFile.getName() + "\t");
}
output.put("index files", files.toString());
}
diff --git
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ListLedgerService.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ListLedgerService.java
index 75d9629..2062507 100644
---
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ListLedgerService.java
+++
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ListLedgerService.java
@@ -19,8 +19,8 @@
package org.apache.bookkeeper.server.http.service;
import static com.google.common.base.Charsets.UTF_8;
+import static com.google.common.base.Preconditions.checkNotNull;
-import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.util.concurrent.AbstractFuture;
@@ -45,7 +45,7 @@ import org.slf4j.LoggerFactory;
/**
* HttpEndpointService that handle Bookkeeper list ledger related http request.
*
- * The GET method will list all ledger_ids in this bookkeeper cluster.
+ * <p>The GET method will list all ledger_ids in this bookkeeper cluster.
* User can choose print metadata of each ledger or not by set parameter
"print_metadata"
*/
public class ListLedgerService implements HttpEndpointService {
@@ -56,7 +56,7 @@ public class ListLedgerService implements HttpEndpointService
{
protected ZooKeeper zk;
public ListLedgerService(ServerConfiguration conf, ZooKeeper zk) {
- Preconditions.checkNotNull(conf);
+ checkNotNull(conf);
this.conf = conf;
this.zk = zk;
}
@@ -64,6 +64,9 @@ public class ListLedgerService implements HttpEndpointService
{
// Number of LedgerMetadata contains in each page
static final int LIST_LEDGER_BATCH_SIZE = 100;
+ /**
+ * Callback for reading ledger metadata.
+ */
public static class ReadLedgerMetadataCallback extends
AbstractFuture<LedgerMetadata>
implements BookkeeperInternalCallbacks.GenericCallback<LedgerMetadata> {
final long ledgerId;
@@ -84,7 +87,8 @@ public class ListLedgerService implements HttpEndpointService
{
}
}
}
- static void keepLedgerMetadata(ReadLedgerMetadataCallback cb,
LinkedHashMap<String, String> output) throws Exception {
+ static void keepLedgerMetadata(ReadLedgerMetadataCallback cb,
LinkedHashMap<String, String> output)
+ throws Exception {
LedgerMetadata md = cb.get();
output.put(Long.valueOf(cb.getLedgerId()).toString(), new
String(md.serialize(), UTF_8));
}
@@ -97,14 +101,13 @@ public class ListLedgerService implements
HttpEndpointService {
if (HttpServer.Method.GET == request.getMethod()) {
Map<String, String> params = request.getParams();
// default not print metadata
- boolean printMeta = (params != null) &&
- params.containsKey("print_metadata") &&
- params.get("print_metadata").equals("true");
+ boolean printMeta = (params != null)
+ && params.containsKey("print_metadata")
+ && params.get("print_metadata").equals("true");
// Page index should start from 1;
- int pageIndex = (printMeta && params.containsKey("page")) ?
- Integer.parseInt(params.get("page")) :
- -1;
+ int pageIndex = (printMeta && params.containsKey("page"))
+ ? Integer.parseInt(params.get("page")) : -1;
LedgerManagerFactory mFactory =
LedgerManagerFactory.newLedgerManagerFactory(conf, zk);
LedgerManager manager = mFactory.newLedgerManager();
@@ -121,7 +124,7 @@ public class ListLedgerService implements
HttpEndpointService {
// start and end ledger index for wanted page.
int startLedgerIndex = 0;
int endLedgerIndex = 0;
- if(pageIndex > 0) {
+ if (pageIndex > 0) {
startLedgerIndex = (pageIndex - 1) *
LIST_LEDGER_BATCH_SIZE;
endLedgerIndex = startLedgerIndex + LIST_LEDGER_BATCH_SIZE
- 1;
}
@@ -130,9 +133,9 @@ public class ListLedgerService implements
HttpEndpointService {
while (iter.hasNext()) {
LedgerManager.LedgerRange r = iter.next();
for (Long lid : r.getLedgers()) {
- ledgerIndex ++;
- if (endLedgerIndex == 0 || // no actual page
parameter provided
- (ledgerIndex >= startLedgerIndex && ledgerIndex <=
endLedgerIndex)) {
+ ledgerIndex++;
+ if (endLedgerIndex == 0 // no actual page
parameter provided
+ || (ledgerIndex >= startLedgerIndex &&
ledgerIndex <= endLedgerIndex)) {
ReadLedgerMetadataCallback cb = new
ReadLedgerMetadataCallback(lid);
manager.readLedgerMetadata(lid, cb);
futures.add(cb);
diff --git
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ListUnderReplicatedLedgerService.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ListUnderReplicatedLedgerService.java
index 01929bb..a76d509 100644
---
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ListUnderReplicatedLedgerService.java
+++
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ListUnderReplicatedLedgerService.java
@@ -18,12 +18,15 @@
*/
package org.apache.bookkeeper.server.http.service;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import com.google.common.collect.Lists;
+
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.function.Predicate;
+
import org.apache.bookkeeper.conf.ServerConfiguration;
import org.apache.bookkeeper.http.HttpServer;
import org.apache.bookkeeper.http.service.HttpEndpointService;
@@ -40,7 +43,7 @@ import org.slf4j.LoggerFactory;
/**
* HttpEndpointService that handle Bookkeeper list under replicated ledger
related http request.
*
- * The GET method will list all ledger_ids of under replicated ledger.
+ * <p>The GET method will list all ledger_ids of under replicated ledger.
* User can filer wanted ledger by set parameter "missingreplica" and
"excludingmissingreplica"
*/
public class ListUnderReplicatedLedgerService implements HttpEndpointService {
@@ -51,7 +54,7 @@ public class ListUnderReplicatedLedgerService implements
HttpEndpointService {
protected ZooKeeper zk;
public ListUnderReplicatedLedgerService(ServerConfiguration conf,
ZooKeeper zk) {
- Preconditions.checkNotNull(conf);
+ checkNotNull(conf);
this.conf = conf;
this.zk = zk;
}
diff --git
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/LostBookieRecoveryDelayService.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/LostBookieRecoveryDelayService.java
index 1a2ed61..fcc9eff 100644
---
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/LostBookieRecoveryDelayService.java
+++
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/LostBookieRecoveryDelayService.java
@@ -18,8 +18,10 @@
*/
package org.apache.bookkeeper.server.http.service;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import java.util.HashMap;
+
import org.apache.bookkeeper.client.BookKeeperAdmin;
import org.apache.bookkeeper.conf.ServerConfiguration;
import org.apache.bookkeeper.http.HttpServer;
@@ -33,7 +35,7 @@ import org.slf4j.LoggerFactory;
/**
* HttpEndpointService that handle Bookkeeper lost bookie recovery delay
parameter related http request.
*
- * The GET method will get the value of parameter lostBookieRecoveryDelay,
+ * <p>The GET method will get the value of parameter lostBookieRecoveryDelay,
* while the PUT method will set the value of parameter
lostBookieRecoveryDelay,
*/
public class LostBookieRecoveryDelayService implements HttpEndpointService {
@@ -44,7 +46,7 @@ public class LostBookieRecoveryDelayService implements
HttpEndpointService {
protected BookKeeperAdmin bka;
public LostBookieRecoveryDelayService(ServerConfiguration conf,
BookKeeperAdmin bka) {
- Preconditions.checkNotNull(conf);
+ checkNotNull(conf);
this.conf = conf;
this.bka = bka;
}
diff --git
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ReadLedgerEntryService.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ReadLedgerEntryService.java
index 7454bc3..9bed45d 100644
---
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ReadLedgerEntryService.java
+++
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ReadLedgerEntryService.java
@@ -19,9 +19,10 @@
package org.apache.bookkeeper.server.http.service;
import static com.google.common.base.Charsets.US_ASCII;
+import static com.google.common.base.Preconditions.checkNotNull;
-import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
+
import java.util.Iterator;
import java.util.Map;
import org.apache.bookkeeper.client.BookKeeperAdmin;
@@ -38,7 +39,7 @@ import org.slf4j.LoggerFactory;
/**
* HttpEndpointService that handle Bookkeeper read ledger entry related http
request.
*
- * The GET method will print all entry content of wanted entry.
+ * <p>The GET method will print all entry content of wanted entry.
* User should set wanted "ledger_id", and can choose only print out wanted
entry
* by set parameter "start_entry_id", "end_entry_id" and "page".
*/
@@ -50,7 +51,7 @@ public class ReadLedgerEntryService implements
HttpEndpointService {
protected BookKeeperAdmin bka;
public ReadLedgerEntryService(ServerConfiguration conf, BookKeeperAdmin
bka) {
- Preconditions.checkNotNull(conf);
+ checkNotNull(conf);
this.conf = conf;
this.bka = bka;
}
@@ -78,7 +79,7 @@ public class ReadLedgerEntryService implements
HttpEndpointService {
// Page index should start from 1;
Integer pageIndex = params.containsKey("page") ?
Integer.parseInt(params.get("page")) : -1;
- if(pageIndex > 0) {
+ if (pageIndex > 0) {
// start and end ledger index for wanted page.
Long startIndexInPage = (pageIndex - 1) * ENTRIES_PER_PAE;
Long endIndexInPage = startIndexInPage + ENTRIES_PER_PAE - 1;
diff --git
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/RecoveryBookieService.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/RecoveryBookieService.java
index ecce428..3b1e175 100644
---
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/RecoveryBookieService.java
+++
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/RecoveryBookieService.java
@@ -18,9 +18,13 @@
*/
package org.apache.bookkeeper.server.http.service;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
import java.util.List;
import java.util.concurrent.ExecutorService;
+
import org.apache.bookkeeper.bookie.Cookie;
import org.apache.bookkeeper.client.BookKeeperAdmin;
import org.apache.bookkeeper.conf.ServerConfiguration;
@@ -40,12 +44,12 @@ import org.slf4j.LoggerFactory;
/**
* HttpEndpointService that handle Bookkeeper recovery related http request.
*
- * The PUT method will recovery bookie with provided parameter.
+ * <p>The PUT method will recovery bookie with provided parameter.
* The parameter of input body should be like this format:
* {
* "bookie_src": [ "bookie_src1", "bookie_src2"... ],
* "bookie_dest": [ "bookie_dest1", "bookie_dest2"... ],
- * "delete_cookie": <bool_value>
+ * "delete_cookie": <bool_value>
* }
*/
public class RecoveryBookieService implements HttpEndpointService {
@@ -57,7 +61,7 @@ public class RecoveryBookieService implements
HttpEndpointService {
protected ExecutorService executor;
public RecoveryBookieService(ServerConfiguration conf, BookKeeperAdmin
bka, ExecutorService executor) {
- Preconditions.checkNotNull(conf);
+ checkNotNull(conf);
this.conf = conf;
this.bka = bka;
this.executor = executor;
@@ -71,8 +75,11 @@ public class RecoveryBookieService implements
HttpEndpointService {
* }
*/
static class RecoveryRequestJsonBody {
- public List<String> bookie_src;
- public boolean delete_cookie;
+ @JsonProperty("bookie_src")
+ public List<String> bookieSrc;
+
+ @JsonProperty("delete_cookie")
+ public boolean deleteCookie;
}
@Override
@@ -89,8 +96,8 @@ public class RecoveryBookieService implements
HttpEndpointService {
try {
requestJsonBody = JsonUtil.fromJson(requestBody,
RecoveryRequestJsonBody.class);
- LOG.debug("bookie_src: [" + requestJsonBody.bookie_src.get(0)
- + "], delete_cookie: [" + requestJsonBody.delete_cookie +
"]");
+ LOG.debug("bookie_src: [" + requestJsonBody.bookieSrc.get(0)
+ + "], delete_cookie: [" + requestJsonBody.deleteCookie + "]");
} catch (JsonUtil.ParseJsonException e) {
LOG.error("Meet Exception: ", e);
response.setCode(HttpServer.StatusCode.NOT_FOUND);
@@ -98,17 +105,16 @@ public class RecoveryBookieService implements
HttpEndpointService {
return response;
}
- if (HttpServer.Method.PUT == request.getMethod() &&
- !requestJsonBody.bookie_src.isEmpty()) {
+ if (HttpServer.Method.PUT == request.getMethod() &&
!requestJsonBody.bookieSrc.isEmpty()) {
Class<? extends RegistrationManager> rmClass =
conf.getRegistrationManagerClass();
RegistrationManager rm = ReflectionUtils.newInstance(rmClass);
rm.initialize(conf, () -> {}, NullStatsLogger.INSTANCE);
- String bookieSrcString[] =
requestJsonBody.bookie_src.get(0).split(":");
+ String bookieSrcString[] =
requestJsonBody.bookieSrc.get(0).split(":");
BookieSocketAddress bookieSrc = new BookieSocketAddress(
bookieSrcString[0], Integer.parseInt(bookieSrcString[1]));
- boolean deleteCookie = requestJsonBody.delete_cookie;
+ boolean deleteCookie = requestJsonBody.deleteCookie;
executor.execute(() -> {
try {
LOG.info("Start recovering bookie.");
diff --git
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/TriggerAuditService.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/TriggerAuditService.java
index 30b580e..f5c2b4e 100644
---
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/TriggerAuditService.java
+++
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/TriggerAuditService.java
@@ -18,7 +18,8 @@
*/
package org.apache.bookkeeper.server.http.service;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import org.apache.bookkeeper.client.BookKeeperAdmin;
import org.apache.bookkeeper.conf.ServerConfiguration;
import org.apache.bookkeeper.http.HttpServer;
@@ -40,7 +41,7 @@ public class TriggerAuditService implements
HttpEndpointService {
protected BookKeeperAdmin bka;
public TriggerAuditService(ServerConfiguration conf, BookKeeperAdmin bka) {
- Preconditions.checkNotNull(conf);
+ checkNotNull(conf);
this.conf = conf;
this.bka = bka;
}
diff --git
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/WhoIsAuditorService.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/WhoIsAuditorService.java
index baf9f80..9154ccd 100644
---
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/WhoIsAuditorService.java
+++
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/WhoIsAuditorService.java
@@ -18,7 +18,8 @@
*/
package org.apache.bookkeeper.server.http.service;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import org.apache.bookkeeper.conf.ServerConfiguration;
import org.apache.bookkeeper.http.HttpServer;
import org.apache.bookkeeper.http.service.HttpEndpointService;
@@ -33,7 +34,7 @@ import org.slf4j.LoggerFactory;
/**
* HttpEndpointService that handle Bookkeeper who is auditor related http
request.
*
- * The GET method will get the auditor bookie address
+ * <p>The GET method will get the auditor bookie address
*/
public class WhoIsAuditorService implements HttpEndpointService {
@@ -43,7 +44,7 @@ public class WhoIsAuditorService implements
HttpEndpointService {
protected ZooKeeper zk;
public WhoIsAuditorService(ServerConfiguration conf, ZooKeeper zk) {
- Preconditions.checkNotNull(conf);
+ checkNotNull(conf);
this.conf = conf;
this.zk = zk;
}
diff --git a/buildtools/src/main/resources/bookkeeper/server-suppressions.xml
b/buildtools/src/main/resources/bookkeeper/server-suppressions.xml
index 4daaf89..6665a6d 100644
--- a/buildtools/src/main/resources/bookkeeper/server-suppressions.xml
+++ b/buildtools/src/main/resources/bookkeeper/server-suppressions.xml
@@ -23,8 +23,6 @@
<!-- suppress packages by packages -->
<suppress checks=".*" files=".*[\\/]bookie[\\/].*"/>
<suppress checks=".*"
files=".*[\\/]client[\\/](?:[^\\/]+$|(?!api)|(?!impl)[^\\/]+[\\/])"/>
- <suppress checks=".*" files=".*[\\/]http[\\/].*"/>
- <suppress checks=".*" files=".*[\\/]replication[\\/].*"/>
<suppress checks=".*" files=".*[\\/]test[\\/].*"/>
<suppress checks=".*" files=".*[\\/]util[\\/].*"/>
--
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].