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


Java BuilderUtils.newContainer方法代码示例

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


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

示例1: createContainer

import org.apache.hadoop.yarn.server.utils.BuilderUtils; //导入方法依赖的package包/类
/**
 * Create and return a container object reflecting an allocation for the
 * given appliction on the given node with the given capability and
 * priority.
 */
public Container createContainer(
    FSSchedulerNode node, Resource capability, Priority priority) {

  NodeId nodeId = node.getRMNode().getNodeID();
  ContainerId containerId = BuilderUtils.newContainerId(
      getApplicationAttemptId(), getNewContainerId());

  // Create the container
  Container container =
      BuilderUtils.newContainer(containerId, nodeId, node.getRMNode()
          .getHttpAddress(), capability, priority, null);

  return container;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:FSAppAttempt.java

示例2: createContainer

import org.apache.hadoop.yarn.server.utils.BuilderUtils; //导入方法依赖的package包/类
Container createContainer(FiCaSchedulerApp application, FiCaSchedulerNode node, 
    Resource capability, Priority priority) {

  NodeId nodeId = node.getRMNode().getNodeID();
  ContainerId containerId = BuilderUtils.newContainerId(application
      .getApplicationAttemptId(), application.getNewContainerId());

  // Create the container
  Container container =
      BuilderUtils.newContainer(containerId, nodeId, node.getRMNode()
        .getHttpAddress(), capability, priority, null);

  return container;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:LeafQueue.java

示例3: assignContainer

import org.apache.hadoop.yarn.server.utils.BuilderUtils; //导入方法依赖的package包/类
private int assignContainer(FiCaSchedulerNode node, FiCaSchedulerApp application, 
    Priority priority, int assignableContainers, 
    ResourceRequest request, NodeType type) {
  LOG.debug("assignContainers:" +
      " node=" + node.getRMNode().getNodeAddress() + 
      " application=" + application.getApplicationId().getId() + 
      " priority=" + priority.getPriority() + 
      " assignableContainers=" + assignableContainers +
      " request=" + request + " type=" + type);
  Resource capability = request.getCapability();

  int availableContainers = 
    node.getAvailableResource().getMemory() / capability.getMemory(); // TODO: A buggy
                                                                      // application
                                                                      // with this
                                                                      // zero would
                                                                      // crash the
                                                                      // scheduler.
  int assignedContainers = 
    Math.min(assignableContainers, availableContainers);

  if (assignedContainers > 0) {
    for (int i=0; i < assignedContainers; ++i) {

      NodeId nodeId = node.getRMNode().getNodeID();
      ContainerId containerId = BuilderUtils.newContainerId(application
          .getApplicationAttemptId(), application.getNewContainerId());

      // Create the container
      Container container =
          BuilderUtils.newContainer(containerId, nodeId, node.getRMNode()
            .getHttpAddress(), capability, priority, null);
      
      // Allocate!
      
      // Inform the application
      RMContainer rmContainer =
          application.allocate(type, node, priority, request, container);
      
      // Inform the node
      node.allocateContainer(rmContainer);

      // Update usage for this container
      increaseUsedResources(rmContainer);
    }

  }
  
  return assignedContainers;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:51,代码来源:FifoScheduler.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


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