Search in sources :

Example 1 with RegionMoverBuilder

use of org.apache.hadoop.hbase.util.RegionMover.RegionMoverBuilder in project hbase by apache.

the class TestRegionMover method testUnloadWithAck.

@Test
public void testUnloadWithAck() throws Exception {
    MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
    HRegionServer regionServer = cluster.getRegionServer(0);
    String rsName = regionServer.getServerName().getHostname();
    int port = regionServer.getServerName().getPort();
    String rs = rsName + ":" + Integer.toString(port);
    RegionMoverBuilder rmBuilder = new RegionMoverBuilder(rs).ack(true);
    RegionMover rm = rmBuilder.build();
    rm.setConf(TEST_UTIL.getConfiguration());
    rm.unload();
    LOG.info("Unloading " + rs);
    assertEquals(0, regionServer.getNumberOfOnlineRegions());
}
Also used : RegionMoverBuilder(org.apache.hadoop.hbase.util.RegionMover.RegionMoverBuilder) MiniHBaseCluster(org.apache.hadoop.hbase.MiniHBaseCluster) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer) Test(org.junit.Test)

Example 2 with RegionMoverBuilder

use of org.apache.hadoop.hbase.util.RegionMover.RegionMoverBuilder in project hbase by apache.

the class TestRegionMover method testUnloadWithoutAck.

@Test
public void testUnloadWithoutAck() throws Exception {
    MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
    final HRegionServer regionServer = cluster.getRegionServer(0);
    final int noRegions = regionServer.getNumberOfOnlineRegions();
    String rsName = regionServer.getServerName().getHostname();
    int port = regionServer.getServerName().getPort();
    String rs = rsName + ":" + Integer.toString(port);
    RegionMoverBuilder rmBuilder = new RegionMoverBuilder(rs).ack(false);
    RegionMover rm = rmBuilder.build();
    rm.setConf(TEST_UTIL.getConfiguration());
    LOG.info("Unloading " + rs);
    rm.unload();
    TEST_UTIL.waitFor(5000, 500, new Predicate<Exception>() {

        @Override
        public boolean evaluate() throws Exception {
            return regionServer.getNumberOfOnlineRegions() < noRegions;
        }
    });
}
Also used : RegionMoverBuilder(org.apache.hadoop.hbase.util.RegionMover.RegionMoverBuilder) MiniHBaseCluster(org.apache.hadoop.hbase.MiniHBaseCluster) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer) Test(org.junit.Test)

Example 3 with RegionMoverBuilder

use of org.apache.hadoop.hbase.util.RegionMover.RegionMoverBuilder in project hbase by apache.

the class TestRegionMover method testExclude.

/**
   * 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
   * @throws Exception
   */
@Test
public void testExclude() throws Exception {
    MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
    File excludeFile = new File(TEST_UTIL.getDataTestDir().toUri().getPath(), "exclude_file");
    FileWriter fos = new FileWriter(excludeFile);
    HRegionServer excludeServer = cluster.getRegionServer(1);
    String excludeHostname = excludeServer.getServerName().getHostname();
    int excludeServerPort = excludeServer.getServerName().getPort();
    int regionsExcludeServer = excludeServer.getNumberOfOnlineRegions();
    String excludeServerName = excludeHostname + ":" + Integer.toString(excludeServerPort);
    fos.write(excludeServerName);
    fos.close();
    HRegionServer regionServer = cluster.getRegionServer(0);
    String rsName = regionServer.getServerName().getHostname();
    int port = regionServer.getServerName().getPort();
    String rs = rsName + ":" + Integer.toString(port);
    RegionMoverBuilder rmBuilder = new RegionMoverBuilder(rs).ack(true).excludeFile(excludeFile.getCanonicalPath());
    RegionMover rm = rmBuilder.build();
    rm.setConf(TEST_UTIL.getConfiguration());
    rm.unload();
    LOG.info("Unloading " + rs);
    assertEquals(0, regionServer.getNumberOfOnlineRegions());
    assertEquals(regionsExcludeServer, cluster.getRegionServer(1).getNumberOfOnlineRegions());
    LOG.info("Before:" + regionsExcludeServer + " After:" + cluster.getRegionServer(1).getNumberOfOnlineRegions());
}
Also used : FileWriter(java.io.FileWriter) RegionMoverBuilder(org.apache.hadoop.hbase.util.RegionMover.RegionMoverBuilder) MiniHBaseCluster(org.apache.hadoop.hbase.MiniHBaseCluster) File(java.io.File) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer) Test(org.junit.Test)

