You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2020/10/29 21:26:27 UTC
[GitHub] [bookkeeper] karanmehta93 opened a new pull request #2472: Add Add ForceAuditChecksCmd to reset auditor checks last run time
karanmehta93 opened a new pull request #2472:
URL: https://github.com/apache/bookkeeper/pull/2472
Descriptions of the changes in this PR:
### Motivation
Reset the last run time for auditor checks. Reboot auditor leader immediately to trigger the checks. This is mostly used for testing infra and get the sanity check of a cluster on demand.
### Changes
Added a new shell command and tests
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [bookkeeper] karanmehta93 commented on a change in pull request #2472: Add Add ForceAuditChecksCmd to reset auditor checks last run time
Posted by GitBox <gi...@apache.org>.
karanmehta93 commented on a change in pull request #2472:
URL: https://github.com/apache/bookkeeper/pull/2472#discussion_r518324292
##########
File path: bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/BookieShell.java
##########
@@ -1799,6 +1804,76 @@ public int runCmd(CommandLine cmdLine) throws Exception {
}
}
+ class ForceAuditorChecksCmd extends MyCommand {
+ Options opts = new Options();
+
+ ForceAuditorChecksCmd() {
+ super(CMD_FORCEAUDITCHECKS);
+ opts.addOption("calc", "checkallledgerscheck", false, "Force checkAllLedgers audit "
+ + "upon next Auditor startup ");
+ opts.addOption("ppc", "placementpolicycheck", false, "Force placementPolicyCheck audit "
+ + "upon next Auditor startup ");
+ opts.addOption("rc", "replicascheck", false, "Force replicasCheck audit "
+ + "upon next Auditor startup ");
+ }
+
+ @Override
+ Options getOptions() {
+ return opts;
+ }
+
+ @Override
+ String getDescription() {
+ return "Reset the last run time of auditor checks "
+ + "(checkallledgerscheck, placementpolicycheck, replicascheck) "
+ + "The current auditor must be REBOOTED after this command is run.";
+ }
+
+ @Override
+ String getUsage() {
+ return "forceauditchecks [-checkallledgerscheck [-placementpolicycheck] [-replicascheck]";
+ }
+
+ @Override
+ int runCmd(CommandLine cmdLine) throws Exception {
+ boolean checkAllLedgersCheck = cmdLine.hasOption("calc");
+ boolean placementPolicyCheck = cmdLine.hasOption("ppc");
+ boolean replicasCheck = cmdLine.hasOption("rc");
+
+ if (checkAllLedgersCheck || placementPolicyCheck || replicasCheck) {
+ runFunctionWithLedgerManagerFactory(bkConf, mFactory -> {
+ try {
+ try (LedgerUnderreplicationManager underreplicationManager =
+ mFactory.newLedgerUnderreplicationManager()) {
+ // Arbitrary value of 21 days chosen since current freq of all checks is less than 21 days
+ long time = System.currentTimeMillis() - (21 * 24 * 60 * 60 * 1000);
+ if (checkAllLedgersCheck) {
+ LOG.info("Resetting CheckAllLedgersCTime to : " + time);
+ underreplicationManager.setCheckAllLedgersCTime(time);
+ }
+ if (placementPolicyCheck) {
+ LOG.info("Resetting PlacementPolicyCheckCTime to : " + time);
+ underreplicationManager.setPlacementPolicyCheckCTime(time);
+ }
+ if (replicasCheck) {
+ LOG.info("Resetting ReplicasCheckCTime to : " + time);
Review comment:
Updated it.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [bookkeeper] eolivelli commented on a change in pull request #2472: Add Add ForceAuditChecksCmd to reset auditor checks last run time
Posted by GitBox <gi...@apache.org>.
eolivelli commented on a change in pull request #2472:
URL: https://github.com/apache/bookkeeper/pull/2472#discussion_r515774688
##########
File path: bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/BookieShell.java
##########
@@ -1799,6 +1804,76 @@ public int runCmd(CommandLine cmdLine) throws Exception {
}
}
+ class ForceAuditorChecksCmd extends MyCommand {
+ Options opts = new Options();
+
+ ForceAuditorChecksCmd() {
+ super(CMD_FORCEAUDITCHECKS);
+ opts.addOption("calc", "checkallledgerscheck", false, "Force checkAllLedgers audit "
+ + "upon next Auditor startup ");
+ opts.addOption("ppc", "placementpolicycheck", false, "Force placementPolicyCheck audit "
+ + "upon next Auditor startup ");
+ opts.addOption("rc", "replicascheck", false, "Force replicasCheck audit "
+ + "upon next Auditor startup ");
+ }
+
+ @Override
+ Options getOptions() {
+ return opts;
+ }
+
+ @Override
+ String getDescription() {
+ return "Reset the last run time of auditor checks "
+ + "(checkallledgerscheck, placementpolicycheck, replicascheck) "
+ + "The current auditor must be REBOOTED after this command is run.";
+ }
+
+ @Override
+ String getUsage() {
+ return "forceauditchecks [-checkallledgerscheck [-placementpolicycheck] [-replicascheck]";
+ }
+
+ @Override
+ int runCmd(CommandLine cmdLine) throws Exception {
+ boolean checkAllLedgersCheck = cmdLine.hasOption("calc");
+ boolean placementPolicyCheck = cmdLine.hasOption("ppc");
+ boolean replicasCheck = cmdLine.hasOption("rc");
+
+ if (checkAllLedgersCheck || placementPolicyCheck || replicasCheck) {
+ runFunctionWithLedgerManagerFactory(bkConf, mFactory -> {
+ try {
+ try (LedgerUnderreplicationManager underreplicationManager =
+ mFactory.newLedgerUnderreplicationManager()) {
+ // Arbitrary value of 21 days chosen since current freq of all checks is less than 21 days
+ long time = System.currentTimeMillis() - (21 * 24 * 60 * 60 * 1000);
+ if (checkAllLedgersCheck) {
+ LOG.info("Resetting CheckAllLedgersCTime to : " + time);
Review comment:
can we ALSO print `time` formatted for humans ?
##########
File path: bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/BookieShell.java
##########
@@ -1799,6 +1804,76 @@ public int runCmd(CommandLine cmdLine) throws Exception {
}
}
+ class ForceAuditorChecksCmd extends MyCommand {
+ Options opts = new Options();
+
+ ForceAuditorChecksCmd() {
+ super(CMD_FORCEAUDITCHECKS);
+ opts.addOption("calc", "checkallledgerscheck", false, "Force checkAllLedgers audit "
+ + "upon next Auditor startup ");
+ opts.addOption("ppc", "placementpolicycheck", false, "Force placementPolicyCheck audit "
+ + "upon next Auditor startup ");
+ opts.addOption("rc", "replicascheck", false, "Force replicasCheck audit "
+ + "upon next Auditor startup ");
+ }
+
+ @Override
+ Options getOptions() {
+ return opts;
+ }
+
+ @Override
+ String getDescription() {
+ return "Reset the last run time of auditor checks "
+ + "(checkallledgerscheck, placementpolicycheck, replicascheck) "
+ + "The current auditor must be REBOOTED after this command is run.";
+ }
+
+ @Override
+ String getUsage() {
+ return "forceauditchecks [-checkallledgerscheck [-placementpolicycheck] [-replicascheck]";
+ }
+
+ @Override
+ int runCmd(CommandLine cmdLine) throws Exception {
+ boolean checkAllLedgersCheck = cmdLine.hasOption("calc");
+ boolean placementPolicyCheck = cmdLine.hasOption("ppc");
+ boolean replicasCheck = cmdLine.hasOption("rc");
+
+ if (checkAllLedgersCheck || placementPolicyCheck || replicasCheck) {
+ runFunctionWithLedgerManagerFactory(bkConf, mFactory -> {
+ try {
+ try (LedgerUnderreplicationManager underreplicationManager =
+ mFactory.newLedgerUnderreplicationManager()) {
+ // Arbitrary value of 21 days chosen since current freq of all checks is less than 21 days
+ long time = System.currentTimeMillis() - (21 * 24 * 60 * 60 * 1000);
+ if (checkAllLedgersCheck) {
+ LOG.info("Resetting CheckAllLedgersCTime to : " + time);
+ underreplicationManager.setCheckAllLedgersCTime(time);
+ }
+ if (placementPolicyCheck) {
+ LOG.info("Resetting PlacementPolicyCheckCTime to : " + time);
Review comment:
can we ALSO print `time` formatted for humans ?
##########
File path: bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/BookieShell.java
##########
@@ -1799,6 +1804,76 @@ public int runCmd(CommandLine cmdLine) throws Exception {
}
}
+ class ForceAuditorChecksCmd extends MyCommand {
+ Options opts = new Options();
+
+ ForceAuditorChecksCmd() {
+ super(CMD_FORCEAUDITCHECKS);
+ opts.addOption("calc", "checkallledgerscheck", false, "Force checkAllLedgers audit "
+ + "upon next Auditor startup ");
+ opts.addOption("ppc", "placementpolicycheck", false, "Force placementPolicyCheck audit "
+ + "upon next Auditor startup ");
+ opts.addOption("rc", "replicascheck", false, "Force replicasCheck audit "
+ + "upon next Auditor startup ");
+ }
+
+ @Override
+ Options getOptions() {
+ return opts;
+ }
+
+ @Override
+ String getDescription() {
+ return "Reset the last run time of auditor checks "
+ + "(checkallledgerscheck, placementpolicycheck, replicascheck) "
+ + "The current auditor must be REBOOTED after this command is run.";
+ }
+
+ @Override
+ String getUsage() {
+ return "forceauditchecks [-checkallledgerscheck [-placementpolicycheck] [-replicascheck]";
+ }
+
+ @Override
+ int runCmd(CommandLine cmdLine) throws Exception {
+ boolean checkAllLedgersCheck = cmdLine.hasOption("calc");
+ boolean placementPolicyCheck = cmdLine.hasOption("ppc");
+ boolean replicasCheck = cmdLine.hasOption("rc");
+
+ if (checkAllLedgersCheck || placementPolicyCheck || replicasCheck) {
+ runFunctionWithLedgerManagerFactory(bkConf, mFactory -> {
+ try {
+ try (LedgerUnderreplicationManager underreplicationManager =
+ mFactory.newLedgerUnderreplicationManager()) {
+ // Arbitrary value of 21 days chosen since current freq of all checks is less than 21 days
+ long time = System.currentTimeMillis() - (21 * 24 * 60 * 60 * 1000);
+ if (checkAllLedgersCheck) {
+ LOG.info("Resetting CheckAllLedgersCTime to : " + time);
+ underreplicationManager.setCheckAllLedgersCTime(time);
+ }
+ if (placementPolicyCheck) {
+ LOG.info("Resetting PlacementPolicyCheckCTime to : " + time);
+ underreplicationManager.setPlacementPolicyCheckCTime(time);
+ }
+ if (replicasCheck) {
+ LOG.info("Resetting ReplicasCheckCTime to : " + time);
Review comment:
can we ALSO print `time` formatted for humans ?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [bookkeeper] jiazhai merged pull request #2472: Add Add ForceAuditChecksCmd to reset auditor checks last run time
Posted by GitBox <gi...@apache.org>.
jiazhai merged pull request #2472:
URL: https://github.com/apache/bookkeeper/pull/2472
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org