本文整理汇总了Java中org.apache.hadoop.hbase.master.balancer.StochasticLoadBalancer类的典型用法代码示例。如果您正苦于以下问题:Java StochasticLoadBalancer类的具体用法?Java StochasticLoadBalancer怎么用?Java StochasticLoadBalancer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StochasticLoadBalancer类属于org.apache.hadoop.hbase.master.balancer包,在下文中一共展示了StochasticLoadBalancer类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: initialize
import org.apache.hadoop.hbase.master.balancer.StochasticLoadBalancer; //导入依赖的package包/类
@Override
public void initialize() throws HBaseIOException {
Class<? extends LoadBalancer> delegatorKlass =
conf.getClass(Constants.INDEX_BALANCER_DELEGATOR_CLASS, StochasticLoadBalancer.class,
LoadBalancer.class);
this.delegator = ReflectionUtils.newInstance(delegatorKlass, conf);
this.delegator.setClusterStatus(clusterStatus);
this.delegator.setMasterServices(this.master);
try {
HTableDescriptor desc = null;
Map<String, HTableDescriptor> tableDescriptors = this.master.getTableDescriptors().getAll();
for (Entry<String, HTableDescriptor> entry : tableDescriptors.entrySet()) {
desc = entry.getValue();
if (desc.getValue(Constants.INDEX_SPEC_KEY) != null) {
addIndexedTable(desc.getTableName());
}
}
} catch (IOException e) {
throw new HBaseIOException(e);
}
}
开发者ID:tenggyut,项目名称:HIndex,代码行数:22,代码来源:SecIndexLoadBalancer.java
示例2: makePlan
import org.apache.hadoop.hbase.master.balancer.StochasticLoadBalancer; //导入依赖的package包/类
public static List<RegionPlan> makePlan(HBaseAdmin admin, List<RegionPlan> newRegionPlan) throws IOException {
// snapshot current region assignment
Map<HRegionInfo, ServerName> regionAssignmentMap = createRegionAssignmentMap(admin);
// update with new plan
for (RegionPlan regionPlan : newRegionPlan) {
regionAssignmentMap.put(regionPlan.getRegionInfo(), regionPlan.getDestination());
}
Map<ServerName, List<HRegionInfo>> clusterState = initializeRegionMap(admin);
for (Map.Entry<HRegionInfo, ServerName> entry : regionAssignmentMap.entrySet())
clusterState.get(entry.getValue()).add(entry.getKey());
StochasticLoadBalancer balancer = new StochasticLoadBalancer();
Configuration conf = admin.getConfiguration();
conf.setFloat("hbase.regions.slop", 0.2f);
balancer.setConf(conf);
return balancer.balanceCluster(clusterState);
}
开发者ID:kakao,项目名称:hbase-tools,代码行数:20,代码来源:CommandAdapter.java
示例3: testJmxMetrics_EnsembleMode
import org.apache.hadoop.hbase.master.balancer.StochasticLoadBalancer; //导入依赖的package包/类
/**
* In Ensemble mode, there should be only one ensemble table
*/
@Test (timeout=60000)
public void testJmxMetrics_EnsembleMode() throws Exception {
loadBalancer = new StochasticLoadBalancer();
conf.setBoolean(HConstants.HBASE_MASTER_LOADBALANCE_BYTABLE, false);
loadBalancer.setConf(conf);
TableName tableName = HConstants.ENSEMBLE_TABLE_NAME;
Map<ServerName, List<RegionInfo>> clusterState = mockClusterServers(mockCluster_ensemble);
loadBalancer.balanceCluster(tableName, clusterState);
String[] tableNames = new String[] { tableName.getNameAsString() };
String[] functionNames = loadBalancer.getCostFunctionNames();
Set<String> jmxMetrics = readJmxMetricsWithRetry();
Set<String> expectedMetrics = getExpectedJmxMetrics(tableNames, functionNames);
// printMetrics(jmxMetrics, "existing metrics in ensemble mode");
// printMetrics(expectedMetrics, "expected metrics in ensemble mode");
// assert that every expected is in the JMX
for (String expected : expectedMetrics) {
assertTrue("Metric " + expected + " can not be found in JMX in ensemble mode.",
jmxMetrics.contains(expected));
}
}
开发者ID:apache,项目名称:hbase,代码行数:29,代码来源:TestStochasticBalancerJmxMetrics.java
示例4: initialize
import org.apache.hadoop.hbase.master.balancer.StochasticLoadBalancer; //导入依赖的package包/类
@Override
public void initialize() throws HBaseIOException {
try {
if (rsGroupInfoManager == null) {
List<RSGroupAdminEndpoint> cps =
masterServices.getMasterCoprocessorHost().findCoprocessors(RSGroupAdminEndpoint.class);
if (cps.size() != 1) {
String msg = "Expected one implementation of GroupAdminEndpoint but found " + cps.size();
LOG.error(msg);
throw new HBaseIOException(msg);
}
rsGroupInfoManager = cps.get(0).getGroupInfoManager();
}
} catch (IOException e) {
throw new HBaseIOException("Failed to initialize GroupInfoManagerImpl", e);
}
// Create the balancer
Class<? extends LoadBalancer> balancerKlass = config.getClass(HBASE_RSGROUP_LOADBALANCER_CLASS,
StochasticLoadBalancer.class, LoadBalancer.class);
internalBalancer = ReflectionUtils.newInstance(balancerKlass, config);
internalBalancer.setMasterServices(masterServices);
internalBalancer.setClusterMetrics(clusterStatus);
internalBalancer.setConf(config);
internalBalancer.initialize();
}
开发者ID:apache,项目名称:hbase,代码行数:27,代码来源:RSGroupBasedLoadBalancer.java
示例5: getExpectedJmxMetrics
import org.apache.hadoop.hbase.master.balancer.StochasticLoadBalancer; //导入依赖的package包/类
/**
* Given the tables and functions, return metrics names that should exist in JMX
*/
private Set<String> getExpectedJmxMetrics(String[] tableNames, String[] functionNames) {
Set<String> ret = new HashSet<>();
for (String tableName : tableNames) {
ret.add(StochasticLoadBalancer.composeAttributeName(tableName, "Overall"));
for (String functionName : functionNames) {
String metricsName = StochasticLoadBalancer.composeAttributeName(tableName, functionName);
ret.add(metricsName);
}
}
return ret;
}
开发者ID:apache,项目名称:hbase,代码行数:17,代码来源:TestStochasticBalancerJmxMetrics.java
示例6: testJmxMetrics_PerTableMode
import org.apache.hadoop.hbase.master.balancer.StochasticLoadBalancer; //导入依赖的package包/类
/**
* In per-table mode, each table has a set of metrics
*/
@Test (timeout=60000)
public void testJmxMetrics_PerTableMode() throws Exception {
loadBalancer = new StochasticLoadBalancer();
conf.setBoolean(HConstants.HBASE_MASTER_LOADBALANCE_BYTABLE, true);
loadBalancer.setConf(conf);
// NOTE the size is normally set in setClusterMetrics, for test purpose, we set it manually
// Tables: hbase:namespace, table1, table2
// Functions: costFunctions, overall
String[] functionNames = loadBalancer.getCostFunctionNames();
loadBalancer.updateMetricsSize(3 * (functionNames.length + 1));
// table 1
TableName tableName = TableName.valueOf(TABLE_NAME_1);
Map<ServerName, List<RegionInfo>> clusterState = mockClusterServers(mockCluster_pertable_1);
loadBalancer.balanceCluster(tableName, clusterState);
// table 2
tableName = TableName.valueOf(TABLE_NAME_2);
clusterState = mockClusterServers(mockCluster_pertable_2);
loadBalancer.balanceCluster(tableName, clusterState);
// table hbase:namespace
tableName = TableName.valueOf(TABLE_NAME_NAMESPACE);
clusterState = mockClusterServers(mockCluster_pertable_namespace);
loadBalancer.balanceCluster(tableName, clusterState);
String[] tableNames = new String[] { TABLE_NAME_1, TABLE_NAME_2, TABLE_NAME_NAMESPACE };
Set<String> jmxMetrics = readJmxMetricsWithRetry();
Set<String> expectedMetrics = getExpectedJmxMetrics(tableNames, functionNames);
// printMetrics(jmxMetrics, "existing metrics in per-table mode");
// printMetrics(expectedMetrics, "expected metrics in per-table mode");
// assert that every expected is in the JMX
for (String expected : expectedMetrics) {
assertTrue("Metric " + expected + " can not be found in JMX in per-table mode.",
jmxMetrics.contains(expected));
}
}
开发者ID:apache,项目名称:hbase,代码行数:45,代码来源:TestStochasticBalancerJmxMetrics.java
注:本文中的org.apache.hadoop.hbase.master.balancer.StochasticLoadBalancer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论