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

dlmarion 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 73d811e018 Run FindCompactionTmpFiles utility via accumulo Admin 
(#4465)
73d811e018 is described below

commit 73d811e01847de093619e7fc22ecbac478b68e55
Author: Arbaaz Khan <[email protected]>
AuthorDate: Thu Feb 12 13:43:06 2026 -0500

    Run FindCompactionTmpFiles utility via accumulo Admin (#4465)
---
 .../server/util/FindCompactionTmpFiles.java        | 99 +++++++++++++---------
 .../FindCompactionTmpFilesIT_SimpleSuite.java      |  5 +-
 .../apache/accumulo/test/start/KeywordStartIT.java |  2 +
 3 files changed, 65 insertions(+), 41 deletions(-)

diff --git 
a/server/base/src/main/java/org/apache/accumulo/server/util/FindCompactionTmpFiles.java
 
b/server/base/src/main/java/org/apache/accumulo/server/util/FindCompactionTmpFiles.java
index be95a9a800..97174a33b0 100644
--- 
a/server/base/src/main/java/org/apache/accumulo/server/util/FindCompactionTmpFiles.java
+++ 
b/server/base/src/main/java/org/apache/accumulo/server/util/FindCompactionTmpFiles.java
@@ -36,26 +36,60 @@ import 
org.apache.accumulo.core.metadata.schema.Ample.DataLevel;
 import org.apache.accumulo.core.metadata.schema.ExternalCompactionId;
 import org.apache.accumulo.core.metadata.schema.TabletMetadata.ColumnType;
 import org.apache.accumulo.core.metadata.schema.TabletsMetadata;
-import org.apache.accumulo.core.trace.TraceUtil;
 import org.apache.accumulo.core.util.UtilWaitThread;
 import org.apache.accumulo.core.volume.Volume;
 import org.apache.accumulo.server.ServerContext;
 import org.apache.accumulo.server.cli.ServerUtilOpts;
+import org.apache.accumulo.start.spi.KeywordExecutable;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.Path;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.beust.jcommander.JCommander;
 import com.beust.jcommander.Parameter;
+import com.beust.jcommander.Parameters;
+import com.google.auto.service.AutoService;
 
-import io.opentelemetry.api.trace.Span;
-import io.opentelemetry.context.Scope;
-
-public class FindCompactionTmpFiles {
+@AutoService(KeywordExecutable.class)
+public class FindCompactionTmpFiles implements KeywordExecutable {
 
   private static final Logger LOG = 
LoggerFactory.getLogger(FindCompactionTmpFiles.class);
 
-  static class Opts extends ServerUtilOpts {
+  @Override
+  public String keyword() {
+    return "find";
+  }
+
+  @Override
+  public String description() {
+    return "Compaction Temp Files Utility";
+  }
+
+  @Override
+  public UsageGroup usageGroup() {
+    return UsageGroup.COMPACTION;
+  }
+
+  @Override
+  public void execute(String[] args) throws Exception {
+    ServerUtilOpts opts = new ServerUtilOpts();
+    JCommander cl = new JCommander(opts);
+    cl.setProgramName("accumulo " + usageGroup().name().toLowerCase() + " " + 
keyword());
+
+    FindCompactionTmpFilesCommand findOps = new 
FindCompactionTmpFilesCommand();
+    cl.addCommand(findOps);
+    cl.parse(args);
+    if (opts.help || cl.getParsedCommand() == null) {
+      cl.usage();
+      return;
+    }
+    ServerContext context = opts.getServerContext();
+    findCompTmpFiles(context, findOps.tables, findOps.delete);
+  }
+
+  @Parameters(commandNames = "find", commandDescription = "Find compaction 
temporary files")
+  static class FindCompactionTmpFilesCommand extends ServerUtilOpts {
 
     @Parameter(names = "--tables", description = "comma separated list of 
table names")
     String tables;
@@ -183,44 +217,33 @@ public class FindCompactionTmpFiles {
     return stats;
   }
 
-  public static void main(String[] args) throws Exception {
-    Opts opts = new Opts();
-    opts.parseArgs(FindCompactionTmpFiles.class.getName(), args);
-    LOG.info("Looking for compaction tmp files over tables: {}, deleting: {}", 
opts.tables,
-        opts.delete);
-
-    Span span = TraceUtil.startSpan(FindCompactionTmpFiles.class, "main");
-    try (Scope scope = span.makeCurrent()) {
-
-      ServerContext context = opts.getServerContext();
-      String[] tables = opts.tables.split(",");
+  public static void findCompTmpFiles(ServerContext context, final String 
tablesToSearch,
+      final boolean delete) throws Exception {
+    LOG.info("Looking for compaction tmp files over tables: {}, deleting: {}", 
tablesToSearch,
+        delete);
 
-      final var stringStringMap = context.tableOperations().tableIdMap();
-      for (String table : tables) {
+    String[] tables = tablesToSearch.split(",");
+    for (String table : tables) {
 
-        table = table.trim();
-        String tableId = stringStringMap.get(table);
-        if (tableId == null || tableId.isEmpty()) {
-          LOG.warn("TableId for table: {} does not exist, maybe the table was 
deleted?", table);
-          continue;
-        }
-
-        final Set<Path> matches = findTempFiles(context, tableId);
-        LOG.info("Found the following compaction tmp files for table {}:", 
table);
-        matches.forEach(p -> LOG.info("{}", p));
+      table = table.trim();
+      String tableId = context.tableOperations().tableIdMap().get(table);
+      if (tableId == null || tableId.isEmpty()) {
+        LOG.warn("TableId for table: {} does not exist, maybe the table was 
deleted?", table);
+        continue;
+      }
 
-        if (opts.delete) {
-          LOG.info("Deleting compaction tmp files for table {}...", table);
-          DeleteStats stats = deleteTempFiles(context, matches);
-          LOG.info(
-              "Deletion of compaction tmp files for table {} complete. 
Success:{}, Failure:{}, Error:{}",
-              table, stats.success, stats.failure, stats.error);
-        }
+      final Set<Path> matches = findTempFiles(context, tableId);
+      LOG.info("Found the following compaction tmp files for table {}:", 
table);
+      matches.forEach(p -> LOG.info("{}", p));
 
+      if (delete) {
+        LOG.info("Deleting compaction tmp files for table {}...", table);
+        DeleteStats stats = deleteTempFiles(context, matches);
+        LOG.info(
+            "Deletion of compaction tmp files for table {} complete. 
Success:{}, Failure:{}, Error:{}",
+            table, stats.success, stats.failure, stats.error);
       }
 
-    } finally {
-      span.end();
     }
   }
 
diff --git 
a/test/src/main/java/org/apache/accumulo/test/functional/FindCompactionTmpFilesIT_SimpleSuite.java
 
b/test/src/main/java/org/apache/accumulo/test/functional/FindCompactionTmpFilesIT_SimpleSuite.java
index aa56f17ba2..ec0649db36 100644
--- 
a/test/src/main/java/org/apache/accumulo/test/functional/FindCompactionTmpFilesIT_SimpleSuite.java
+++ 
b/test/src/main/java/org/apache/accumulo/test/functional/FindCompactionTmpFilesIT_SimpleSuite.java
@@ -160,7 +160,7 @@ public class FindCompactionTmpFilesIT_SimpleSuite extends 
SharedMiniClusterBase
 
       System.setProperty("accumulo.properties",
           "file://" + getCluster().getAccumuloPropertiesPath());
-      FindCompactionTmpFiles.main(new String[] {"--tables", tableName});
+      FindCompactionTmpFiles.findCompTmpFiles(getCluster().getServerContext(), 
tableName, false);
 
       foundPaths = FindCompactionTmpFiles.findTempFiles(ctx, tid.canonical());
       assertEquals(100, foundPaths.size());
@@ -208,12 +208,11 @@ public class FindCompactionTmpFilesIT_SimpleSuite extends 
SharedMiniClusterBase
 
       System.setProperty("accumulo.properties",
           "file://" + getCluster().getAccumuloPropertiesPath());
-      FindCompactionTmpFiles.main(new String[] {"--tables", tableName, 
"--delete"});
+      FindCompactionTmpFiles.findCompTmpFiles(getCluster().getServerContext(), 
tableName, true);
 
       foundPaths = FindCompactionTmpFiles.findTempFiles(ctx, tid.canonical());
       assertEquals(0, foundPaths.size());
 
     }
   }
-
 }
diff --git 
a/test/src/main/java/org/apache/accumulo/test/start/KeywordStartIT.java 
b/test/src/main/java/org/apache/accumulo/test/start/KeywordStartIT.java
index dccd971187..6fd9dcc3dd 100644
--- a/test/src/main/java/org/apache/accumulo/test/start/KeywordStartIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/start/KeywordStartIT.java
@@ -60,6 +60,7 @@ import org.apache.accumulo.server.conf.util.ZooPropEditor;
 import org.apache.accumulo.server.init.Initialize;
 import org.apache.accumulo.server.util.CancelCompaction;
 import org.apache.accumulo.server.util.DumpZookeeper;
+import org.apache.accumulo.server.util.FindCompactionTmpFiles;
 import org.apache.accumulo.server.util.Info;
 import org.apache.accumulo.server.util.ListCompactions;
 import org.apache.accumulo.server.util.ListCompactors;
@@ -211,6 +212,7 @@ public class KeywordStartIT {
     expectSet.add(new CommandInfo(UsageGroup.COMPACTION, "cancel", 
CancelCompaction.class));
     expectSet.add(new CommandInfo(UsageGroup.PROCESS, "list-compactors", 
ListCompactors.class));
     expectSet.add(new CommandInfo(UsageGroup.COMPACTION, "list", 
ListCompactions.class));
+    expectSet.add(new CommandInfo(UsageGroup.COMPACTION, "find", 
FindCompactionTmpFiles.class));
 
     Map<UsageGroup,Map<String,KeywordExecutable>> actualExecutables =
         new TreeMap<>(getKeywordExecutables());

Reply via email to