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:
[email protected]


Reply via email to