This is an automated email from the ASF dual-hosted git repository.

ddanielr pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo.git

commit 391a87616b25f1a0a0f5a55dddfe0509aef9286b
Merge: 6cfdfc242a3 27e5fe76f75
Author: Daniel Roberts ddanielr <ddani...@gmail.com>
AuthorDate: Wed Jan 22 16:56:58 2025 +0000

    Merge branch '3.1'

 .../org/apache/accumulo/core/cli/TestHelp.java     | 19 ++++++
 .../org/apache/accumulo/server/util/Admin.java     | 79 ++++++++++++++--------
 .../accumulo/server/util/ServiceStatusCmd.java     | 17 +----
 .../accumulo/server/util/AdminCommandsTest.java    |  4 +-
 .../accumulo/server/util/ServiceStatusCmdTest.java |  2 +-
 5 files changed, 74 insertions(+), 47 deletions(-)

diff --cc server/base/src/main/java/org/apache/accumulo/server/util/Admin.java
index bb350ec5326,51670687e57..2d8c342c367
--- a/server/base/src/main/java/org/apache/accumulo/server/util/Admin.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/util/Admin.java
@@@ -128,12 -108,10 +128,11 @@@ import edu.umd.cs.findbugs.annotations.
  @AutoService(KeywordExecutable.class)
  public class Admin implements KeywordExecutable {
    private static final Logger log = LoggerFactory.getLogger(Admin.class);
 +  private final CountDownLatch lockAcquiredLatch = new CountDownLatch(1);
  
-   static class AdminOpts extends ServerUtilOpts {
-     @Parameter(names = {"-f", "--force"},
-         description = "force the given server to stop by removing its lock")
-     boolean force = false;
+   private static class SubCommandOpts {
+     @Parameter(names = {"-h", "-?", "--help", "-help"}, help = true)
+     public boolean help = false;
    }
  
    @Parameters(commandDescription = "stop the tablet server on the given 
hosts")
@@@ -327,12 -308,12 +329,12 @@@
  
    @Parameters(commandNames = "fate",
        commandDescription = "Operations performed on the Manager FaTE system.")
-   static class FateOpsCommand {
+   static class FateOpsCommand extends SubCommandOpts {
 -    @Parameter(description = "[<txId>...]")
 -    List<String> txList = new ArrayList<>();
 +    @Parameter(description = "[<FateId>...]")
 +    List<String> fateIdList = new ArrayList<>();
  
      @Parameter(names = {"-c", "--cancel"},
 -        description = "<txId>... Cancel new or submitted FaTE transactions")
 +        description = "<FateId>... Cancel new or submitted FaTE transactions")
      boolean cancel;
  
      @Parameter(names = {"-f", "--fail"},
@@@ -358,42 -337,17 +360,51 @@@
      @Parameter(names = {"-s", "--state"},
          description = "<state>... Print transactions in the state(s) {NEW, 
IN_PROGRESS, FAILED_IN_PROGRESS, FAILED, SUCCESSFUL}")
      List<String> states = new ArrayList<>();
 +
 +    @Parameter(names = {"-t", "--type"},
 +        description = "<type>... Print transactions of fate instance type(s) 
{USER, META}")
 +    List<String> instanceTypes = new ArrayList<>();
 +  }
 +
 +  class AdminLockWatcher implements ServiceLock.AccumuloLockWatcher {
 +    @Override
 +    public void lostLock(ServiceLock.LockLossReason reason) {
 +      String msg = "Admin lost lock: " + reason.toString();
 +      if (reason == ServiceLock.LockLossReason.LOCK_DELETED) {
 +        Halt.halt(msg, 0);
 +      } else {
 +        Halt.halt(msg, 1);
 +      }
 +    }
 +
 +    @Override
 +    public void unableToMonitorLockNode(Exception e) {
 +      String msg = "Admin unable to monitor lock: " + e.getMessage();
 +      log.warn(msg);
 +      Halt.halt(msg, 1);
 +    }
 +
 +    @Override
 +    public void acquiredLock() {
 +      lockAcquiredLatch.countDown();
 +      log.debug("Acquired ZooKeeper lock for Admin");
 +    }
 +
 +    @Override
 +    public void failedToAcquireLock(Exception e) {
 +      log.warn("Failed to acquire ZooKeeper lock for Admin, msg: " + 
e.getMessage());
 +    }
    }
  
+   @Parameters(commandDescription = "show service status")
+   public static class ServiceStatusCmdOpts extends SubCommandOpts {
+     @Parameter(names = "--json", description = "provide output in json format 
(--noHosts ignored)")
+     boolean json = false;
+     @Parameter(names = "--noHosts",
+         description = "provide a summary of service counts without host 
details")
+     boolean noHosts = false;
+   }
+ 
    public static void main(String[] args) {
      new Admin().execute(args);
    }
diff --cc 
server/base/src/main/java/org/apache/accumulo/server/util/ServiceStatusCmd.java
index aea14d09ffd,92c241bbd59..00b236fb5d5
--- 
a/server/base/src/main/java/org/apache/accumulo/server/util/ServiceStatusCmd.java
+++ 
b/server/base/src/main/java/org/apache/accumulo/server/util/ServiceStatusCmd.java
@@@ -55,24 -55,27 +53,24 @@@ public class ServiceStatusCmd 
     * Read the service statuses from ZooKeeper, build the status report and 
then output the report to
     * stdout.
     */
-   public void execute(final ServerContext context, final Opts opts) {
+   public void execute(final ServerContext context, final boolean json, final 
boolean noHosts) {
  
 -    ZooReader zooReader = context.getZooSession().asReader();
 -
 -    final String zooRoot = context.getZooKeeperRoot();
 -    LOG.trace("zooRoot: {}", zooRoot);
 +    if (LOG.isTraceEnabled()) {
 +      LOG.trace("zooRoot: {}", context.getZooKeeperRoot());
 +    }
  
      final Map<ServiceStatusReport.ReportKey,StatusSummary> services = new 
TreeMap<>();
  
 -    services.put(ServiceStatusReport.ReportKey.MANAGER, 
getManagerStatus(zooReader, zooRoot));
 -    services.put(ServiceStatusReport.ReportKey.MONITOR, 
getMonitorStatus(zooReader, zooRoot));
 -    services.put(ServiceStatusReport.ReportKey.T_SERVER, 
getTServerStatus(zooReader, zooRoot));
 -    services.put(ServiceStatusReport.ReportKey.S_SERVER, 
getScanServerStatus(zooReader, zooRoot));
 -    services.put(ServiceStatusReport.ReportKey.COORDINATOR,
 -        getCoordinatorStatus(zooReader, zooRoot));
 -    services.put(ServiceStatusReport.ReportKey.COMPACTOR, 
getCompactorStatus(zooReader, zooRoot));
 -    services.put(ServiceStatusReport.ReportKey.GC, getGcStatus(zooReader, 
zooRoot));
 +    services.put(ServiceStatusReport.ReportKey.MANAGER, 
getManagerStatus(context));
 +    services.put(ServiceStatusReport.ReportKey.MONITOR, 
getMonitorStatus(context));
 +    services.put(ServiceStatusReport.ReportKey.T_SERVER, 
getTServerStatus(context));
 +    services.put(ServiceStatusReport.ReportKey.S_SERVER, 
getScanServerStatus(context));
 +    services.put(ServiceStatusReport.ReportKey.COMPACTOR, 
getCompactorStatus(context));
 +    services.put(ServiceStatusReport.ReportKey.GC, getGcStatus(context));
  
-     ServiceStatusReport report = new ServiceStatusReport(services, 
opts.noHosts);
+     ServiceStatusReport report = new ServiceStatusReport(services, noHosts);
  
-     if (opts.json) {
+     if (json) {
        System.out.println(report.toJson());
      } else {
        StringBuilder sb = new StringBuilder(8192);
diff --cc 
server/base/src/test/java/org/apache/accumulo/server/util/ServiceStatusCmdTest.java
index 163bfed546c,74f252368e7..ffc2815a99f
--- 
a/server/base/src/test/java/org/apache/accumulo/server/util/ServiceStatusCmdTest.java
+++ 
b/server/base/src/test/java/org/apache/accumulo/server/util/ServiceStatusCmdTest.java
@@@ -501,8 -478,8 +501,8 @@@ public class ServiceStatusCmdTest 
  
    @Test
    public void testServiceStatusCommandOpts() {
 -    replay(zk);
 +    replay(zooReader, zooCache);
-     ServiceStatusCmd.Opts opts = new ServiceStatusCmd.Opts();
+     Admin.ServiceStatusCmdOpts opts = new Admin.ServiceStatusCmdOpts();
      assertFalse(opts.json);
      assertFalse(opts.noHosts);
    }

Reply via email to