Example 4 with RegionMoverBuilder

use of org.apache.hadoop.hbase.util.RegionMover.RegionMoverBuilder in project hbase by apache.

the class TestRegionMover method testLoadWithoutAck.

/** Test to unload a regionserver first and then load it using no Ack mode
   * we check if some regions are loaded on the region server(since no ack is best effort)
   * @throws Exception
   */
@Test
public void testLoadWithoutAck() throws Exception {
    MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
    final HRegionServer regionServer = cluster.getRegionServer(0);
    String rsName = regionServer.getServerName().getHostname();
    int port = regionServer.getServerName().getPort();
    int noRegions = regionServer.getNumberOfOnlineRegions();
    String rs = rsName + ":" + Integer.toString(port);
    RegionMoverBuilder rmBuilder = new RegionMoverBuilder(rs).ack(true);
    RegionMover rm = rmBuilder.build();
    rm.setConf(TEST_UTIL.getConfiguration());
    LOG.info("Unloading " + rs);
    rm.unload();
    assertEquals(0, regionServer.getNumberOfOnlineRegions());
    LOG.info("Successfully Unloaded\nNow Loading");
    rm = rmBuilder.ack(false).build();
    rm.setConf(TEST_UTIL.getConfiguration());
    rm.load();
    TEST_UTIL.waitFor(5000, 500, new Predicate<Exception>() {

        @Override
        public boolean evaluate() throws Exception {
            return regionServer.getNumberOfOnlineRegions() > 0;
        }
    });
}
Also used : RegionMoverBuilder(org.apache.hadoop.hbase.util.RegionMover.RegionMoverBuilder) MiniHBaseCluster(org.apache.hadoop.hbase.MiniHBaseCluster) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer) Test(org.junit.Test)

Example 5 with RegionMoverBuilder

use of org.apache.hadoop.hbase.util.RegionMover.RegionMoverBuilder in project hbase by apache.

the class TestRegionMover method testLoadWithAck.

@Test
public void testLoadWithAck() throws Exception {
    MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
    HRegionServer regionServer = cluster.getRegionServer(0);
    String rsName = regionServer.getServerName().getHostname();
    int port = regionServer.getServerName().getPort();
    int noRegions = regionServer.getNumberOfOnlineRegions();
    String rs = rsName + ":" + Integer.toString(port);
    RegionMoverBuilder rmBuilder = new RegionMoverBuilder(rs).ack(true).maxthreads(8);
    RegionMover rm = rmBuilder.build();
    rm.setConf(TEST_UTIL.getConfiguration());
    LOG.info("Unloading " + rs);
    rm.unload();
    assertEquals(0, regionServer.getNumberOfOnlineRegions());
    LOG.info("Successfully Unloaded\nNow Loading");
    rm.load();
    assertEquals(noRegions, regionServer.getNumberOfOnlineRegions());
}
Also used : RegionMoverBuilder(org.apache.hadoop.hbase.util.RegionMover.RegionMoverBuilder) MiniHBaseCluster(org.apache.hadoop.hbase.MiniHBaseCluster) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer) Test(org.junit.Test)

Aggregations

MiniHBaseCluster (org.apache.hadoop.hbase.MiniHBaseCluster)5 HRegionServer (org.apache.hadoop.hbase.regionserver.HRegionServer)5 RegionMoverBuilder (org.apache.hadoop.hbase.util.RegionMover.RegionMoverBuilder)5 Test (org.junit.Test)5 File (java.io.File)1 FileWriter (java.io.FileWriter)1