From b161ad573e6ede257528a2b0802e07e6a6c8eccb Mon Sep 17 00:00:00 2001 From: WangXin <1458451310@qq.com> Date: Fri, 6 Sep 2024 21:07:23 +0800 Subject: [PATCH] HBASE-28807 Remove some useless code and add some logs for CanaryTool (#6187) Co-authored-by: wangxin Signed-off-by: Nihal Jain --- .../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 21e9edfe0688..f21edd176d4e 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 @@ -1734,26 +1734,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); } } @@ -1959,7 +1955,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();