Skip to content

Commit

Permalink
shut down ExecutorService always
Browse files Browse the repository at this point in the history
  • Loading branch information
terence-yoo committed Jul 29, 2016
1 parent e0ec8a1 commit f5a332d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -308,23 +308,26 @@ private List<HRegionInfo> findEmptyRegionsInternal(TableInfo tableInfo) throws E
tableInfo.refresh();

ExecutorService executorService = Executors.newFixedThreadPool(EmptyRegionChecker.THREAD_POOL_SIZE);
EmptyRegionChecker.resetCounter();

Set<HRegionInfo> 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<HRegionInfo> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,14 @@ private void clean(NavigableMap<HRegionInfo, ServerName> regionServerMap) throws
Set<String> 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);
}
Expand Down

0 comments on commit f5a332d

Please sign in to comment.