本文整理汇总了Java中org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread方法的典型用法代码示例。如果您正苦于以下问题:Java JVMClusterUtil.RegionServerThread方法的具体用法?Java JVMClusterUtil.RegionServerThread怎么用?Java JVMClusterUtil.RegionServerThread使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hbase.util.JVMClusterUtil
的用法示例。
在下文中一共展示了JVMClusterUtil.RegionServerThread方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addRegionServer
import org.apache.hadoop.hbase.util.JVMClusterUtil; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public JVMClusterUtil.RegionServerThread addRegionServer(
Configuration config, final int index)
throws IOException {
// Create each regionserver with its own Configuration instance so each has
// its HConnection instance rather than share (see HBASE_INSTANCES down in
// the guts of HConnectionManager.
// Also, create separate CoordinatedStateManager instance per Server.
// This is special case when we have to have more than 1 CoordinatedStateManager
// within 1 process.
CoordinatedStateManager cp = CoordinatedStateManagerFactory.getCoordinatedStateManager(conf);
JVMClusterUtil.RegionServerThread rst =
JVMClusterUtil.createRegionServerThread(config, cp, (Class<? extends HRegionServer>) conf
.getClass(HConstants.REGION_SERVER_IMPL, this.regionServerClass), index);
this.regionThreads.add(rst);
return rst;
}
示例2: startRegionServer
import org.apache.hadoop.hbase.util.JVMClusterUtil; //导入方法依赖的package包/类
/**
* Starts a region server thread running
*
* @throws IOException
* @return New RegionServerThread
*/
public JVMClusterUtil.RegionServerThread startRegionServer()
throws IOException {
final Configuration newConf = HBaseConfiguration.create(conf);
User rsUser =
HBaseTestingUtility.getDifferentUser(newConf, ".hfs."+index++);
JVMClusterUtil.RegionServerThread t = null;
try {
t = hbaseCluster.addRegionServer(
newConf, hbaseCluster.getRegionServers().size(), rsUser);
t.start();
t.waitForServerOnline();
} catch (InterruptedException ie) {
throw new IOException("Interrupted adding regionserver to cluster", ie);
}
return t;
}
示例3: ensureSomeNonStoppedRegionServersAvailable
import org.apache.hadoop.hbase.util.JVMClusterUtil; //导入方法依赖的package包/类
/**
* Make sure that at least the specified number of region servers
* are running. We don't count the ones that are currently stopping or are
* stopped.
* @param num minimum number of region servers that should be running
* @return true if we started some servers
* @throws IOException
*/
public boolean ensureSomeNonStoppedRegionServersAvailable(final int num)
throws IOException {
boolean startedServer = ensureSomeRegionServersAvailable(num);
int nonStoppedServers = 0;
for (JVMClusterUtil.RegionServerThread rst :
getMiniHBaseCluster().getRegionServerThreads()) {
HRegionServer hrs = rst.getRegionServer();
if (hrs.isStopping() || hrs.isStopped()) {
LOG.info("A region server is stopped or stopping:"+hrs);
} else {
nonStoppedServers++;
}
}
for (int i=nonStoppedServers; i<num; ++i) {
LOG.info("Started new server=" + getMiniHBaseCluster().startRegionServer());
startedServer = true;
}
return startedServer;
}
示例4: test
import org.apache.hadoop.hbase.util.JVMClusterUtil; //导入方法依赖的package包/类
@Test
public void test() throws IOException, InterruptedException {
testUtil.getHBaseAdmin().createNamespace(
NamespaceDescriptor.create(tableName.getNamespaceAsString()).build());
HTable table = testUtil.createTable(tableName, families);
table.put(new Put(Bytes.toBytes("k")).add(family, Bytes.toBytes("q"), Bytes.toBytes("v")));
table.flushCommits();
MiniHBaseCluster cluster = testUtil.getMiniHBaseCluster();
List<JVMClusterUtil.RegionServerThread> rsts = cluster.getRegionServerThreads();
Region region = null;
for (int i = 0; i < cluster.getRegionServerThreads().size(); i++) {
HRegionServer hrs = rsts.get(i).getRegionServer();
for (Region r : hrs.getOnlineRegions(tableName)) {
region = r;
break;
}
}
assertNotNull(region);
Thread.sleep(2000);
RegionStoreSequenceIds ids =
testUtil.getHBaseCluster().getMaster()
.getLastSequenceId(region.getRegionInfo().getEncodedNameAsBytes());
assertEquals(HConstants.NO_SEQNUM, ids.getLastFlushedSequenceId());
// This will be the sequenceid just before that of the earliest edit in memstore.
long storeSequenceId = ids.getStoreSequenceId(0).getSequenceId();
assertTrue(storeSequenceId > 0);
testUtil.getHBaseAdmin().flush(tableName);
Thread.sleep(2000);
ids =
testUtil.getHBaseCluster().getMaster()
.getLastSequenceId(region.getRegionInfo().getEncodedNameAsBytes());
assertTrue(ids.getLastFlushedSequenceId() + " > " + storeSequenceId,
ids.getLastFlushedSequenceId() > storeSequenceId);
assertEquals(ids.getLastFlushedSequenceId(), ids.getStoreSequenceId(0).getSequenceId());
table.close();
}
示例5: findRegionsForTable
import org.apache.hadoop.hbase.util.JVMClusterUtil; //导入方法依赖的package包/类
public List<HRegion> findRegionsForTable(TableName tableName) {
ArrayList<HRegion> ret = new ArrayList<HRegion>();
for (JVMClusterUtil.RegionServerThread rst : getRegionServerThreads()) {
HRegionServer hrs = rst.getRegionServer();
for (Region region : hrs.getOnlineRegions(tableName)) {
if (region.getTableDesc().getTableName().equals(tableName)) {
ret.add((HRegion)region);
}
}
}
return ret;
}
示例6: getLiveRegionServers
import org.apache.hadoop.hbase.util.JVMClusterUtil; //导入方法依赖的package包/类
/**
* @return List of running servers (Some servers may have been killed or
* aborted during lifetime of cluster; these servers are not included in this
* list).
*/
public List<JVMClusterUtil.RegionServerThread> getLiveRegionServers() {
List<JVMClusterUtil.RegionServerThread> liveServers =
new ArrayList<JVMClusterUtil.RegionServerThread>();
List<RegionServerThread> list = getRegionServers();
for (JVMClusterUtil.RegionServerThread rst: list) {
if (rst.isAlive()) liveServers.add(rst);
else LOG.info("Not alive " + rst.getName());
}
return liveServers;
}
示例7: assertRegionOnlyOnServer
import org.apache.hadoop.hbase.util.JVMClusterUtil; //导入方法依赖的package包/类
/**
* Check to make sure the region is open on the specified
* region server, but not on any other one.
*/
public void assertRegionOnlyOnServer(
final HRegionInfo hri, final ServerName server,
final long timeout) throws IOException, InterruptedException {
long timeoutTime = System.currentTimeMillis() + timeout;
while (true) {
List<HRegionInfo> regions = getHBaseAdmin().getOnlineRegions(server);
if (regions.contains(hri)) {
List<JVMClusterUtil.RegionServerThread> rsThreads =
getHBaseCluster().getLiveRegionServerThreads();
for (JVMClusterUtil.RegionServerThread rsThread: rsThreads) {
HRegionServer rs = rsThread.getRegionServer();
if (server.equals(rs.getServerName())) {
continue;
}
Collection<Region> hrs = rs.getOnlineRegionsLocalContext();
for (Region r: hrs) {
assertTrue("Region should not be double assigned",
r.getRegionInfo().getRegionId() != hri.getRegionId());
}
}
return; // good, we are happy
}
long now = System.currentTimeMillis();
if (now > timeoutTime) break;
Thread.sleep(10);
}
fail("Could not find region " + hri.getRegionNameAsString()
+ " on server " + server);
}
示例8: getServerWith
import org.apache.hadoop.hbase.util.JVMClusterUtil; //导入方法依赖的package包/类
/**
* Get the location of the specified region
* @param regionName Name of the region in bytes
* @return Index into List of {@link MiniHBaseCluster#getRegionServerThreads()}
* of HRS carrying hbase:meta. Returns -1 if none found.
*/
public int getServerWith(byte[] regionName) {
int index = -1;
int count = 0;
for (JVMClusterUtil.RegionServerThread rst: getRegionServerThreads()) {
HRegionServer hrs = rst.getRegionServer();
Region region = hrs.getOnlineRegion(regionName);
if (region != null) {
index = count;
break;
}
count++;
}
return index;
}
示例9: setUp
import org.apache.hadoop.hbase.util.JVMClusterUtil; //导入方法依赖的package包/类
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
// Starting and stopping replication can make us miss new logs,
// rolling like this makes sure the most recent one gets added to the queue
for (JVMClusterUtil.RegionServerThread r :
utility1.getHBaseCluster().getRegionServerThreads()) {
utility1.getHBaseAdmin().rollWALWriter(r.getRegionServer().getServerName());
}
utility1.deleteTableData(tableName);
// truncating the table will send one Delete per row to the slave cluster
// in an async fashion, which is why we cannot just call deleteTableData on
// utility2 since late writes could make it to the slave in some way.
// Instead, we truncate the first table and wait for all the Deletes to
// make it to the slave.
Scan scan = new Scan();
int lastCount = 0;
for (int i = 0; i < NB_RETRIES; i++) {
if (i == NB_RETRIES - 1) {
fail("Waited too much time for truncate");
}
ResultScanner scanner = htable2.getScanner(scan);
Result[] res = scanner.next(NB_ROWS_IN_BIG_BATCH);
scanner.close();
if (res.length != 0) {
if (res.length < lastCount) {
i--; // Don't increment timeout if we make progress
}
lastCount = res.length;
LOG.info("Still got " + res.length + " rows");
Thread.sleep(SLEEP_TIME);
} else {
break;
}
}
}
示例10: setup
import org.apache.hadoop.hbase.util.JVMClusterUtil; //导入方法依赖的package包/类
/**
* @throws java.lang.Exception
*/
@Before
public void setup() throws Exception {
MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
cluster.getConfiguration().setStrings(HConstants.REGION_SERVER_IMPL,
RegionServerWithFakeRpcServices.class.getName());
JVMClusterUtil.RegionServerThread rsThread = cluster.startRegionServer();
rsThread.waitForServerOnline();
badRS = rsThread.getRegionServer();
assertTrue(badRS.getRSRpcServices() instanceof FakeRSRpcServices);
cluster.getConfiguration().setStrings(HConstants.REGION_SERVER_IMPL,
HRegionServer.class.getName());
assertEquals(2, cluster.getRegionServerThreads().size());
conn = (ConnectionManager.HConnectionImplementation)ConnectionFactory.createConnection(
TEST_UTIL.getConfiguration());
HTableDescriptor table = new HTableDescriptor(TABLE_NAME);
HColumnDescriptor fam = new HColumnDescriptor(FAMILY);
fam.setMaxVersions(2);
table.addFamily(fam);
try (Admin admin = conn.getAdmin()) {
admin.createTable(table, HBaseTestingUtility.KEYS_FOR_HBA_CREATE_TABLE);
}
TEST_UTIL.waitUntilAllRegionsAssigned(TABLE_NAME);
}
示例11: getRegions
import org.apache.hadoop.hbase.util.JVMClusterUtil; //导入方法依赖的package包/类
public List<HRegion> getRegions(TableName tableName) {
List<HRegion> ret = new ArrayList<HRegion>();
for (JVMClusterUtil.RegionServerThread rst : getRegionServerThreads()) {
HRegionServer hrs = rst.getRegionServer();
for (Region region : hrs.getOnlineRegionsLocalContext()) {
if (region.getTableDesc().getTableName().equals(tableName)) {
ret.add((HRegion)region);
}
}
}
return ret;
}
示例12: getStoreWithName
import org.apache.hadoop.hbase.util.JVMClusterUtil; //导入方法依赖的package包/类
private Store getStoreWithName(TableName tableName) {
MiniHBaseCluster cluster = TEST_UTIL.getMiniHBaseCluster();
List<JVMClusterUtil.RegionServerThread> rsts = cluster.getRegionServerThreads();
for (int i = 0; i < cluster.getRegionServerThreads().size(); i++) {
HRegionServer hrs = rsts.get(i).getRegionServer();
for (Region region : hrs.getOnlineRegions(tableName)) {
return region.getStores().iterator().next();
}
}
return null;
}
示例13: flushcache
import org.apache.hadoop.hbase.util.JVMClusterUtil; //导入方法依赖的package包/类
/**
* Call flushCache on all regions on all participating regionservers.
* @throws IOException
*/
public void flushcache() throws IOException {
for (JVMClusterUtil.RegionServerThread t:
this.hbaseCluster.getRegionServers()) {
for(Region r: t.getRegionServer().getOnlineRegionsLocalContext()) {
r.flush(true);
}
}
}
示例14: testPreWALRestoreSkip
import org.apache.hadoop.hbase.util.JVMClusterUtil; //导入方法依赖的package包/类
@Test (timeout=300000)
public void testPreWALRestoreSkip() throws Exception {
LOG.info(TestRegionObserverInterface.class.getName() + ".testPreWALRestoreSkip");
TableName tableName = TableName.valueOf(SimpleRegionObserver.TABLE_SKIPPED);
HTable table = util.createTable(tableName, new byte[][] { A, B, C });
JVMClusterUtil.RegionServerThread rs1 = cluster.startRegionServer();
ServerName sn2 = rs1.getRegionServer().getServerName();
String regEN = table.getRegionLocations().firstEntry().getKey().getEncodedName();
util.getHBaseAdmin().move(regEN.getBytes(), sn2.getServerName().getBytes());
while (!sn2.equals(table.getRegionLocations().firstEntry().getValue())) {
Thread.sleep(100);
}
Put put = new Put(ROW);
put.add(A, A, A);
put.add(B, B, B);
put.add(C, C, C);
table.put(put);
table.flushCommits();
cluster.killRegionServer(rs1.getRegionServer().getServerName());
Threads.sleep(20000); // just to be sure that the kill has fully started.
util.waitUntilAllRegionsAssigned(tableName);
verifyMethodResult(SimpleRegionObserver.class, new String[] { "getCtPreWALRestore",
"getCtPostWALRestore", "getCtPreWALRestoreDeprecated", "getCtPostWALRestoreDeprecated"},
tableName,
new Integer[] {0, 0, 0, 0});
util.deleteTable(tableName);
table.close();
}
示例15: compact
import org.apache.hadoop.hbase.util.JVMClusterUtil; //导入方法依赖的package包/类
/**
* Call flushCache on all regions of the specified table.
* @throws IOException
*/
public void compact(TableName tableName, boolean major) throws IOException {
for (JVMClusterUtil.RegionServerThread t:
this.hbaseCluster.getRegionServers()) {
for(Region r: t.getRegionServer().getOnlineRegionsLocalContext()) {
if(r.getTableDesc().getTableName().equals(tableName)) {
r.compact(major);
}
}
}
}