Source:
public boolean unload() throws InterruptedException, ExecutionException, TimeoutException { deleteFile(this.filename); ExecutorService unloadPool = Executors.newFixedThreadPool(1); Future<Boolean> unloadTask = unloadPool.submit(() -> { List<RegionInfo> movedRegions = Collections.synchronizedList(new ArrayList<>()); try { List<ServerName> regionServers = new ArrayList<>(); RSGroupInfo rsgroup = admin.getRSGroup(Address.fromParts(hostname, port)); LOG.info("{} belongs to {}", hostname, rsgroup.getName()); regionServers.addAll(filterRSGroupServers(rsgroup, admin.getRegionServers())); ServerName server = stripServer(regionServers, hostname, port); if (server == null) { LOG.info("Could not find server '{}:{}' in the set of region servers. giving up.", hostname, port); LOG.debug("List of region servers: {}", regionServers); return false; } if (designatedFile != null) { filterDesignatedServers(regionServers); } stripExcludes(regionServers); Set<ServerName> decommissionedRS = new HashSet<>(admin.listDecommissionedRegionServers()); if (CollectionUtils.isNotEmpty(decommissionedRS)) { regionServers.removeIf(decommissionedRS::contains); LOG.debug("Excluded RegionServers from unloading regions to because they " + "are marked as decommissioned. Servers: {}", decommissionedRS); } stripMaster(regionServers); if (regionServers.isEmpty()) { LOG.warn("No Regions were moved - no servers available"); return false; } else { LOG.info("Available servers {}", regionServers); } unloadRegions(server, regionServers, movedRegions); } catch (Exception e) { LOG.error("Error while unloading regions ", e); return false; } finally { if (movedRegions != null) { writeFile(filename, movedRegions); } } return true; }); return waitTaskToFinish(unloadPool, unloadTask, "unloading"); }

Target:
public boolean unload() throws InterruptedException, ExecutionException, TimeoutException { deleteFile(this.filename); ExecutorService unloadPool = Executors.newFixedThreadPool(1); Future<Boolean> unloadTask = unloadPool.submit(() -> { List<RegionInfo> movedRegions = Collections.synchronizedList(new ArrayList<>()); try { List<ServerName> regionServers = new ArrayList<>(); RSGroupInfo rsgroup = admin.getRSGroup(Address.fromParts(hostname, port)); LOG.info("{} belongs to {}", hostname, rsgroup.getName()); regionServers.addAll(filterRSGroupServers(rsgroup, admin.getRegionServers())); ServerName server = stripServer(regionServers, hostname, port); if (server == null) { LOG.info("Could not find server '{}:{}' in the set of region servers. giving up.", hostname, port); LOG.debug("List of region servers: {}", regionServers); return false; } includeExcludeRegionServers(designatedFile, regionServers, true); includeExcludeRegionServers(excludeFile, regionServers, false); Set<ServerName> decommissionedRS = new HashSet<>(admin.listDecommissionedRegionServers()); if (CollectionUtils.isNotEmpty(decommissionedRS)) { regionServers.removeIf(decommissionedRS::contains); LOG.debug("Excluded RegionServers from unloading regions to because they " + "are marked as decommissioned. Servers: {}", decommissionedRS); } stripMaster(regionServers); if (regionServers.isEmpty()) { LOG.warn("No Regions were moved - no servers available"); return false; } else { LOG.info("Available servers {}", regionServers); } unloadRegions(server, regionServers, movedRegions); } catch (Exception e) { LOG.error("Error while unloading regions ", e); return false; } finally { if (movedRegions != null) { writeFile(filename, movedRegions); } } return true; }); return waitTaskToFinish(unloadPool, unloadTask, "unloading"); }