@Test
  public void testDesignatedFile() throws Exception {
    SingleProcessHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
    File designatedFile = new File(TEST_UTIL.getDataTestDir().toUri().getPath(), "designated_file");
    HRegionServer designatedServer = cluster.getRegionServer(0);
    try (FileWriter fos = new FileWriter(designatedFile)) {
      String designatedHostname = designatedServer.getServerName().getHostname();
      int designatedServerPort = designatedServer.getServerName().getPort();
      String excludeServerName = designatedHostname + ":" + designatedServerPort;
      fos.write(excludeServerName);
    }
    int regionsInDesignatedServer = designatedServer.getNumberOfOnlineRegions();
    HRegionServer regionServer = cluster.getRegionServer(1);
    String rsName = regionServer.getServerName().getHostname();
    int port = regionServer.getServerName().getPort();
    String rs = rsName + ":" + port;
    int regionsInRegionServer = regionServer.getNumberOfOnlineRegions();
    RegionMoverBuilder rmBuilder = new RegionMoverBuilder(rs, TEST_UTIL.getConfiguration())
      .designatedFile(designatedFile.getCanonicalPath());
    try (RegionMover rm = rmBuilder.build()) {
      LOG.debug("Unloading {} regions", rs);
      rm.unload();
      assertEquals(0, regionServer.getNumberOfOnlineRegions());
      assertEquals(regionsInDesignatedServer + regionsInRegionServer,
        designatedServer.getNumberOfOnlineRegions());
      LOG.debug("Before:{} After:{}", regionsInDesignatedServer,
        designatedServer.getNumberOfOnlineRegions());
    }
  }
To test that we successfully exclude a server from the unloading process We test for the number
of regions on Excluded server and also test that regions are unloaded successfully
hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestRegionMover1.java