This is an automated email from the ASF dual-hosted git repository.
sijie 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 afa1c20 Enhancing DecommissionBookieCmd
afa1c20 is described below
commit afa1c2008ddf2eff7cec3fd9c055157f41e0fdd3
Author: cguttapalem <[email protected]>
AuthorDate: Mon Aug 6 15:34:03 2018 -0700
Enhancing DecommissionBookieCmd
Descriptions of the changes in this PR:
- adding bookieid option to DecommissionBookieCmd, to enable
decommissioning remote
bookie. This might be needed because, in an extreme scenario Bookie node
might not
be completely accessible and hence we might need to decommission a Bookie
remotely.
- also DecommissionBookieCmd should delete the cookie of the decommissioned
Bookie.
Author: cguttapalem <[email protected]>
Reviewers: Sijie Guo <[email protected]>, Venkateswararao Jujjuri (JV) <None>
This closes #1582 from reddycharan/decomfix
---
.../org/apache/bookkeeper/bookie/BookieShell.java | 35 ++++++++++++++++++----
1 file changed, 29 insertions(+), 6 deletions(-)
diff --git
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/BookieShell.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/BookieShell.java
index b119062..102a441 100644
---
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/BookieShell.java
+++
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/BookieShell.java
@@ -2490,25 +2490,28 @@ public class BookieShell implements Tool {
}
/**
- * Command to trigger AuditTask by resetting lostBookieRecoveryDelay and
then make sure the
- * ledgers stored in the bookie are properly replicated.
+ * Command to trigger AuditTask by resetting lostBookieRecoveryDelay and
+ * then make sure the ledgers stored in the bookie are properly replicated
+ * and Cookie of the decommissioned bookie should be deleted from metadata
+ * server.
*/
class DecommissionBookieCmd extends MyCommand {
Options lOpts = new Options();
DecommissionBookieCmd() {
super(CMD_DECOMMISSIONBOOKIE);
+ lOpts.addOption("bookieid", true, "decommission a remote bookie");
}
@Override
String getDescription() {
return "Force trigger the Audittask and make sure all the ledgers
stored in the decommissioning bookie"
- + " are replicated.";
+ + " are replicated and cookie of the decommissioned bookie
is deleted from metadata server.";
}
@Override
String getUsage() {
- return CMD_DECOMMISSIONBOOKIE;
+ return CMD_DECOMMISSIONBOOKIE + " [-bookieid <bookieaddress>]";
}
@Override
@@ -2521,8 +2524,28 @@ public class BookieShell implements Tool {
ClientConfiguration adminConf = new ClientConfiguration(bkConf);
BookKeeperAdmin admin = new BookKeeperAdmin(adminConf);
try {
- BookieSocketAddress thisBookieAddress =
Bookie.getBookieAddress(bkConf);
- admin.decommissionBookie(thisBookieAddress);
+ final String remoteBookieidToDecommission =
cmdLine.getOptionValue("bookieid");
+ final BookieSocketAddress bookieAddressToDecommission =
(StringUtils
+ .isBlank(remoteBookieidToDecommission) ?
Bookie.getBookieAddress(bkConf)
+ : new
BookieSocketAddress(remoteBookieidToDecommission));
+ admin.decommissionBookie(bookieAddressToDecommission);
+ LOG.info("The ledgers stored in the given decommissioning
bookie: {} are properly replicated",
+ bookieAddressToDecommission);
+ runFunctionWithRegistrationManager(bkConf, rm -> {
+ try {
+ Versioned<Cookie> cookie =
Cookie.readFromRegistrationManager(rm, bookieAddressToDecommission);
+ cookie.getValue().deleteFromRegistrationManager(rm,
bookieAddressToDecommission,
+ cookie.getVersion());
+ } catch (CookieNotFoundException nne) {
+ LOG.warn("No cookie to remove for the decommissioning
bookie: {}, it could be deleted already",
+ bookieAddressToDecommission, nne);
+ } catch (BookieException be) {
+ throw new UncheckedExecutionException(be.getMessage(),
be);
+ }
+ return 0;
+ });
+ LOG.info("Cookie of the decommissioned bookie: {} is deleted
successfully",
+ bookieAddressToDecommission);
return 0;
} catch (Exception e) {
LOG.error("Received exception in DecommissionBookieCmd ", e);