From 6c0d53361ab8a2323cb00fcc61afe88c6ee9b63f Mon Sep 17 00:00:00 2001 From: wangxin Date: Sat, 31 Aug 2024 17:04:45 +0800 Subject: [PATCH] HBASE-28807 Remove some useless code and add some logs for CanaryTool --- .../apache/hadoop/hbase/tool/CanaryTool.java | 34 ++++++++----------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/CanaryTool.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/CanaryTool.java index 92dca7c24c92..44f241817db0 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/CanaryTool.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/CanaryTool.java @@ -1699,26 +1699,22 @@ private static List> sniff(final Admin admin, final Sink sink, TableDescriptor tableDesc, ExecutorService executor, TaskType taskType, boolean rawScanEnabled, LongAdder rwLatency, boolean readAllCF) throws Exception { LOG.debug("Reading list of regions for table {}", tableDesc.getTableName()); - try (Table table = admin.getConnection().getTable(tableDesc.getTableName())) { - List tasks = new ArrayList<>(); - try (RegionLocator regionLocator = - admin.getConnection().getRegionLocator(tableDesc.getTableName())) { - for (HRegionLocation location : regionLocator.getAllRegionLocations()) { - if (location == null) { - LOG.warn("Null location"); - continue; - } - ServerName rs = location.getServerName(); - RegionInfo region = location.getRegion(); - tasks.add(new RegionTask(admin.getConnection(), region, rs, (RegionStdOutSink) sink, - taskType, rawScanEnabled, rwLatency, readAllCF)); - Map> regionMap = ((RegionStdOutSink) sink).getRegionMap(); - regionMap.put(region.getRegionNameAsString(), new ArrayList()); + List tasks = new ArrayList<>(); + try (RegionLocator regionLocator = + admin.getConnection().getRegionLocator(tableDesc.getTableName())) { + for (HRegionLocation location : regionLocator.getAllRegionLocations()) { + if (location == null) { + LOG.warn("Null location for table {}", tableDesc.getTableName()); + continue; } - return executor.invokeAll(tasks); + ServerName rs = location.getServerName(); + RegionInfo region = location.getRegion(); + tasks.add(new RegionTask(admin.getConnection(), region, rs, (RegionStdOutSink) sink, + taskType, rawScanEnabled, rwLatency, readAllCF)); + Map> regionMap = ((RegionStdOutSink) sink).getRegionMap(); + regionMap.put(region.getRegionNameAsString(), new ArrayList()); } - } catch (TableNotFoundException e) { - return Collections.EMPTY_LIST; + return executor.invokeAll(tasks); } } @@ -1924,7 +1920,7 @@ private Map> getAllRegionServerByName() { this.admin.getConnection().getRegionLocator(tableDesc.getTableName())) { for (HRegionLocation location : regionLocator.getAllRegionLocations()) { if (location == null) { - LOG.warn("Null location"); + LOG.warn("Null location for table {}", tableDesc.getTableName()); continue; } ServerName rs = location.getServerName();