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


##########
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:
   I'm sorry that you misunderstood this. 
   Let's ignore the previous example, and then I'll give a new one to 
illustrate.
   
   Now, we want to manually execute ExpiredMobFileCleaner to clean expired MOB 
files of a MOB table.
   But, we mistakenly specified a non-existing table in hbase cluster (Assuming 
that the table name we specify is non_existing_table).
   
   So, Before applying this commit, we get the following message.
   ```shell
   [root@hbase001 hbase-4.0.0-alpha-1-SNAPSHOT]# ./bin/hbase 
org.apache.hadoop.hbase.mob.ExpiredMobFileCleaner non_existing_table info
   2024-09-18T18:49:46,512 WARN  [main {}] util.NativeCodeLoader: Unable to 
load native-hadoop library for your platform... using builtin-java classes 
where applicable
   2024-09-18T18:49:47,331 INFO  [RPCClient-NioEventLoopGroup-1-2 {}] 
Configuration.deprecation: hbase.client.pause.cqtbe is deprecated. Instead, use 
hbase.client.pause.server.overloaded
   2024-09-18T18:49:47,413 INFO  [main {}] client.AsyncConnectionImpl: 
Connection has been closed by main.
   Exception in thread "main" org.apache.hadoop.hbase.TableNotFoundException: 
non_existing_table
           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)
           at 
org.apache.hbase.thirdparty.com.google.protobuf.RpcUtil$1.run(RpcUtil.java:47)
           at 
org.apache.hadoop.hbase.ipc.AbstractRpcClient.onCallFinished(AbstractRpcClient.java:400)
           at 
org.apache.hadoop.hbase.ipc.AbstractRpcClient$3.run(AbstractRpcClient.java:430)
           at 
org.apache.hadoop.hbase.ipc.AbstractRpcClient$3.run(AbstractRpcClient.java:425)
           at org.apache.hadoop.hbase.ipc.Call.callComplete(Call.java:117)
           at org.apache.hadoop.hbase.ipc.Call.setResponse(Call.java:149)
           at 
org.apache.hadoop.hbase.ipc.RpcConnection.finishCall(RpcConnection.java:396)
           at 
org.apache.hadoop.hbase.ipc.RpcConnection.readResponse(RpcConnection.java:461)
           at 
org.apache.hadoop.hbase.ipc.NettyRpcDuplexHandler.readResponse(NettyRpcDuplexHandler.java:125)
           at 
org.apache.hadoop.hbase.ipc.NettyRpcDuplexHandler.channelRead(NettyRpcDuplexHandler.java:140)
   ...
   ```
   
   After applying this commit, we would get **clear and concise information** 
about that table doesn't exist, as following.
   ```
    ./bin/hbase org.apache.hadoop.hbase.mob.ExpiredMobFileCleaner 
non_existing_table info
   2024-09-18T18:50:22,049 WARN  [main {}] util.NativeCodeLoader: Unable to 
load native-hadoop library for your platform... using builtin-java classes 
where applicable
   2024-09-18T18:50:22,795 INFO  [RPCClient-NioEventLoopGroup-1-2 {}] 
Configuration.deprecation: hbase.client.pause.cqtbe is deprecated. Instead, use 
hbase.client.pause.server.overloaded
   2024-09-18T18:50:22,907 INFO  [main {}] client.AsyncConnectionImpl: 
Connection has been closed by main.
   Exception in thread "main" 2024-09-18T18:50:22,912 INFO  
[Registry-endpoints-refresh-end-points {}] client.RegistryEndpointsRefresher: 
Registry end points refresher loop exited.
   java.io.IOException: The table non_existing_table 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)
   ```



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