本文整理汇总了Java中org.apache.hadoop.yarn.server.resourcemanager.MockRM.init方法的典型用法代码示例。如果您正苦于以下问题:Java MockRM.init方法的具体用法?Java MockRM.init怎么用?Java MockRM.init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.yarn.server.resourcemanager.MockRM
的用法示例。
在下文中一共展示了MockRM.init方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testPolicyInitializeAfterSchedulerInitialized
import org.apache.hadoop.yarn.server.resourcemanager.MockRM; //导入方法依赖的package包/类
@Test
public void testPolicyInitializeAfterSchedulerInitialized() {
@SuppressWarnings("resource")
MockRM rm = new MockRM(conf);
rm.init(conf);
// ProportionalCapacityPreemptionPolicy should be initialized after
// CapacityScheduler initialized. We will
// 1) find SchedulingMonitor from RMActiveService's service list,
// 2) check if ResourceCalculator in policy is null or not.
// If it's not null, we can come to a conclusion that policy initialized
// after scheduler got initialized
for (Service service : rm.getRMActiveService().getServices()) {
if (service instanceof SchedulingMonitor) {
ProportionalCapacityPreemptionPolicy policy =
(ProportionalCapacityPreemptionPolicy) ((SchedulingMonitor) service)
.getSchedulingEditPolicy();
assertNotNull(policy.getResourceCalculator());
return;
}
}
fail("Failed to find SchedulingMonitor service, please check what happened");
}
示例2: testWithNodeLabelUpdateDisabled
import org.apache.hadoop.yarn.server.resourcemanager.MockRM; //导入方法依赖的package包/类
@Test
public void testWithNodeLabelUpdateDisabled() throws Exception {
conf.setLong(YarnConfiguration.RM_NODE_LABELS_PROVIDER_FETCH_INTERVAL_MS,
RMDelegatedNodeLabelsUpdater.DISABLE_DELEGATED_NODE_LABELS_UPDATE);
MockRM rm = new MockRM(conf);
rm.init(conf);
rm.getRMContext().getRMDelegatedNodeLabelsUpdater().nodeLabelsUpdateInterval
= 3 * 1000;
rm.start();
RMNodeLabelsManager mgr = rm.getRMContext().getNodeLabelManager();
mgr.addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of("x"));
NodeId nodeId = toNodeId("h1:1234");
updateNodeLabels(nodeId, "x");
registerNode(rm, nodeId);
Thread.sleep(4000);
// Ensure that even though timer is not run, node labels are fetched
// when node is registered
assertCollectionEquals(ImmutableSet.of("x"), mgr.getLabelsOnNode(nodeId));
rm.stop();
}
示例3: testRMNodeLabelsMappingProviderConfiguration
import org.apache.hadoop.yarn.server.resourcemanager.MockRM; //导入方法依赖的package包/类
@Test
public void testRMNodeLabelsMappingProviderConfiguration() {
conf.unset(YarnConfiguration.RM_NODE_LABELS_PROVIDER_CONFIG);
try {
MockRM rm = new MockRM(conf);
rm.init(conf);
rm.start();
Assert.fail("Expected an exception");
} catch (Exception e) {
// expected an exception
Assert.assertTrue(e.getMessage().contains(
"RMNodeLabelsMappingProvider should be configured"));
}
}
示例4: testWithNodeLabelUpdateEnabled
import org.apache.hadoop.yarn.server.resourcemanager.MockRM; //导入方法依赖的package包/类
@Test
public void testWithNodeLabelUpdateEnabled() throws Exception {
conf.setLong(YarnConfiguration.RM_NODE_LABELS_PROVIDER_FETCH_INTERVAL_MS,
1000);
MockRM rm = new MockRM(conf);
rm.init(conf);
rm.getRMContext().getRMDelegatedNodeLabelsUpdater().nodeLabelsUpdateInterval
= 3 * 1000;
rm.start();
RMNodeLabelsManager mgr = rm.getRMContext().getNodeLabelManager();
mgr.addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of("x", "y"));
NodeId nodeId = toNodeId("h1:1234");
assertEquals(0, mgr.getLabelsOnNode(nodeId).size());
updateNodeLabels(nodeId, "x");
registerNode(rm, nodeId);
Thread.sleep(4000);
assertCollectionEquals(ImmutableSet.of("x"), mgr.getLabelsOnNode(nodeId));
// Ensure that node labels are updated if NodeLabelsProvider
// gives different labels
updateNodeLabels(nodeId, "y");
Thread.sleep(4000);
assertCollectionEquals(ImmutableSet.of("y"), mgr.getLabelsOnNode(nodeId));
rm.stop();
}
示例5: testDefaultResolver
import org.apache.hadoop.yarn.server.resourcemanager.MockRM; //导入方法依赖的package包/类
@Test
public void testDefaultResolver() throws Exception {
Logger rootLogger = LogManager.getRootLogger();
rootLogger.setLevel(Level.DEBUG);
YarnConfiguration conf = new YarnConfiguration();
MockRM rm = new MockRM(conf);
rm.init(conf);
NodesListManager nodesListManager = rm.getNodesListManager();
NodesListManager.Resolver resolver = nodesListManager.getResolver();
Assert.assertTrue("default resolver should be DirectResolver",
resolver instanceof NodesListManager.DirectResolver);
}
示例6: testCachedResolverWithEvent
import org.apache.hadoop.yarn.server.resourcemanager.MockRM; //导入方法依赖的package包/类
@Test
public void testCachedResolverWithEvent() throws Exception {
Logger rootLogger = LogManager.getRootLogger();
rootLogger.setLevel(Level.DEBUG);
YarnConfiguration conf = new YarnConfiguration();
conf.setInt(YarnConfiguration.RM_NODE_IP_CACHE_EXPIRY_INTERVAL_SECS, 30);
MockRM rm = new MockRM(conf);
rm.init(conf);
NodesListManager nodesListManager = rm.getNodesListManager();
nodesListManager.init(conf);
nodesListManager.start();
NodesListManager.CachedResolver resolver =
(NodesListManager.CachedResolver)nodesListManager.getResolver();
resolver.addToCache("testCachedResolverHost1", "1.1.1.1");
resolver.addToCache("testCachedResolverHost2", "1.1.1.2");
Assert.assertEquals("1.1.1.1",
resolver.resolve("testCachedResolverHost1"));
Assert.assertEquals("1.1.1.2",
resolver.resolve("testCachedResolverHost2"));
RMNode rmnode1 = MockNodes.newNodeInfo(1, Resource.newInstance(28000, 8),
1, "testCachedResolverHost1", 1234);
RMNode rmnode2 = MockNodes.newNodeInfo(1, Resource.newInstance(28000, 8),
1, "testCachedResolverHost2", 1234);
nodesListManager.handle(
new NodesListManagerEvent(NodesListManagerEventType.NODE_USABLE,
rmnode1));
Assert.assertNotEquals("1.1.1.1",
resolver.resolve("testCachedResolverHost1"));
Assert.assertEquals("1.1.1.2",
resolver.resolve("testCachedResolverHost2"));
nodesListManager.handle(
new NodesListManagerEvent(NodesListManagerEventType.NODE_USABLE,
rmnode2));
Assert.assertNotEquals("1.1.1.1",
resolver.resolve("testCachedResolverHost1"));
Assert.assertNotEquals("1.1.1.2",
resolver.resolve("testCachedResolverHost2"));
}