本文整理汇总了Java中org.apache.hadoop.hbase.master.AssignmentManager.waitUntilNoRegionsInTransition方法的典型用法代码示例。如果您正苦于以下问题:Java AssignmentManager.waitUntilNoRegionsInTransition方法的具体用法?Java AssignmentManager.waitUntilNoRegionsInTransition怎么用?Java AssignmentManager.waitUntilNoRegionsInTransition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hbase.master.AssignmentManager
的用法示例。
在下文中一共展示了AssignmentManager.waitUntilNoRegionsInTransition方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: postAssign
import org.apache.hadoop.hbase.master.AssignmentManager; //导入方法依赖的package包/类
@Override
public void postAssign(ObserverContext<MasterCoprocessorEnvironment> ctx, HRegionInfo regionInfo)
throws IOException {
LOG.info("Entering into postAssign of region " + regionInfo.getRegionNameAsString() + '.');
if (false == regionInfo.getTableNameAsString().endsWith(Constants.INDEX_TABLE_SUFFIX)) {
MasterServices master = ctx.getEnvironment().getMasterServices();
AssignmentManager am = master.getAssignmentManager();
// waiting until user region is removed from transition.
long timeout =
master.getConfiguration()
.getLong("hbase.bulk.assignment.waiton.empty.rit", 5 * 60 * 1000);
Set<HRegionInfo> regionSet = new HashSet<HRegionInfo>(1);
regionSet.add(regionInfo);
try {
am.waitUntilNoRegionsInTransition(timeout, regionSet);
am.waitForAssignment(regionInfo, timeout);
} catch (InterruptedException e) {
if (LOG.isDebugEnabled()) {
LOG.debug("Interrupted while region in assignment.");
}
}
ServerName sn = am.getRegionServerOfRegion(regionInfo);
String indexTableName = IndexUtils.getIndexTableName(regionInfo.getTableNameAsString());
List<HRegionInfo> tableRegions = am.getRegionsOfTable(Bytes.toBytes(indexTableName));
for (HRegionInfo hRegionInfo : tableRegions) {
if (0 == Bytes.compareTo(hRegionInfo.getStartKey(), regionInfo.getStartKey())) {
am.addPlan(hRegionInfo.getEncodedName(), new RegionPlan(hRegionInfo, null, sn));
LOG.info("Assigning region " + hRegionInfo.getRegionNameAsString() + " to server " + sn
+ '.');
am.assign(hRegionInfo, true, false, false);
}
}
}
LOG.info("Exiting from postAssign " + regionInfo.getRegionNameAsString() + '.');
}
示例2: testRegionMove
import org.apache.hadoop.hbase.master.AssignmentManager; //导入方法依赖的package包/类
@Test(timeout = 180000)
public void testRegionMove() throws Exception {
MiniHBaseCluster cluster = UTIL.getHBaseCluster();
HMaster master = cluster.getMaster();
ZooKeeperWatcher zkw = UTIL.getZooKeeperWatcher(UTIL);
TableName tableName = TableName.valueOf("testRegionMove");
HTableDescriptor iHtd = new HTableDescriptor(tableName);
HColumnDescriptor hcd = new HColumnDescriptor("col").setMaxVersions(Integer.MAX_VALUE);
IndexSpecification iSpec = new IndexSpecification("ScanIndexf");
iSpec.addIndexColumn(hcd, "q1", ValueType.String, 10);
TableIndices tableIndices = new TableIndices();
tableIndices.addIndex(iSpec);
iHtd.addFamily(hcd);
iHtd.setValue(Constants.INDEX_SPEC_KEY, tableIndices.toByteArray());
char c = 'A';
byte[][] split = new byte[4][];
for (int i = 0; i < 4; i++) {
byte[] b = { (byte) c };
split[i] = b;
c++;
}
admin.createTable(iHtd, split);
List<HRegionInfo> tableRegions =
MetaReader.getTableRegions(master.getCatalogTracker(),
iHtd.getTableName());
int numRegions = cluster.getRegionServerThreads().size();
cluster.getRegionServer(1).getServerName();
Random random = new Random();
for (HRegionInfo hRegionInfo : tableRegions) {
int regionNumber = random.nextInt(numRegions);
ServerName serverName = cluster.getRegionServer(regionNumber).getServerName();
admin.move(hRegionInfo.getEncodedNameAsBytes(), Bytes.toBytes(serverName.getServerName()));
}
ZKAssign.blockUntilNoRIT(zkw);
AssignmentManager am = UTIL.getHBaseCluster().getMaster().getAssignmentManager();
while(!am.waitUntilNoRegionsInTransition(1000));
boolean isRegionColocated =
TestUtils.checkForColocation(master, tableName.getNameAsString(),
IndexUtils.getIndexTableName(tableName));
assertTrue("User regions and index regions should colocate.", isRegionColocated);
}
示例3: postMove
import org.apache.hadoop.hbase.master.AssignmentManager; //导入方法依赖的package包/类
@Override
public void postMove(ObserverContext<MasterCoprocessorEnvironment> ctx, HRegionInfo regionInfo,
ServerName srcServer, ServerName destServer) throws IOException {
LOG.info("Entering into postMove " + regionInfo.getRegionNameAsString() + '.');
if (false == regionInfo.getTableNameAsString().endsWith(Constants.INDEX_TABLE_SUFFIX)) {
MasterServices master = ctx.getEnvironment().getMasterServices();
AssignmentManager am = master.getAssignmentManager();
// waiting until user region is removed from transition.
long timeout =
master.getConfiguration()
.getLong("hbase.bulk.assignment.waiton.empty.rit", 5 * 60 * 1000);
Set<HRegionInfo> regionSet = new HashSet<HRegionInfo>(1);
regionSet.add(regionInfo);
try {
am.waitUntilNoRegionsInTransition(timeout, regionSet);
am.waitForAssignment(regionInfo, timeout);
destServer = am.getRegionServerOfRegion(regionInfo);
am.putRegionPlan(regionInfo, destServer);
} catch (InterruptedException e) {
if (LOG.isDebugEnabled()) {
LOG.debug("Interrupted while region in assignment.");
}
}
String indexTableName = IndexUtils.getIndexTableName(regionInfo.getTableNameAsString());
List<HRegionInfo> tableRegions = am.getRegionsOfTable(Bytes.toBytes(indexTableName));
for (HRegionInfo indexRegionInfo : tableRegions) {
if (0 == Bytes.compareTo(indexRegionInfo.getStartKey(), regionInfo.getStartKey())) {
LOG.info("Assigning region " + indexRegionInfo.getRegionNameAsString() + "from "
+ srcServer + " to server " + destServer + '.');
am.putRegionPlan(indexRegionInfo, destServer);
am.addPlan(indexRegionInfo.getEncodedName(), new RegionPlan(indexRegionInfo, null,
destServer));
am.unassign(indexRegionInfo);
/*
* ((HMaster) master).move(indexRegionInfo.getEncodedNameAsBytes(),
* Bytes.toBytes(destServer.getServerName()));
*/
}
}
}
LOG.info("Exiting from postMove " + regionInfo.getRegionNameAsString() + '.');
}