From f5a332deb0fbd1b809f2f3058711043f98acfe68 Mon Sep 17 00:00:00 2001 From: "terence.yoo" Date: Fri, 29 Jul 2016 16:19:25 +0900 Subject: [PATCH] shut down ExecutorService always --- .../kakao/hbase/manager/command/Merge.java | 31 ++++++++++--------- .../com/kakao/hbase/stat/load/TableInfo.java | 12 ++++--- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/hbase0.98/hbase-manager-0.98/src/main/java/com/kakao/hbase/manager/command/Merge.java b/hbase0.98/hbase-manager-0.98/src/main/java/com/kakao/hbase/manager/command/Merge.java index aca63ee..cb4c7fc 100644 --- a/hbase0.98/hbase-manager-0.98/src/main/java/com/kakao/hbase/manager/command/Merge.java +++ b/hbase0.98/hbase-manager-0.98/src/main/java/com/kakao/hbase/manager/command/Merge.java @@ -308,23 +308,26 @@ private List findEmptyRegionsInternal(TableInfo tableInfo) throws E tableInfo.refresh(); ExecutorService executorService = Executors.newFixedThreadPool(EmptyRegionChecker.THREAD_POOL_SIZE); - EmptyRegionChecker.resetCounter(); - - Set allTableRegions = tableInfo.getRegionInfoSet(); - for (HRegionInfo regionInfo : allTableRegions) { - RegionLoadDelegator regionLoad = tableInfo.getRegionLoad(regionInfo); - if (regionLoad == null) { - Util.printMessage("RegionLoad is empty - " + regionInfo); - throw new IllegalStateException(Constant.MESSAGE_NEED_REFRESH); - } + try { + EmptyRegionChecker.resetCounter(); + + Set allTableRegions = tableInfo.getRegionInfoSet(); + for (HRegionInfo regionInfo : allTableRegions) { + RegionLoadDelegator regionLoad = tableInfo.getRegionLoad(regionInfo); + if (regionLoad == null) { + Util.printMessage("RegionLoad is empty - " + regionInfo); + throw new IllegalStateException(Constant.MESSAGE_NEED_REFRESH); + } - if (regionLoad.getStorefileSizeMB() == 0 && regionLoad.getMemStoreSizeMB() == 0) { - executorService.execute( - new EmptyRegionChecker(connection, tableInfo.getTableName(), regionInfo, emptyRegions)); + if (regionLoad.getStorefileSizeMB() == 0 && regionLoad.getMemStoreSizeMB() == 0) { + executorService.execute( + new EmptyRegionChecker(connection, tableInfo.getTableName(), regionInfo, emptyRegions)); + } } + } finally { + executorService.shutdown(); + executorService.awaitTermination(30, TimeUnit.MINUTES); } - executorService.shutdown(); - executorService.awaitTermination(30, TimeUnit.MINUTES); Util.printMessage(emptyRegions.size() + " empty regions are found."); Util.printVerboseMessage(args, Util.getMethodName(), timestamp); diff --git a/hbase0.98/hbase-table-stat-0.98/src/main/java/com/kakao/hbase/stat/load/TableInfo.java b/hbase0.98/hbase-table-stat-0.98/src/main/java/com/kakao/hbase/stat/load/TableInfo.java index dfcce2b..3dc15d7 100644 --- a/hbase0.98/hbase-table-stat-0.98/src/main/java/com/kakao/hbase/stat/load/TableInfo.java +++ b/hbase0.98/hbase-table-stat-0.98/src/main/java/com/kakao/hbase/stat/load/TableInfo.java @@ -128,10 +128,14 @@ private void clean(NavigableMap regionServerMap) throws Set tableNameSet = tableNameSet(regionServerMap); ExecutorService executorService = Executors.newFixedThreadPool(RegionLocationCleaner.THREAD_POOL_SIZE); - for (String tableName : tableNameSet) - executorService.execute(new RegionLocationCleaner(tableName, admin.getConfiguration(), regionServerMap)); - executorService.shutdown(); - executorService.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS); + try { + for (String tableName : tableNameSet) + executorService.execute( + new RegionLocationCleaner(tableName, admin.getConfiguration(), regionServerMap)); + } finally { + executorService.shutdown(); + executorService.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS); + } Util.printVerboseMessage(args, "TableInfo.clean", timestamp); }