本文整理了Java中org.apache.hadoop.hbase.HBaseTestingUtility.getMiniHBaseCluster()
方法的一些代码示例,展示了HBaseTestingUtility.getMiniHBaseCluster()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HBaseTestingUtility.getMiniHBaseCluster()
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.HBaseTestingUtility
类名称:HBaseTestingUtility
方法名:getMiniHBaseCluster
暂无
代码示例来源:origin: apache/hbase
private static HMaster getMaster(final HBaseTestingUtility util) {
return util.getMiniHBaseCluster().getMaster();
}
代码示例来源:origin: apache/hbase
@Test
public void testIsMetaWhenAllHealthy() throws InterruptedException {
HMaster m = UTIL.getMiniHBaseCluster().getMaster();
assertTrue(m.waitForMetaOnline());
}
代码示例来源:origin: apache/hbase
@Test
public void test() throws InterruptedException {
RegionServerThread t = UTIL.getMiniHBaseCluster().stopRegionServer(0);
t.join();
}
}
代码示例来源:origin: apache/hbase
@Test
public void testMasterOnlineConfigChange() throws Exception {
replaceHBaseSiteXML();
ServerName master = admin.getMaster().get();
admin.updateConfiguration(master).join();
admin.getBackupMasters().get()
.forEach(backupMaster -> admin.updateConfiguration(backupMaster).join());
// Check the configuration of the Masters
TEST_UTIL.getMiniHBaseCluster().getMasterThreads().forEach(thread -> {
Configuration conf = thread.getMaster().getConfiguration();
assertEquals(1000, conf.getInt("hbase.custom.config", 0));
});
restoreHBaseSiteXML();
}
代码示例来源:origin: apache/hbase
@Test
public void testIsMetaWhenMetaGoesOffline() throws InterruptedException {
HMaster m = UTIL.getMiniHBaseCluster().getMaster();
int index = UTIL.getMiniHBaseCluster().getServerWithMeta();
HRegionServer rsWithMeta = UTIL.getMiniHBaseCluster().getRegionServer(index);
rsWithMeta.abort("TESTING");
assertTrue(m.waitForMetaOnline());
}
代码示例来源:origin: apache/hbase
@Test
public void testRegionServerOnlineConfigChange() throws Exception {
replaceHBaseSiteXML();
admin.getRegionServers().get().forEach(server -> admin.updateConfiguration(server).join());
// Check the configuration of the RegionServers
TEST_UTIL.getMiniHBaseCluster().getRegionServerThreads().forEach(thread -> {
Configuration conf = thread.getRegionServer().getConfiguration();
assertEquals(1000, conf.getInt("hbase.custom.config", 0));
});
restoreHBaseSiteXML();
}
代码示例来源:origin: apache/hbase
@Test
public void testAllClusterOnlineConfigChange() throws IOException {
replaceHBaseSiteXML();
admin.updateConfiguration().join();
// Check the configuration of the Masters
TEST_UTIL.getMiniHBaseCluster().getMasterThreads().forEach(thread -> {
Configuration conf = thread.getMaster().getConfiguration();
assertEquals(1000, conf.getInt("hbase.custom.config", 0));
});
// Check the configuration of the RegionServers
TEST_UTIL.getMiniHBaseCluster().getRegionServerThreads().forEach(thread -> {
Configuration conf = thread.getRegionServer().getConfiguration();
assertEquals(1000, conf.getInt("hbase.custom.config", 0));
});
restoreHBaseSiteXML();
}
代码示例来源:origin: apache/hbase
private HFileCleaner getHFileCleaner(Stoppable stoppable, Configuration conf,
FileSystem fs, Path archiveDir) throws IOException {
Map<String, Object> params = new HashMap<>();
params.put(HMaster.MASTER, UTIL.getMiniHBaseCluster().getMaster());
HFileCleaner cleaner = new HFileCleaner(1, stoppable, conf, fs, archiveDir);
cleaner.init(params);
return Objects.requireNonNull(cleaner);
}
代码示例来源:origin: apache/hbase
@Test
public void testMasterOnlineConfigChange() throws IOException {
LOG.debug("Starting the test");
Path cnfPath = FileSystems.getDefault().getPath("target/test-classes/hbase-site.xml");
Path cnf2Path = FileSystems.getDefault().getPath("target/test-classes/hbase-site2.xml");
Path cnf3Path = FileSystems.getDefault().getPath("target/test-classes/hbase-site3.xml");
// make a backup of hbase-site.xml
Files.copy(cnfPath, cnf3Path, StandardCopyOption.REPLACE_EXISTING);
// update hbase-site.xml by overwriting it
Files.copy(cnf2Path, cnfPath, StandardCopyOption.REPLACE_EXISTING);
Admin admin = TEST_UTIL.getAdmin();
ServerName server = TEST_UTIL.getHBaseCluster().getMaster().getServerName();
admin.updateConfiguration(server);
Configuration conf = TEST_UTIL.getMiniHBaseCluster().getMaster().getConfiguration();
int custom = conf.getInt("hbase.custom.config", 0);
assertEquals(1000, custom);
// restore hbase-site.xml
Files.copy(cnf3Path, cnfPath, StandardCopyOption.REPLACE_EXISTING);
}
代码示例来源:origin: apache/hbase
@Test
public void test() {
assertTrue(testUtil.getMiniHBaseCluster().getRegionServer(0).getMasterAddressTracker()
.getMasterInfoPort() > 0);
}
}
代码示例来源:origin: apache/hbase
@Test
public void testShutdown() throws Exception {
TEST_UTIL.getMiniHBaseCluster().getMasterThreads().forEach(thread -> {
assertFalse(thread.getMaster().isStopped());
});
TEST_UTIL.getMiniHBaseCluster().getRegionServerThreads().forEach(thread -> {
assertFalse(thread.getRegionServer().isStopped());
});
admin.shutdown().join();
TEST_UTIL.getMiniHBaseCluster().getMasterThreads().forEach(thread -> {
while (!thread.getMaster().isStopped()) {
trySleep(100, TimeUnit.MILLISECONDS);
}
});
TEST_UTIL.getMiniHBaseCluster().getRegionServerThreads().forEach(thread -> {
while (!thread.getRegionServer().isStopped()) {
trySleep(100, TimeUnit.MILLISECONDS);
}
});
}
代码示例来源:origin: apache/hbase
public static void waitBackupMaster(final HBaseTestingUtility testUtil,
final HMaster oldMaster) throws Exception {
MiniHBaseCluster cluster = testUtil.getMiniHBaseCluster();
HMaster newMaster = cluster.getMaster();
while (newMaster == null || newMaster == oldMaster) {
Thread.sleep(250);
newMaster = cluster.getMaster();
}
while (!(newMaster.isActiveMaster() && newMaster.isInitialized())) {
Thread.sleep(250);
}
}
代码示例来源:origin: apache/hbase
@Test
public void test() throws Exception {
List<RegionInfo> regionInfos = admin.getRegions(TABLE_NAME);
MergeTableRegionsProcedure mergeTableRegionsProcedure = new MergeTableRegionsProcedure(
UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor()
.getEnvironment(), regionInfos.get(0), regionInfos.get(1));
long procID = UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor()
.submitProcedure(mergeTableRegionsProcedure);
mergeCommitArrive.await();
UTIL.getMiniHBaseCluster().stopMaster(0);
UTIL.getMiniHBaseCluster().startMaster();
//wait until master initialized
UTIL.waitFor(30000,
() -> UTIL.getMiniHBaseCluster().getMaster() != null && UTIL
.getMiniHBaseCluster().getMaster().isInitialized());
UTIL.waitFor(30000, () -> UTIL.getMiniHBaseCluster().getMaster()
.getMasterProcedureExecutor().isFinished(procID));
Assert.assertTrue("Found region RIT, that's impossible!",
UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager()
.getRegionsInTransition().size() == 0);
}
代码示例来源:origin: apache/hbase
@Test
public void testChangingNumberOfPeerRegionServers() throws IOException, InterruptedException {
LOG.info("testSimplePutDelete");
MiniHBaseCluster peerCluster = utility2.getMiniHBaseCluster();
int numRS = peerCluster.getRegionServerThreads().size();
doPutTest(Bytes.toBytes(1));
int rsToStop = peerCluster.getServerWithMeta() == 0 ? 1 : 0;
peerCluster.stopRegionServer(rsToStop);
peerCluster.waitOnRegionServer(rsToStop);
// Sanity check
assertEquals(numRS - 1, peerCluster.getRegionServerThreads().size());
doPutTest(Bytes.toBytes(2));
peerCluster.startRegionServer();
// Sanity check
assertEquals(numRS, peerCluster.getRegionServerThreads().size());
doPutTest(Bytes.toBytes(3));
}
代码示例来源:origin: apache/hbase
private Map<RegionInfo,Long> getReportedSizesForTable(TableName tn) {
HMaster master = TEST_UTIL.getMiniHBaseCluster().getMaster();
MasterQuotaManager quotaManager = master.getMasterQuotaManager();
Map<RegionInfo,Long> filteredRegionSizes = new HashMap<>();
for (Entry<RegionInfo,Long> entry : quotaManager.snapshotRegionSizes().entrySet()) {
if (entry.getKey().getTable().equals(tn)) {
filteredRegionSizes.put(entry.getKey(), entry.getValue());
}
}
return filteredRegionSizes;
}
代码示例来源:origin: apache/hbase
@Test
public void testRecoveryAndDoubleExecutionMove() throws Exception {
MasterProcedureEnv env =
UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor().getEnvironment();
HRegion region = UTIL.getMiniHBaseCluster().getRegions(tableName).get(0);
long openSeqNum = region.getOpenSeqNum();
TransitRegionStateProcedure proc =
TransitRegionStateProcedure.move(env, region.getRegionInfo(), null);
testRecoveryAndDoubleExcution(proc);
HRegion region2 = UTIL.getMiniHBaseCluster().getRegions(tableName).get(0);
long openSeqNum2 = region2.getOpenSeqNum();
// confirm that the region is successfully opened
assertTrue(openSeqNum2 > openSeqNum);
}
代码示例来源:origin: apache/hbase
@Test
public void test() throws IOException, InterruptedException {
HRegion region = UTIL.getMiniHBaseCluster().getRegions(TABLE_NAME).get(0);
long openSeqNum = region.getOpenSeqNum();
HRegionServer src = UTIL.getRSForFirstRegionInTable(TABLE_NAME);
HRegionServer dst = UTIL.getOtherRegionServer(src);
// will fail two times, and then verify that the open sequence number is still openSeqNum + 2
FAILED_OPEN.set(2);
UTIL.getAdmin().move(region.getRegionInfo().getEncodedNameAsBytes(),
Bytes.toBytes(dst.getServerName().getServerName()));
UTIL.waitTableAvailable(TABLE_NAME);
HRegion region1 = UTIL.getMiniHBaseCluster().getRegions(TABLE_NAME).get(0);
long openSeqNum1 = region1.getOpenSeqNum();
assertEquals(openSeqNum + 2, openSeqNum1);
}
}
代码示例来源:origin: apache/hbase
@Override
public boolean evaluate() throws IOException {
HMaster master = getMiniHBaseCluster().getMaster();
if (master == null) return false;
AssignmentManager am = master.getAssignmentManager();
if (am == null) return false;
return !am.hasRegionsInTransition();
}
};
代码示例来源:origin: apache/hbase
/**
* Basic client side validation of HBASE-4536
*/
@Test
public void testWarmup() throws Exception {
int serverid = 0;
HRegion region = TEST_UTIL.getMiniHBaseCluster().getRegions(TABLENAME).get(0);
RegionInfo info = region.getRegionInfo();
runwarmup();
for (int i = 0; i < 10; i++) {
HRegionServer rs = TEST_UTIL.getMiniHBaseCluster().getRegionServer(serverid);
byte [] destName = Bytes.toBytes(rs.getServerName().toString());
assertTrue(destName != null);
LOG.info("i=" + i );
TEST_UTIL.getMiniHBaseCluster().getMaster().move(info.getEncodedNameAsBytes(), destName);
serverid = (serverid + 1) % 2;
}
}
}
代码示例来源:origin: apache/hbase
@Test
public void testRegionServerObserver() throws IOException {
try (Connection connection = ConnectionFactory.createConnection(UTIL.getConfiguration());
Admin admin = connection.getAdmin()) {
LOG.info("Rolling WALs");
admin.rollWALWriter(UTIL.getMiniHBaseCluster().getServerHoldingMeta());
}
// Find out the MetricRegistry used by the CP using the global registries
MetricRegistryInfo info = MetricsCoprocessor.createRegistryInfoForRSCoprocessor(
CustomRegionServerObserver.class.getName());
Optional<MetricRegistry> registry = MetricRegistries.global().get(info);
assertTrue(registry.isPresent());
Optional<Metric> metric = registry.get().get("rollWALRequests");
assertTrue(metric.isPresent());
Counter rollWalRequests = (Counter)metric.get();
assertEquals(1, rollWalRequests.getCount());
}
内容来源于网络,如有侵权,请联系作者删除!