You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by mm...@apache.org on 2022/09/30 19:16:23 UTC

[accumulo] branch main updated: Fixes for new Admin fate command (#2987)

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

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


The following commit(s) were added to refs/heads/main by this push:
     new a57cec3dc8 Fixes for new Admin fate command (#2987)
a57cec3dc8 is described below

commit a57cec3dc800ff0c9e20ba27dc66743f5969872a
Author: Mike Miller <mm...@apache.org>
AuthorDate: Fri Sep 30 19:16:17 2022 +0000

    Fixes for new Admin fate command (#2987)
    
    * A few fixes for new Admin fate command
    * Make Admin fate conform to Git command usage guidelines
    * Closes #2974
---
 .../org/apache/accumulo/server/util/Admin.java     | 35 ++++++++++------------
 1 file changed, 16 insertions(+), 19 deletions(-)

diff --git 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
index e6df9ff0af..2f5010846e 100644
--- 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
@@ -68,6 +68,7 @@ import org.apache.accumulo.core.util.AddressUtil;
 import org.apache.accumulo.core.util.HostAndPort;
 import org.apache.accumulo.core.util.tables.TableMap;
 import org.apache.accumulo.fate.AdminUtil;
+import org.apache.accumulo.fate.FateTxId;
 import org.apache.accumulo.fate.ReadOnlyTStore;
 import org.apache.accumulo.fate.ZooStore;
 import org.apache.accumulo.fate.zookeeper.ServiceLock;
@@ -228,19 +229,19 @@ public class Admin implements KeywordExecutable {
     List<String> txList = new ArrayList<>();
 
     @Parameter(names = {"-c", "--cancel"},
-        description = "<txId>[ <txId>...] Cancel new or submitted FaTE transactions")
+        description = "<txId>... Cancel new or submitted FaTE transactions")
     boolean cancel;
 
     @Parameter(names = {"-f", "--fail"},
-        description = "<txId>[ <txId>...] Transition FaTE transaction status to FAILED_IN_PROGRESS (requires Manager to be down)")
+        description = "<txId>... Transition FaTE transaction status to FAILED_IN_PROGRESS (requires Manager to be down)")
     boolean fail;
 
     @Parameter(names = {"-d", "--delete"},
-        description = "<txId>[ <txId>...] Delete locks associated with transactions (Requires Manager to be down)")
+        description = "<txId>... Delete locks associated with transactions (Requires Manager to be down)")
     boolean delete;
 
-    @Parameter(names = {"-p", "--print", "-l", "--list"},
-        description = "[txId <txId>...] Print information about FaTE transactions. Print only the 'txId's specified or print all transactions if empty. Use -s to only print certain states.")
+    @Parameter(names = {"-p", "--print", "-print", "-l", "--list", "-list"},
+        description = "[<txId>...] Print information about FaTE transactions. Print only the 'txId's specified or print all transactions if empty. Use -s to only print certain states.")
     boolean print;
 
     @Parameter(names = "--summary", description = "Print a summary of all FaTE transactions")
@@ -250,7 +251,7 @@ public class Admin implements KeywordExecutable {
     boolean printJson;
 
     @Parameter(names = {"-s", "--state"},
-        description = "<state>[ -s <state>...] Print transactions in the state(s) {NEW, IN_PROGRESS, FAILED_IN_PROGRESS, FAILED, SUCCESSFUL}")
+        description = "<state>... Print transactions in the state(s) {NEW, IN_PROGRESS, FAILED_IN_PROGRESS, FAILED, SUCCESSFUL}")
     List<String> states = new ArrayList<>();
   }
 
@@ -282,9 +283,6 @@ public class Admin implements KeywordExecutable {
     JCommander cl = new JCommander(opts);
     cl.setProgramName("accumulo admin");
 
-    FateOpsCommand fateOpsCommand = new FateOpsCommand();
-    cl.addCommand("fate", fateOpsCommand);
-
     ChangeSecretCommand changeSecretCommand = new ChangeSecretCommand();
     cl.addCommand("changeSecret", changeSecretCommand);
 
@@ -297,6 +295,9 @@ public class Admin implements KeywordExecutable {
     DumpConfigCommand dumpConfigCommand = new DumpConfigCommand();
     cl.addCommand("dumpConfig", dumpConfigCommand);
 
+    FateOpsCommand fateOpsCommand = new FateOpsCommand();
+    cl.addCommand("fate", fateOpsCommand);
+
     ListInstancesCommand listInstancesOpts = new ListInstancesCommand();
     cl.addCommand("listInstances", listInstancesOpts);
 
@@ -797,13 +798,8 @@ public class Admin implements KeywordExecutable {
     if (fateOpsCommand.print) {
       final Set<Long> sortedTxs = new TreeSet<>();
       fateOpsCommand.txList.forEach(s -> sortedTxs.add(parseTidFromUserInput(s)));
-      if (!fateOpsCommand.txList.isEmpty()) {
-        EnumSet<ReadOnlyTStore.TStatus> statusFilter =
-            getCmdLineStatusFilters(fateOpsCommand.states);
-        admin.print(zs, zk, zTableLocksPath, new Formatter(System.out), sortedTxs, statusFilter);
-      } else {
-        admin.printAll(zs, zk, zTableLocksPath);
-      }
+      EnumSet<ReadOnlyTStore.TStatus> statusFilter = getCmdLineStatusFilters(fateOpsCommand.states);
+      admin.print(zs, zk, zTableLocksPath, new Formatter(System.out), sortedTxs, statusFilter);
       // print line break at the end
       System.out.println();
     }
@@ -830,10 +826,11 @@ public class Admin implements KeywordExecutable {
       long txid = Long.parseLong(txStr, 16);
       boolean cancelled = cancelFateOperation(context, txid);
       if (cancelled) {
-        System.out.println("FaTE transaction " + txid + " was cancelled or already completed.");
+        System.out.println("FaTE transaction " + FateTxId.formatTid(txid)
+            + " was cancelled or already completed.");
       } else {
-        System.out
-            .println("FaTE transaction " + txid + " was not cancelled, status may have changed.");
+        System.out.println("FaTE transaction " + FateTxId.formatTid(txid)
+            + " was not cancelled, status may have changed.");
       }
     }
   }