guluo2016 commented on code in PR #6231:
URL: https://github.com/apache/hbase/pull/6231#discussion_r1759972204


##########
hbase-server/src/main/java/org/apache/hadoop/hbase/mob/ExpiredMobFileCleaner.java:
##########
@@ -85,35 +85,33 @@ private void printUsage() {
   @edu.umd.cs.findbugs.annotations.SuppressWarnings(value = 
"REC_CATCH_EXCEPTION",
       justification = "Intentional")
   @Override
-  public int run(String[] args) throws Exception {
+  public int run(String[] args) throws IOException {
     if (args.length != 2) {
       printUsage();
       return 1;
     }
     String tableName = args[0];
     String familyName = args[1];
     TableName tn = TableName.valueOf(tableName);
-    Connection connection = ConnectionFactory.createConnection(getConf());
-    Admin admin = connection.getAdmin();
-    try {
+    try (Connection connection = ConnectionFactory.createConnection(getConf());
+      Admin admin = connection.getAdmin()) {
+      if (!admin.tableExists(tn)) {
+        throw new IOException("The table " + tableName + " doesn't exist");
+      }
       TableDescriptor htd = admin.getDescriptor(tn);

Review Comment:
   Yes,  admin.getDescriptor would throw TableNotFoundException when table 
doesn't exist.
   In here, What I mean is that we provide clear and concise information about 
that table doesn't exist, as following, maybe this would be better?
   ```
   ./bin/hbase org.apache.hadoop.hbase.mob.ExpiredMobFileCleaner  t01 in
   2024-09-15T14:02:26,263 WARN  [main {}] util.NativeCodeLoader: Unable to 
load native-hadoop library for your platform... using builtin-java classes 
where applicable
   2024-09-15T14:02:26,940 INFO  [RPCClient-NioEventLoopGroup-1-2 {}] 
Configuration.deprecation: hbase.client.pause.cqtbe is deprecated. Instead, use 
hbase.client.pause.server.overloaded
   2024-09-15T14:02:27,040 INFO  [main {}] client.AsyncConnectionImpl: 
Connection has been closed by main.
   Exception in thread "main" java.io.IOException: The table t01 doesn't exist
           at 
org.apache.hadoop.hbase.mob.ExpiredMobFileCleaner.run(ExpiredMobFileCleaner.java:99)
           at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:82)
           at 
org.apache.hadoop.hbase.mob.ExpiredMobFileCleaner.main(ExpiredMobFileCleaner.java:75)
   2024-09-15T14:02:27,050 INFO  [Registry-endpoints-refresh-end-points {}] 
client.RegistryEndpointsRefresher: Registry end points refresher loop exited.
   ```
   
   If we donot do this, when table does not exist, we will get the follow 
message.
   ```
   Exception in thread "main" org.apache.hadoop.hbase.TableNotFoundException: 
t04_mob01
           at java.base/java.lang.Thread.getStackTrace(Thread.java:1610)
           at 
org.apache.hadoop.hbase.util.FutureUtils.setStackTrace(FutureUtils.java:144)
           at 
org.apache.hadoop.hbase.util.FutureUtils.rethrow(FutureUtils.java:163)
           at org.apache.hadoop.hbase.util.FutureUtils.get(FutureUtils.java:186)
           at 
org.apache.hadoop.hbase.client.AdminOverAsyncAdmin.getDescriptor(AdminOverAsyncAdmin.java:172)
           at 
org.apache.hadoop.hbase.mob.ExpiredMobFileCleaner.run(ExpiredMobFileCleaner.java:99)
           at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:82)
           at 
org.apache.hadoop.hbase.mob.ExpiredMobFileCleaner.main(ExpiredMobFileCleaner.java:75)
           at -------Future.get-------(Unknown Source)
           at 
org.apache.hadoop.hbase.client.RawAsyncHBaseAdmin.lambda$getDescriptor$24(RawAsyncHBaseAdmin.java:654)
           at 
org.apache.hadoop.hbase.util.FutureUtils.lambda$addListener$0(FutureUtils.java:71)
           at 
java.base/java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:863)
           at 
java.base/java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:841)
           at 
java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
           at 
java.base/java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2147)
           at 
org.apache.hadoop.hbase.client.AsyncMasterRequestRpcRetryingCaller.lambda$doCall$4(AsyncMasterRequestRpcRetryingCaller.java:80)
           at 
org.apache.hadoop.hbase.util.FutureUtils.lambda$addListener$0(FutureUtils.java:71)
           at 
java.base/java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:863)
           at 
java.base/java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:841)
           at 
java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
           at 
java.base/java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2147)
           at 
org.apache.hadoop.hbase.client.RawAsyncHBaseAdmin$1.run(RawAsyncHBaseAdmin.java:467)
           at 
org.apache.hbase.thirdparty.com.google.protobuf.RpcUtil$1.run(RpcUtil.java:56)
   ```



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to