本文整理汇总了Java中org.apache.hadoop.hbase.master.AssignmentManager.getRegionServerOfRegion方法的典型用法代码示例。如果您正苦于以下问题:Java AssignmentManager.getRegionServerOfRegion方法的具体用法?Java AssignmentManager.getRegionServerOfRegion怎么用?Java AssignmentManager.getRegionServerOfRegion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hbase.master.AssignmentManager
的用法示例。
在下文中一共展示了AssignmentManager.getRegionServerOfRegion方法的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: testMasterFailoverWhenDisablingTableRegionsInRITOnDeadRS
import org.apache.hadoop.hbase.master.AssignmentManager; //导入方法依赖的package包/类
@Test (timeout=180000)
public void testMasterFailoverWhenDisablingTableRegionsInRITOnDeadRS() throws Exception {
MiniHBaseCluster cluster = TESTUTIL.getHBaseCluster();
HMaster master = cluster.getMaster();
// disable load balancing on this master
master.balanceSwitch(false);
final String table = "testMasterFailoverWhenDisablingTableRegionsInRITOnDeadRS";
byte [] FAMILY = Bytes.toBytes("family");
byte[][] SPLIT_KEYS =
new byte[][] {Bytes.toBytes("a"), Bytes.toBytes("b"), Bytes.toBytes("c"),
Bytes.toBytes("d") };
HTableDescriptor htd = new HTableDescriptor(table);
HColumnDescriptor hcd = new HColumnDescriptor(FAMILY);
htd.addFamily(hcd);
TESTUTIL.getHBaseAdmin().createTable(htd, SPLIT_KEYS);
AssignmentManager am = cluster.getMaster().getAssignmentManager();
List<HRegionInfo> regionsOfTable = null;
while ((regionsOfTable = am.getRegionsOfTable(table.getBytes())).size()
!= (SPLIT_KEYS.length + 1)) {
Thread.sleep(10);
}
HRegionInfo closingRegion = regionsOfTable.get(0);
ServerName serverName = am.getRegionServerOfRegion(closingRegion);
HRegionServer deadRS = null;
for (int i = 0; i < cluster.getRegionServerThreads().size(); i++) {
deadRS = cluster.getRegionServer(i);
if (deadRS.getServerName().equals(serverName)) {
break;
}
}
// Disable the table in ZK
ZKTable zkTable = am.getZKTable();
zkTable.setDisablingTable(table);
ZKAssign.createNodeClosing(master.getZooKeeper(), closingRegion, serverName);
// Stop the master
abortMaster(cluster);
master = startMasterAndWaitTillMetaRegionAssignment(cluster);
deadRS.kill();
deadRS.join();
waitUntilMasterIsInitialized(master);
am = cluster.getMaster().getAssignmentManager();
zkTable = am.getZKTable();
// wait for no more RIT
ZKAssign.blockUntilNoRIT(master.getZooKeeper());
while (!master.getAssignmentManager().getZKTable().isDisabledTable(table)) {
Thread.sleep(10);
}
assertTrue("Table should be disabled state.", zkTable.isDisabledTable(table));
HBaseAdmin admin = new HBaseAdmin(master.getConfiguration());
admin.deleteTable(table);
}
示例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() + '.');
}