当前位置: 首页>>代码示例>>Java>>正文


Java BuilderUtils.newNodeId方法代码示例

本文整理汇总了Java中org.apache.hadoop.yarn.server.utils.BuilderUtils.newNodeId方法的典型用法代码示例。如果您正苦于以下问题:Java BuilderUtils.newNodeId方法的具体用法?Java BuilderUtils.newNodeId怎么用?Java BuilderUtils.newNodeId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.yarn.server.utils.BuilderUtils的用法示例。


在下文中一共展示了BuilderUtils.newNodeId方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRunningNode

import org.apache.hadoop.yarn.server.utils.BuilderUtils; //导入方法依赖的package包/类
private RMNodeImpl getRunningNode(String nmVersion) {
  NodeId nodeId = BuilderUtils.newNodeId("localhost", 0);
  Resource capability = Resource.newInstance(4096, 4, 4);
  RMNodeImpl node = new RMNodeImpl(nodeId, rmContext,null, 0, 0,
      null, capability, nmVersion);
  node.handle(new RMNodeStartedEvent(node.getNodeID(), null, null));
  Assert.assertEquals(NodeState.RUNNING, node.getState());
  return node;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:10,代码来源:TestRMNodeTransitions.java

示例2: getRebootedNode

import org.apache.hadoop.yarn.server.utils.BuilderUtils; //导入方法依赖的package包/类
private RMNodeImpl getRebootedNode() {
  NodeId nodeId = BuilderUtils.newNodeId("localhost", 0);
  Resource capability = Resource.newInstance(4096, 4, 4);
  RMNodeImpl node = new RMNodeImpl(nodeId, rmContext,null, 0, 0,
      null, capability, null);
  node.handle(new RMNodeStartedEvent(node.getNodeID(), null, null));
  Assert.assertEquals(NodeState.RUNNING, node.getState());
  node.handle(new RMNodeEvent(node.getNodeID(), RMNodeEventType.REBOOTING));
  Assert.assertEquals(NodeState.REBOOTED, node.getState());
  return node;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:12,代码来源:TestRMNodeTransitions.java

示例3: MockNM

import org.apache.hadoop.yarn.server.utils.BuilderUtils; //导入方法依赖的package包/类
public MockNM(String nodeIdStr, int memory, int vcores, int gcores,
    ResourceTrackerService resourceTracker, String version) {
  this.memory = memory;
  this.vCores = vcores;
  this.gCores = gcores;
  this.resourceTracker = resourceTracker;
  this.version = version;
  String[] splits = nodeIdStr.split(":");
  nodeId = BuilderUtils.newNodeId(splits[0], Integer.parseInt(splits[1]));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:MockNM.java

示例4: testExpireWhileRunning

import org.apache.hadoop.yarn.server.utils.BuilderUtils; //导入方法依赖的package包/类
@Test
public void testExpireWhileRunning() {

  DrainDispatcher drainDispatcher = new DrainDispatcher();
  EventHandler<RMAppAttemptEvent> appAttemptEventHandler = mock(EventHandler.class);
  EventHandler generic = mock(EventHandler.class);
  drainDispatcher.register(RMAppAttemptEventType.class,
      appAttemptEventHandler);
  drainDispatcher.register(RMNodeEventType.class, generic);
  drainDispatcher.init(new YarnConfiguration());
  drainDispatcher.start();
  NodeId nodeId = BuilderUtils.newNodeId("host", 3425);
  ApplicationId appId = BuilderUtils.newApplicationId(1, 1);
  ApplicationAttemptId appAttemptId = BuilderUtils.newApplicationAttemptId(
      appId, 1);
  ContainerId containerId = BuilderUtils.newContainerId(appAttemptId, 1);
  ContainerAllocationExpirer expirer = mock(ContainerAllocationExpirer.class);

  Resource resource = BuilderUtils.newResource(512, 1, 1);
  Priority priority = BuilderUtils.newPriority(5);

  Container container = BuilderUtils.newContainer(containerId, nodeId,
      "host:3465", resource, priority, null);

  RMApplicationHistoryWriter writer = mock(RMApplicationHistoryWriter.class);
  SystemMetricsPublisher publisher = mock(SystemMetricsPublisher.class);
  RMContext rmContext = mock(RMContext.class);
  when(rmContext.getDispatcher()).thenReturn(drainDispatcher);
  when(rmContext.getContainerAllocationExpirer()).thenReturn(expirer);
  when(rmContext.getRMApplicationHistoryWriter()).thenReturn(writer);
  when(rmContext.getSystemMetricsPublisher()).thenReturn(publisher);
  when(rmContext.getYarnConfiguration()).thenReturn(new YarnConfiguration());
  RMContainer rmContainer = new RMContainerImpl(container, appAttemptId,
      nodeId, "user", rmContext);

  assertEquals(RMContainerState.NEW, rmContainer.getState());
  assertEquals(resource, rmContainer.getAllocatedResource());
  assertEquals(nodeId, rmContainer.getAllocatedNode());
  assertEquals(priority, rmContainer.getAllocatedPriority());
  verify(writer).containerStarted(any(RMContainer.class));
  verify(publisher).containerCreated(any(RMContainer.class), anyLong());

  rmContainer.handle(new RMContainerEvent(containerId,
      RMContainerEventType.START));
  drainDispatcher.await();
  assertEquals(RMContainerState.ALLOCATED, rmContainer.getState());

  rmContainer.handle(new RMContainerEvent(containerId,
      RMContainerEventType.ACQUIRED));
  drainDispatcher.await();
  assertEquals(RMContainerState.ACQUIRED, rmContainer.getState());

  rmContainer.handle(new RMContainerEvent(containerId,
      RMContainerEventType.LAUNCHED));
  drainDispatcher.await();
  assertEquals(RMContainerState.RUNNING, rmContainer.getState());
  assertEquals("http://host:3465/node/containerlogs/container_1_0001_01_000001/user",
      rmContainer.getLogURL());

  // In RUNNING state. Verify EXPIRE and associated actions.
  reset(appAttemptEventHandler);
  ContainerStatus containerStatus = SchedulerUtils
      .createAbnormalContainerStatus(containerId,
          SchedulerUtils.EXPIRED_CONTAINER);
  rmContainer.handle(new RMContainerFinishedEvent(containerId,
      containerStatus, RMContainerEventType.EXPIRE));
  drainDispatcher.await();
  assertEquals(RMContainerState.RUNNING, rmContainer.getState());
  verify(writer, never()).containerFinished(any(RMContainer.class));
  verify(publisher, never()).containerFinished(any(RMContainer.class),
      anyLong());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:73,代码来源:TestRMContainerImpl.java

示例5: setUp

import org.apache.hadoop.yarn.server.utils.BuilderUtils; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
  InlineDispatcher rmDispatcher = new InlineDispatcher();
  
  rmContext =
      new RMContextImpl(rmDispatcher, null, null, null,
          mock(DelegationTokenRenewer.class), null, null, null, null, null);
  NodesListManager nodesListManager = mock(NodesListManager.class);
  HostsFileReader reader = mock(HostsFileReader.class);
  when(nodesListManager.getHostsReader()).thenReturn(reader);
  ((RMContextImpl) rmContext).setNodesListManager(nodesListManager);
  scheduler = mock(YarnScheduler.class);
  doAnswer(
      new Answer<Void>() {

        @Override
        public Void answer(InvocationOnMock invocation) throws Throwable {
          final SchedulerEvent event = (SchedulerEvent)(invocation.getArguments()[0]);
          eventType = event.getType();
          if (eventType == SchedulerEventType.NODE_UPDATE) {
            List<UpdatedContainerInfo> lastestContainersInfoList = 
                ((NodeUpdateSchedulerEvent)event).getRMNode().pullContainerUpdates();
            for(UpdatedContainerInfo lastestContainersInfo : lastestContainersInfoList) {
          	  completedContainers.addAll(lastestContainersInfo.getCompletedContainers()); 
            }
          }
          return null;
        }
      }
      ).when(scheduler).handle(any(SchedulerEvent.class));
  
  rmDispatcher.register(SchedulerEventType.class, 
      new TestSchedulerEventDispatcher());
  
  rmDispatcher.register(NodesListManagerEventType.class,
      new TestNodeListManagerEventDispatcher());

  NodeId nodeId = BuilderUtils.newNodeId("localhost", 0);
  node = new RMNodeImpl(nodeId, rmContext, null, 0, 0, null, null, null);
  nodesListManagerEvent =  null;

}
 
开发者ID:naver,项目名称:hadoop,代码行数:43,代码来源:TestRMNodeTransitions.java

示例6: testContainerUpdate

import org.apache.hadoop.yarn.server.utils.BuilderUtils; //导入方法依赖的package包/类
@Test (timeout = 5000)
public void testContainerUpdate() throws InterruptedException{
  //Start the node
  node.handle(new RMNodeStartedEvent(null, null, null));
  
  NodeId nodeId = BuilderUtils.newNodeId("localhost:1", 1);
  RMNodeImpl node2 = new RMNodeImpl(nodeId, rmContext, null, 0, 0, null, null, null);
  node2.handle(new RMNodeStartedEvent(null, null, null));
  
  ContainerId completedContainerIdFromNode1 = BuilderUtils.newContainerId(
      BuilderUtils.newApplicationAttemptId(
          BuilderUtils.newApplicationId(0, 0), 0), 0);
  ContainerId completedContainerIdFromNode2_1 = BuilderUtils.newContainerId(
      BuilderUtils.newApplicationAttemptId(
          BuilderUtils.newApplicationId(1, 1), 1), 1);
  ContainerId completedContainerIdFromNode2_2 = BuilderUtils.newContainerId(
      BuilderUtils.newApplicationAttemptId(
          BuilderUtils.newApplicationId(1, 1), 1), 2);
 
  RMNodeStatusEvent statusEventFromNode1 = getMockRMNodeStatusEvent();
  RMNodeStatusEvent statusEventFromNode2_1 = getMockRMNodeStatusEvent();
  RMNodeStatusEvent statusEventFromNode2_2 = getMockRMNodeStatusEvent();
  
  ContainerStatus containerStatusFromNode1 = mock(ContainerStatus.class);
  ContainerStatus containerStatusFromNode2_1 = mock(ContainerStatus.class);
  ContainerStatus containerStatusFromNode2_2 = mock(ContainerStatus.class);

  doReturn(completedContainerIdFromNode1).when(containerStatusFromNode1)
      .getContainerId();
  doReturn(Collections.singletonList(containerStatusFromNode1))
      .when(statusEventFromNode1).getContainers();
  node.handle(statusEventFromNode1);
  Assert.assertEquals(1, completedContainers.size());
  Assert.assertEquals(completedContainerIdFromNode1,
      completedContainers.get(0).getContainerId());

  completedContainers.clear();

  doReturn(completedContainerIdFromNode2_1).when(containerStatusFromNode2_1)
      .getContainerId();
  doReturn(Collections.singletonList(containerStatusFromNode2_1))
      .when(statusEventFromNode2_1).getContainers();

  doReturn(completedContainerIdFromNode2_2).when(containerStatusFromNode2_2)
      .getContainerId();
  doReturn(Collections.singletonList(containerStatusFromNode2_2))
      .when(statusEventFromNode2_2).getContainers();

  node2.setNextHeartBeat(false);
  node2.handle(statusEventFromNode2_1);
  node2.setNextHeartBeat(true);
  node2.handle(statusEventFromNode2_2);

  Assert.assertEquals(2, completedContainers.size());
  Assert.assertEquals(completedContainerIdFromNode2_1,completedContainers.get(0)
      .getContainerId()); 
  Assert.assertEquals(completedContainerIdFromNode2_2,completedContainers.get(1)
      .getContainerId());   
}
 
开发者ID:naver,项目名称:hadoop,代码行数:60,代码来源:TestRMNodeTransitions.java

示例7: getNewNode

import org.apache.hadoop.yarn.server.utils.BuilderUtils; //导入方法依赖的package包/类
private RMNodeImpl getNewNode() {
  NodeId nodeId = BuilderUtils.newNodeId("localhost", 0);
  RMNodeImpl node = new RMNodeImpl(nodeId, rmContext, null, 0, 0, null, null, null);
  return node;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:6,代码来源:TestRMNodeTransitions.java

示例8: testNodeRegistrationWithMinimumAllocations

import org.apache.hadoop.yarn.server.utils.BuilderUtils; //导入方法依赖的package包/类
@Test
public void testNodeRegistrationWithMinimumAllocations() throws Exception {
  Configuration conf = new Configuration();
  conf.set(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_MB, "2048");
  conf.set(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_VCORES, "4");
  conf.set(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_GCORES, "4");
  rm = new MockRM(conf);
  rm.start();

  ResourceTrackerService resourceTrackerService
    = rm.getResourceTrackerService();
  RegisterNodeManagerRequest req = Records.newRecord(
      RegisterNodeManagerRequest.class);
  NodeId nodeId = BuilderUtils.newNodeId("host", 1234);
  req.setNodeId(nodeId);

  Resource capability = BuilderUtils.newResource(1024, 1, 1);
  req.setResource(capability);
  RegisterNodeManagerResponse response1 =
      resourceTrackerService.registerNodeManager(req);
  Assert.assertEquals(NodeAction.SHUTDOWN,response1.getNodeAction());
  
  capability.setMemory(2048);
  capability.setVirtualCores(1);
  capability.setGpuCores(1);
  req.setResource(capability);
  RegisterNodeManagerResponse response2 =
      resourceTrackerService.registerNodeManager(req);
  Assert.assertEquals(NodeAction.SHUTDOWN,response2.getNodeAction());
  
  capability.setMemory(1024);
  capability.setVirtualCores(4);
  capability.setGpuCores(4);
  req.setResource(capability);
  RegisterNodeManagerResponse response3 =
      resourceTrackerService.registerNodeManager(req);
  Assert.assertEquals(NodeAction.SHUTDOWN,response3.getNodeAction());
  
  capability.setMemory(2048);
  capability.setVirtualCores(4);
  capability.setGpuCores(4);
  req.setResource(capability);
  RegisterNodeManagerResponse response4 =
      resourceTrackerService.registerNodeManager(req);
  Assert.assertEquals(NodeAction.NORMAL,response4.getNodeAction());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:47,代码来源:TestResourceTrackerService.java


注:本文中的org.apache.hadoop.yarn.server.utils.BuilderUtils.newNodeId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。