本文整理汇总了Java中org.apache.hadoop.hbase.master.AssignmentManager.addPlan方法的典型用法代码示例。如果您正苦于以下问题:Java AssignmentManager.addPlan方法的具体用法?Java AssignmentManager.addPlan怎么用?Java AssignmentManager.addPlan使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hbase.master.AssignmentManager
的用法示例。
在下文中一共展示了AssignmentManager.addPlan方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 (!IndexUtils.isIndexTable(regionInfo.getTable().getName())) {
MasterServices master = ctx.getEnvironment().getMasterServices();
LoadBalancer balancer = master.getAssignmentManager().getBalancer();
AssignmentManager am = master.getAssignmentManager();
RegionStates regionStates = am.getRegionStates();
// waiting until user region is removed from transition.
long timeout =
master.getConfiguration()
.getLong("hbase.bulk.assignment.waiton.empty.rit", 5 * 60 * 1000);
try {
am.waitOnRegionToClearRegionsInTransition(regionInfo, timeout);
} catch (InterruptedException e) {
if (LOG.isDebugEnabled()) {
LOG.debug("Interrupted while region in assignment.");
}
}
ServerName sn = regionStates.getRegionServerOfRegion(regionInfo);
TableName indexTableName =
TableName.valueOf(IndexUtils.getIndexTableName(regionInfo.getTableName()));
List<HRegionInfo> tableRegions = regionStates.getRegionsOfTable(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
+ '.');
balancer.regionOnline(hRegionInfo, sn);
am.assign(hRegionInfo, true, false);
break;
}
}
}
LOG.info("Exiting from postAssign " + regionInfo.getRegionNameAsString() + '.');
}
示例2: 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 (!IndexUtils.isIndexTable(regionInfo.getTable().getNameAsString())) {
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);
try {
am.waitOnRegionToClearRegionsInTransition(regionInfo, timeout);
destServer = am.getRegionStates().getRegionServerOfRegion(regionInfo);
am.getBalancer().regionOnline(regionInfo, destServer);
} catch (InterruptedException e) {
if (LOG.isDebugEnabled()) {
LOG.debug("Interrupted while region in assignment.");
}
}
TableName indexTableName =
TableName.valueOf(IndexUtils.getIndexTableName(regionInfo.getTable().getNameAsString()));
List<HRegionInfo> tableRegions = am.getRegionStates().getRegionsOfTable(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.getBalancer().regionOnline(indexRegionInfo, destServer);
am.addPlan(indexRegionInfo.getEncodedName(), new RegionPlan(indexRegionInfo, null,
destServer));
am.unassign(indexRegionInfo);
}
}
}
LOG.info("Exiting from postMove " + regionInfo.getRegionNameAsString() + '.');
}
示例3: 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() + '.');
}
示例4: 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() + '.');
}