use of org.apache.hadoop.hbase.SingleProcessHBaseCluster in project hbase by apache.
the class TestRegionMover1 method testExcludeAndDesignated.
@Test
public void testExcludeAndDesignated() throws Exception {
SingleProcessHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
// create designated file
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();
// create exclude file
File excludeFile = new File(TEST_UTIL.getDataTestDir().toUri().getPath(), "exclude_file");
HRegionServer excludeServer = cluster.getRegionServer(1);
try (FileWriter fos = new FileWriter(excludeFile)) {
String excludeHostname = excludeServer.getServerName().getHostname();
int excludeServerPort = excludeServer.getServerName().getPort();
String excludeServerName = excludeHostname + ":" + excludeServerPort;
fos.write(excludeServerName);
}
int regionsInExcludeServer = excludeServer.getNumberOfOnlineRegions();
HRegionServer targetRegionServer = cluster.getRegionServer(2);
String rsName = targetRegionServer.getServerName().getHostname();
int port = targetRegionServer.getServerName().getPort();
String rs = rsName + ":" + port;
int regionsInTargetRegionServer = targetRegionServer.getNumberOfOnlineRegions();
RegionMoverBuilder rmBuilder = new RegionMoverBuilder(rs, TEST_UTIL.getConfiguration()).designatedFile(designatedFile.getCanonicalPath()).excludeFile(excludeFile.getCanonicalPath());
try (RegionMover rm = rmBuilder.build()) {
LOG.debug("Unloading {}", rs);
rm.unload();
assertEquals(0, targetRegionServer.getNumberOfOnlineRegions());
assertEquals(regionsInDesignatedServer + regionsInTargetRegionServer, designatedServer.getNumberOfOnlineRegions());
LOG.debug("DesignatedServer Before:{} After:{}", regionsInDesignatedServer, designatedServer.getNumberOfOnlineRegions());
assertEquals(regionsInExcludeServer, excludeServer.getNumberOfOnlineRegions());
LOG.debug("ExcludeServer Before:{} After:{}", regionsInExcludeServer, excludeServer.getNumberOfOnlineRegions());
}
}
use of org.apache.hadoop.hbase.SingleProcessHBaseCluster in project hbase by apache.
the class TestRegionMover1 method testWithoutAck.
/**
* Test to unload a regionserver first and then load it using no Ack mode.
*/
@Test
public void testWithoutAck() throws Exception {
SingleProcessHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
HRegionServer regionServer = cluster.getRegionServer(0);
String rsName = regionServer.getServerName().getAddress().toString();
int numRegions = regionServer.getNumberOfOnlineRegions();
RegionMoverBuilder rmBuilder = new RegionMoverBuilder(rsName, TEST_UTIL.getConfiguration()).ack(false);
try (RegionMover rm = rmBuilder.build()) {
LOG.info("Unloading " + regionServer.getServerName());
rm.unload();
TEST_UTIL.waitFor(30000, 1000, new Predicate<Exception>() {
@Override
public boolean evaluate() throws Exception {
return regionServer.getNumberOfOnlineRegions() == 0;
}
});
LOG.info("Successfully Unloaded\nNow Loading");
rm.load();
// In UT we only have 10 regions so it is not likely to fail, so here we check for all
// regions, in the real production this may not be true.
TEST_UTIL.waitFor(30000, 1000, new Predicate<Exception>() {
@Override
public boolean evaluate() throws Exception {
return regionServer.getNumberOfOnlineRegions() == numRegions;
}
});
}
}
use of org.apache.hadoop.hbase.SingleProcessHBaseCluster in project hbase by apache.
the class TestRegionMover1 method testExcludeAndDecomServers.
@Test
public void testExcludeAndDecomServers() throws Exception {
SingleProcessHBaseCluster 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();
String excludeServerName = excludeHostname + ":" + Integer.toString(excludeServerPort);
fos.write(excludeServerName);
fos.close();
HRegionServer decomServer = cluster.getRegionServer(2);
TEST_UTIL.getAdmin().decommissionRegionServers(Collections.singletonList(decomServer.getServerName()), false);
waitForServerDecom(decomServer);
HRegionServer regionServer = cluster.getRegionServer(0);
String rsName = regionServer.getServerName().getHostname();
int port = regionServer.getServerName().getPort();
String sourceServer = rsName + ":" + Integer.toString(port);
RegionMoverBuilder rmBuilder = new RegionMoverBuilder(sourceServer, TEST_UTIL.getConfiguration()).ack(true).excludeFile(excludeFile.getCanonicalPath());
try (RegionMover regionMover = rmBuilder.build()) {
Assert.assertFalse(regionMover.unload());
}
TEST_UTIL.getAdmin().recommissionRegionServer(decomServer.getServerName(), Collections.emptyList());
}
use of org.apache.hadoop.hbase.SingleProcessHBaseCluster in project hbase by apache.
the class TestRegionMover3 method setUpBeforeClass.
@BeforeClass
public static void setUpBeforeClass() throws Exception {
TEST_UTIL.startMiniCluster(3);
SingleProcessHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
rs0 = cluster.getRegionServer(0).getServerName();
rs1 = cluster.getRegionServer(1).getServerName();
rs2 = cluster.getRegionServer(2).getServerName();
TEST_UTIL.getAdmin().balancerSwitch(false, true);
}
use of org.apache.hadoop.hbase.SingleProcessHBaseCluster in project hbase by apache.
the class TestRegionMover1 method testWithAck.
@Test
public void testWithAck() throws Exception {
SingleProcessHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
HRegionServer regionServer = cluster.getRegionServer(0);
String rsName = regionServer.getServerName().getAddress().toString();
int numRegions = regionServer.getNumberOfOnlineRegions();
RegionMoverBuilder rmBuilder = new RegionMoverBuilder(rsName, TEST_UTIL.getConfiguration()).ack(true).maxthreads(8);
try (RegionMover rm = rmBuilder.build()) {
LOG.info("Unloading " + regionServer.getServerName());
rm.unload();
assertEquals(0, regionServer.getNumberOfOnlineRegions());
LOG.info("Successfully Unloaded\nNow Loading");
rm.load();
assertEquals(numRegions, regionServer.getNumberOfOnlineRegions());
// Repeat the same load. It should be very fast because all regions are already moved.
rm.load();
}
}
Aggregations