本文整理汇总了Java中org.apache.hadoop.hbase.master.balancer.StochasticLoadBalancer.setConf方法的典型用法代码示例。如果您正苦于以下问题:Java StochasticLoadBalancer.setConf方法的具体用法?Java StochasticLoadBalancer.setConf怎么用?Java StochasticLoadBalancer.setConf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hbase.master.balancer.StochasticLoadBalancer
的用法示例。
在下文中一共展示了StochasticLoadBalancer.setConf方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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));
}
}
示例3: 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));
}
}