use of org.apache.hadoop.hbase.regionserver.HRegionServer in project hbase by apache.
the class TestSplitWALProcedure method testMasterRestart.
@Test
public void testMasterRestart() throws Exception {
Table table = TEST_UTIL.createTable(TABLE_NAME, FAMILY, TEST_UTIL.KEYS_FOR_HBA_CREATE_TABLE);
for (int i = 0; i < 10; i++) {
TEST_UTIL.loadTable(table, FAMILY);
}
HRegionServer testServer = TEST_UTIL.getHBaseCluster().getRegionServer(0);
List<FileStatus> wals = splitWALManager.getWALsToSplit(testServer.getServerName(), false);
Assert.assertEquals(1, wals.size());
SplitWALProcedure splitWALProcedure = new SplitWALProcedure(wals.get(0).getPath().toString(), testServer.getServerName());
long pid = ProcedureTestingUtility.submitProcedure(master.getMasterProcedureExecutor(), splitWALProcedure, HConstants.NO_NONCE, HConstants.NO_NONCE);
TEST_UTIL.waitFor(5000, () -> splitWALProcedure.getWorker() != null);
// Kill master
TEST_UTIL.getHBaseCluster().killMaster(master.getServerName());
TEST_UTIL.getHBaseCluster().waitForMasterToStop(master.getServerName(), 20000);
// restart master
TEST_UTIL.getHBaseCluster().startMaster();
TEST_UTIL.getHBaseCluster().waitForActiveAndReadyMaster();
this.master = TEST_UTIL.getHBaseCluster().getMaster();
ProcedureTestingUtility.waitProcedure(master.getMasterProcedureExecutor(), pid);
Optional<Procedure<?>> procedure = master.getProcedures().stream().filter(p -> p.getProcId() == pid).findAny();
// make sure procedure is successful and wal is deleted
Assert.assertTrue(procedure.isPresent());
Assert.assertTrue(procedure.get().isSuccess());
Assert.assertFalse(TEST_UTIL.getTestFileSystem().exists(wals.get(0).getPath()));
}
use of org.apache.hadoop.hbase.regionserver.HRegionServer in project hbase by apache.
the class TestRegionMoverWithRSGroupEnable method testUnloadRegions.
@Test
public void testUnloadRegions() throws Exception {
Address decommission = rsservers.get(0);
Address online = rsservers.get(1);
String filename = new Path(TEST_UTIL.getDataTestDir(), "testRSGroupUnload").toString();
RegionMoverBuilder builder = new RegionMoverBuilder(decommission.toString(), TEST_UTIL.getConfiguration());
try (RegionMover rm = builder.filename(filename).ack(true).build()) {
LOG.info("Unloading " + decommission.getHostname());
rm.unload();
}
HRegionServer onlineRS = TEST_UTIL.getMiniHBaseCluster().getRegionServerThreads().stream().map(JVMClusterUtil.RegionServerThread::getRegionServer).filter(rs -> rs.getServerName().getAddress().equals(online)).findFirst().get();
assertEquals(9, onlineRS.getNumberOfOnlineRegions());
}
use of org.apache.hadoop.hbase.regionserver.HRegionServer in project hbase by apache.
the class TestRegionMover1 method testDecomServerExclusionWithAck.
@Test
public void testDecomServerExclusionWithAck() throws Exception {
SingleProcessHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
HRegionServer excludeServer = cluster.getRegionServer(1);
List<HRegion> regions = excludeServer.getRegions();
int regionsExcludeServer = excludeServer.getNumberOfOnlineRegions();
TEST_UTIL.getAdmin().decommissionRegionServers(Collections.singletonList(excludeServer.getServerName()), false);
waitForServerDecom(excludeServer);
HRegionServer regionServer = cluster.getRegionServer(0);
String rsName = regionServer.getServerName().getHostname();
int port = regionServer.getServerName().getPort();
String hostname = rsName + ":" + Integer.toString(port);
RegionMoverBuilder rmBuilder = new RegionMoverBuilder(hostname, TEST_UTIL.getConfiguration()).ack(true);
int targetServerRegions = cluster.getRegionServer(2).getRegions().size();
int sourceServerRegions = regionServer.getRegions().size();
try (RegionMover regionMover = rmBuilder.build()) {
Assert.assertTrue(regionMover.unload());
LOG.info("Unloading {}", hostname);
assertEquals(0, regionServer.getNumberOfOnlineRegions());
assertEquals(regionsExcludeServer, cluster.getRegionServer(1).getNumberOfOnlineRegions());
LOG.info("Before:" + regionsExcludeServer + " After:" + cluster.getRegionServer(1).getNumberOfOnlineRegions());
List<HRegion> regionList = cluster.getRegionServer(1).getRegions();
int index = 0;
for (HRegion hRegion : regionList) {
Assert.assertEquals(hRegion, regions.get(index++));
}
Assert.assertEquals(targetServerRegions + sourceServerRegions, cluster.getRegionServer(2).getNumberOfOnlineRegions());
Assert.assertTrue(regionMover.load());
}
TEST_UTIL.getAdmin().recommissionRegionServer(excludeServer.getServerName(), Collections.emptyList());
}
use of org.apache.hadoop.hbase.regionserver.HRegionServer in project hbase by apache.
the class TestRegionMover1 method testDesignatedFile.
@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());
}
}
use of org.apache.hadoop.hbase.regionserver.HRegionServer in project hbase by apache.
the class TestRegionMover1 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
*/
@Test
public void testExclude() 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();
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, TEST_UTIL.getConfiguration()).ack(true).excludeFile(excludeFile.getCanonicalPath());
try (RegionMover rm = rmBuilder.build()) {
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());
}
}
Aggregations