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


Java RMContainerImpl类代码示例

本文整理汇总了Java中org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerImpl的典型用法代码示例。如果您正苦于以下问题:Java RMContainerImpl类的具体用法?Java RMContainerImpl怎么用?Java RMContainerImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RMContainerImpl类属于org.apache.hadoop.yarn.server.resourcemanager.rmcontainer包,在下文中一共展示了RMContainerImpl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: recoverAndCreateContainer

import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerImpl; //导入依赖的package包/类
private RMContainer recoverAndCreateContainer(NMContainerStatus status,
    RMNode node) {
  Container container =
      Container.newInstance(status.getContainerId(), node.getNodeID(),
        node.getHttpAddress(), status.getAllocatedResource(),
        status.getPriority(), null);
  ApplicationAttemptId attemptId =
      container.getId().getApplicationAttemptId();
  RMContainer rmContainer =
      new RMContainerImpl(container, attemptId, node.getNodeID(),
        applications.get(attemptId.getApplicationId()).getUser(), rmContext,
        status.getCreationTime());
  return rmContainer;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:AbstractYarnScheduler.java

示例2: allocateApplicationAttempt

import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerImpl; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private Container allocateApplicationAttempt() {
  scheduleApplicationAttempt();
  
  // Mock the allocation of AM container 
  Container container = mock(Container.class);
  Resource resource = BuilderUtils.newResource(2048, 1, 1);
  when(container.getId()).thenReturn(
      BuilderUtils.newContainerId(applicationAttempt.getAppAttemptId(), 1));
  when(container.getResource()).thenReturn(resource);
  Allocation allocation = mock(Allocation.class);
  when(allocation.getContainers()).
      thenReturn(Collections.singletonList(container));
  when(
      scheduler.allocate(
          any(ApplicationAttemptId.class), 
          any(List.class), 
          any(List.class), 
          any(List.class), 
          any(List.class))).
  thenReturn(allocation);
  RMContainer rmContainer = mock(RMContainerImpl.class);
  when(scheduler.getRMContainer(container.getId())).
      thenReturn(rmContainer);
  
  applicationAttempt.handle(
      new RMAppAttemptContainerAllocatedEvent(
          applicationAttempt.getAppAttemptId()));
  
  assertEquals(RMAppAttemptState.ALLOCATED_SAVING, 
      applicationAttempt.getAppAttemptState());
  applicationAttempt.handle(
      new RMAppAttemptEvent(applicationAttempt.getAppAttemptId(),
          RMAppAttemptEventType.ATTEMPT_NEW_SAVED));
  
  testAppAttemptAllocatedState(container);
  
  return container;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:40,代码来源:TestRMAppAttemptTransitions.java

示例3: recoverAndCreateContainer

import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerImpl; //导入依赖的package包/类
private RMContainer recoverAndCreateContainer(NMContainerStatus status,
    RMNode node) {
  Container container =
      Container.newInstance(status.getContainerId(), node.getNodeID(),
        node.getHttpAddress(), status.getAllocatedResource(),
        status.getPriority(), null);
  ApplicationAttemptId attemptId =
      container.getId().getApplicationAttemptId();
  RMContainer rmContainer =
      new RMContainerImpl(container, attemptId, node.getNodeID(),
        applications.get(attemptId.getApplicationId()).getUser(), rmContext,
        status.getCreationTime(), status.getNodeLabelExpression());
  return rmContainer;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:15,代码来源:AbstractYarnScheduler.java

示例4: allocateApplicationAttempt

import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerImpl; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private Container allocateApplicationAttempt() {
  scheduleApplicationAttempt();
  
  // Mock the allocation of AM container 
  Container container = mock(Container.class);
  Resource resource = BuilderUtils.newResource(2048, 1);
  when(container.getId()).thenReturn(
      BuilderUtils.newContainerId(applicationAttempt.getAppAttemptId(), 1));
  when(container.getResource()).thenReturn(resource);
  Allocation allocation = mock(Allocation.class);
  when(allocation.getContainers()).
      thenReturn(Collections.singletonList(container));
  when(scheduler.allocate(any(ApplicationAttemptId.class), any(List.class),
      any(List.class), any(List.class), any(List.class), any(List.class),
      any(List.class))).
  thenReturn(allocation);
  RMContainer rmContainer = mock(RMContainerImpl.class);
  when(scheduler.getRMContainer(container.getId())).
      thenReturn(rmContainer);
  
  applicationAttempt.handle(
      new RMAppAttemptEvent(applicationAttempt.getAppAttemptId(),
          RMAppAttemptEventType.CONTAINER_ALLOCATED));
  
  assertEquals(RMAppAttemptState.ALLOCATED_SAVING, 
      applicationAttempt.getAppAttemptState());
  applicationAttempt.handle(
      new RMAppAttemptEvent(applicationAttempt.getAppAttemptId(),
          RMAppAttemptEventType.ATTEMPT_NEW_SAVED));
  
  testAppAttemptAllocatedState(container);
  
  return container;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:36,代码来源:TestRMAppAttemptTransitions.java

示例5: allocateApplicationAttempt

import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerImpl; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private Container allocateApplicationAttempt() {
  scheduleApplicationAttempt();
  
  // Mock the allocation of AM container 
  Container container = mock(Container.class);
  Resource resource = BuilderUtils.newResource(2048, 1);
  when(container.getId()).thenReturn(
      BuilderUtils.newContainerId(applicationAttempt.getAppAttemptId(), 1));
  when(container.getResource()).thenReturn(resource);
  Allocation allocation = mock(Allocation.class);
  when(allocation.getContainers()).
      thenReturn(Collections.singletonList(container));
  when(
      scheduler.allocate(
          any(ApplicationAttemptId.class), 
          any(List.class), 
          any(List.class), 
          any(List.class), 
          any(List.class))).
  thenReturn(allocation);
  RMContainer rmContainer = mock(RMContainerImpl.class);
  when(scheduler.getRMContainer(container.getId())).
      thenReturn(rmContainer);
  
  applicationAttempt.handle(
      new RMAppAttemptContainerAllocatedEvent(
          applicationAttempt.getAppAttemptId()));
  
  assertEquals(RMAppAttemptState.ALLOCATED_SAVING, 
      applicationAttempt.getAppAttemptState());
  applicationAttempt.handle(
      new RMAppAttemptEvent(applicationAttempt.getAppAttemptId(),
          RMAppAttemptEventType.ATTEMPT_NEW_SAVED));
  
  testAppAttemptAllocatedState(container);
  
  return container;
}
 
开发者ID:yncxcw,项目名称:big-c,代码行数:40,代码来源:TestRMAppAttemptTransitions.java

示例6: recoverAndCreateContainer

import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerImpl; //导入依赖的package包/类
private RMContainer recoverAndCreateContainer(NMContainerStatus status,
    RMNode node) {
  Container container =
      Container.newInstance(status.getContainerId(), node.getNodeID(),
        node.getHttpAddress(), status.getAllocatedResource(),
        status.getPriority(), null);
  container.setVersion(status.getVersion());
  ApplicationAttemptId attemptId =
      container.getId().getApplicationAttemptId();
  RMContainer rmContainer =
      new RMContainerImpl(container, attemptId, node.getNodeID(),
        applications.get(attemptId.getApplicationId()).getUser(), rmContext,
        status.getCreationTime(), status.getNodeLabelExpression());
  return rmContainer;
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:16,代码来源:AbstractYarnScheduler.java

示例7: createRMContainer

import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerImpl; //导入依赖的package包/类
private RMContainer createRMContainer(ApplicationAttemptId appAttId, int id,
    Resource resource) {
  ContainerId containerId = ContainerId.newContainerId(appAttId, id);
  RMContainer rmContainer = mock(RMContainerImpl.class);
  Container container = mock(Container.class);
  when(container.getResource()).thenReturn(resource);
  when(container.getNodeId()).thenReturn(nodeId);
  when(rmContainer.getContainer()).thenReturn(container);
  when(rmContainer.getContainerId()).thenReturn(containerId);
  return rmContainer;
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:12,代码来源:TestSchedulerApplicationAttempt.java

示例8: transition

import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerImpl; //导入依赖的package包/类
@Override
public RMAppAttemptState transition(RMAppAttemptImpl appAttempt,
    RMAppAttemptEvent event) {
  // Acquire the AM container from the scheduler.
  Allocation amContainerAllocation =
      appAttempt.scheduler.allocate(appAttempt.applicationAttemptId,
        EMPTY_CONTAINER_REQUEST_LIST, EMPTY_CONTAINER_RELEASE_LIST, null,
        null);
  // There must be at least one container allocated, because a
  // CONTAINER_ALLOCATED is emitted after an RMContainer is constructed,
  // and is put in SchedulerApplication#newlyAllocatedContainers.

  // Note that YarnScheduler#allocate is not guaranteed to be able to
  // fetch it since container may not be fetchable for some reason like
  // DNS unavailable causing container token not generated. As such, we
  // return to the previous state and keep retry until am container is
  // fetched.
  if (amContainerAllocation.getContainers().size() == 0) {
    appAttempt.retryFetchingAMContainer(appAttempt);
    return RMAppAttemptState.SCHEDULED;
  }

  // Set the masterContainer
  appAttempt.setMasterContainer(amContainerAllocation.getContainers()
      .get(0));
  RMContainerImpl rmMasterContainer = (RMContainerImpl)appAttempt.scheduler
      .getRMContainer(appAttempt.getMasterContainer().getId());
  rmMasterContainer.setAMContainer(true);
  // The node set in NMTokenSecrentManager is used for marking whether the
  // NMToken has been issued for this node to the AM.
  // When AM container was allocated to RM itself, the node which allocates
  // this AM container was marked as the NMToken already sent. Thus,
  // clear this node set so that the following allocate requests from AM are
  // able to retrieve the corresponding NMToken.
  appAttempt.rmContext.getNMTokenSecretManager()
    .clearNodeSetForAttempt(appAttempt.applicationAttemptId);
  appAttempt.getSubmissionContext().setResource(
    appAttempt.getMasterContainer().getResource());
  appAttempt.storeAttempt();
  return RMAppAttemptState.ALLOCATED_SAVING;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:42,代码来源:RMAppAttemptImpl.java

示例9: allocate

import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerImpl; //导入依赖的package包/类
synchronized public RMContainer allocate(NodeType type, FSSchedulerNode node,
    Priority priority, ResourceRequest request,
    Container container) {
  // Update allowed locality level
  NodeType allowed = allowedLocalityLevel.get(priority);
  if (allowed != null) {
    if (allowed.equals(NodeType.OFF_SWITCH) &&
        (type.equals(NodeType.NODE_LOCAL) ||
            type.equals(NodeType.RACK_LOCAL))) {
      this.resetAllowedLocalityLevel(priority, type);
    }
    else if (allowed.equals(NodeType.RACK_LOCAL) &&
        type.equals(NodeType.NODE_LOCAL)) {
      this.resetAllowedLocalityLevel(priority, type);
    }
  }

  // Required sanity check - AM can call 'allocate' to update resource 
  // request without locking the scheduler, hence we need to check
  if (getTotalRequiredResources(priority) <= 0) {
    return null;
  }
  
  // Create RMContainer
  RMContainer rmContainer = new RMContainerImpl(container, 
      getApplicationAttemptId(), node.getNodeID(),
      appSchedulingInfo.getUser(), rmContext);

  // Add it to allContainers list.
  newlyAllocatedContainers.add(rmContainer);
  liveContainers.put(container.getId(), rmContainer);    

  // Update consumption and track allocations
  List<ResourceRequest> resourceRequestList = appSchedulingInfo.allocate(
      type, node, priority, request, container);
  this.attemptResourceUsage.incUsed(container.getResource());

  // Update resource requests related to "request" and store in RMContainer
  ((RMContainerImpl) rmContainer).setResourceRequests(resourceRequestList);

  // Inform the container
  rmContainer.handle(
      new RMContainerEvent(container.getId(), RMContainerEventType.START));

  if (LOG.isDebugEnabled()) {
    LOG.debug("allocate: applicationAttemptId=" 
        + container.getId().getApplicationAttemptId() 
        + " container=" + container.getId() + " host="
        + container.getNodeId().getHost() + " type=" + type);
  }
  RMAuditLogger.logSuccess(getUser(), 
      AuditConstants.ALLOC_CONTAINER, "SchedulerApp", 
      getApplicationId(), container.getId());
  
  return rmContainer;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:57,代码来源:FSAppAttempt.java

示例10: allocate

import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerImpl; //导入依赖的package包/类
synchronized public RMContainer allocate(NodeType type, FiCaSchedulerNode node,
    Priority priority, ResourceRequest request, 
    Container container) {

  if (isStopped) {
    return null;
  }
  
  // Required sanity check - AM can call 'allocate' to update resource 
  // request without locking the scheduler, hence we need to check
  if (getTotalRequiredResources(priority) <= 0) {
    return null;
  }
  
  // Create RMContainer
  RMContainer rmContainer = new RMContainerImpl(container, this
      .getApplicationAttemptId(), node.getNodeID(),
      appSchedulingInfo.getUser(), this.rmContext);

  // Add it to allContainers list.
  newlyAllocatedContainers.add(rmContainer);
  liveContainers.put(container.getId(), rmContainer);    

  // Update consumption and track allocations
  List<ResourceRequest> resourceRequestList = appSchedulingInfo.allocate(
      type, node, priority, request, container);

  attemptResourceUsage.incUsed(node.getPartition(), container.getResource());

  // Update resource requests related to "request" and store in RMContainer
  ((RMContainerImpl)rmContainer).setResourceRequests(resourceRequestList);

  // Inform the container
  rmContainer.handle(
      new RMContainerEvent(container.getId(), RMContainerEventType.START));

  if (LOG.isDebugEnabled()) {
    LOG.debug("allocate: applicationAttemptId=" 
        + container.getId().getApplicationAttemptId() 
        + " container=" + container.getId() + " host="
        + container.getNodeId().getHost() + " type=" + type);
  }
  RMAuditLogger.logSuccess(getUser(),
      AuditConstants.ALLOC_CONTAINER, "SchedulerApp",
      getApplicationId(), container.getId());
  
  return rmContainer;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:49,代码来源:FiCaSchedulerApp.java

示例11: testGetAppToUnreserve

import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerImpl; //导入依赖的package包/类
@Test
public void testGetAppToUnreserve() throws Exception {

  CapacitySchedulerConfiguration csConf = new CapacitySchedulerConfiguration();
  setup(csConf);
  final String user_0 = "user_0";
  final ApplicationAttemptId appAttemptId_0 = TestUtils
      .getMockApplicationAttemptId(0, 0);
  LeafQueue a = stubLeafQueue((LeafQueue) queues.get(A));
  FiCaSchedulerApp app_0 = new FiCaSchedulerApp(appAttemptId_0, user_0, a,
      mock(ActiveUsersManager.class), spyRMContext);

  String host_0 = "host_0";
  FiCaSchedulerNode node_0 = TestUtils.getMockNode(host_0, DEFAULT_RACK, 0,
      8 * GB);
  String host_1 = "host_1";
  FiCaSchedulerNode node_1 = TestUtils.getMockNode(host_1, DEFAULT_RACK, 0,
      8 * GB);
  
  Resource clusterResource = Resources.createResource(2 * 8 * GB);

  // Setup resource-requests
  Priority priorityMap = TestUtils.createMockPriority(5);
  Resource capability = Resources.createResource(2*GB, 0);

  RMApplicationHistoryWriter writer = mock(RMApplicationHistoryWriter.class);
  SystemMetricsPublisher publisher = mock(SystemMetricsPublisher.class);
  RMContext rmContext = mock(RMContext.class);
  ContainerAllocationExpirer expirer =
    mock(ContainerAllocationExpirer.class);
  DrainDispatcher drainDispatcher = new DrainDispatcher();
  when(rmContext.getContainerAllocationExpirer()).thenReturn(expirer);
  when(rmContext.getDispatcher()).thenReturn(drainDispatcher);
  when(rmContext.getRMApplicationHistoryWriter()).thenReturn(writer);
  when(rmContext.getSystemMetricsPublisher()).thenReturn(publisher);
  ApplicationAttemptId appAttemptId = BuilderUtils.newApplicationAttemptId(
      app_0.getApplicationId(), 1);
  ContainerId containerId = BuilderUtils.newContainerId(appAttemptId, 1);
  Container container = TestUtils.getMockContainer(containerId,
      node_1.getNodeID(), Resources.createResource(2*GB), priorityMap);
  RMContainer rmContainer = new RMContainerImpl(container, appAttemptId,
      node_1.getNodeID(), "user", rmContext);

  Container container_1 = TestUtils.getMockContainer(containerId,
      node_0.getNodeID(), Resources.createResource(1*GB), priorityMap);
  RMContainer rmContainer_1 = new RMContainerImpl(container_1, appAttemptId,
      node_0.getNodeID(), "user", rmContext);

  // no reserved containers
  NodeId unreserveId =
      app_0.getNodeIdToUnreserve(priorityMap, capability,
          cs.getResourceCalculator(), clusterResource);
  assertEquals(null, unreserveId);

  // no reserved containers - reserve then unreserve
  app_0.reserve(node_0, priorityMap, rmContainer_1, container_1);
  app_0.unreserve(node_0, priorityMap);
  unreserveId = app_0.getNodeIdToUnreserve(priorityMap, capability,
      cs.getResourceCalculator(), clusterResource);
  assertEquals(null, unreserveId);

  // no container large enough is reserved
  app_0.reserve(node_0, priorityMap, rmContainer_1, container_1);
  unreserveId = app_0.getNodeIdToUnreserve(priorityMap, capability,
      cs.getResourceCalculator(), clusterResource);
  assertEquals(null, unreserveId);

  // reserve one that is now large enough
  app_0.reserve(node_1, priorityMap, rmContainer, container);
  unreserveId = app_0.getNodeIdToUnreserve(priorityMap, capability,
      cs.getResourceCalculator(), clusterResource);
  assertEquals(node_1.getNodeID(), unreserveId);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:74,代码来源:TestReservations.java

示例12: testFindNodeToUnreserve

import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerImpl; //导入依赖的package包/类
@Test
public void testFindNodeToUnreserve() throws Exception {

  CapacitySchedulerConfiguration csConf = new CapacitySchedulerConfiguration();
  setup(csConf);
  final String user_0 = "user_0";
  final ApplicationAttemptId appAttemptId_0 = TestUtils
      .getMockApplicationAttemptId(0, 0);
  LeafQueue a = stubLeafQueue((LeafQueue) queues.get(A));
  FiCaSchedulerApp app_0 = new FiCaSchedulerApp(appAttemptId_0, user_0, a,
      mock(ActiveUsersManager.class), spyRMContext);

  String host_1 = "host_1";
  FiCaSchedulerNode node_1 = TestUtils.getMockNode(host_1, DEFAULT_RACK, 0,
      8 * GB);

  // Setup resource-requests
  Priority priorityMap = TestUtils.createMockPriority(5);
  Resource capability = Resources.createResource(2 * GB, 0);

  RMApplicationHistoryWriter writer = mock(RMApplicationHistoryWriter.class);
  SystemMetricsPublisher publisher = mock(SystemMetricsPublisher.class);
  RMContext rmContext = mock(RMContext.class);
  ContainerAllocationExpirer expirer =
    mock(ContainerAllocationExpirer.class);
  DrainDispatcher drainDispatcher = new DrainDispatcher();
  when(rmContext.getContainerAllocationExpirer()).thenReturn(expirer);
  when(rmContext.getDispatcher()).thenReturn(drainDispatcher);
  when(rmContext.getRMApplicationHistoryWriter()).thenReturn(writer);
  when(rmContext.getSystemMetricsPublisher()).thenReturn(publisher);
  ApplicationAttemptId appAttemptId = BuilderUtils.newApplicationAttemptId(
      app_0.getApplicationId(), 1);
  ContainerId containerId = BuilderUtils.newContainerId(appAttemptId, 1);
  Container container = TestUtils.getMockContainer(containerId,
      node_1.getNodeID(), Resources.createResource(2*GB), priorityMap);
  RMContainer rmContainer = new RMContainerImpl(container, appAttemptId,
      node_1.getNodeID(), "user", rmContext);

  // nothing reserved
  boolean res = a.findNodeToUnreserve(csContext.getClusterResource(),
      node_1, app_0, priorityMap, capability);
  assertFalse(res);

  // reserved but scheduler doesn't know about that node.
  app_0.reserve(node_1, priorityMap, rmContainer, container);
  node_1.reserveResource(app_0, priorityMap, rmContainer);
  res = a.findNodeToUnreserve(csContext.getClusterResource(), node_1, app_0,
      priorityMap, capability);
  assertFalse(res);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:51,代码来源:TestReservations.java

示例13: getRMApp

import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerImpl; //导入依赖的package包/类
private RMAppImpl getRMApp(RMContext rmContext, YarnScheduler yarnScheduler,
    ApplicationId applicationId3, YarnConfiguration config, String queueName,
    final long memorySeconds, final long vcoreSeconds, final long gcoreSeconds) {
  ApplicationSubmissionContext asContext = mock(ApplicationSubmissionContext.class);
  when(asContext.getMaxAppAttempts()).thenReturn(1);

  RMAppImpl app =
      spy(new RMAppImpl(applicationId3, rmContext, config, null, null,
          queueName, asContext, yarnScheduler, null,
          System.currentTimeMillis(), "YARN", null,
          BuilderUtils.newResourceRequest(
              RMAppAttemptImpl.AM_CONTAINER_PRIORITY, ResourceRequest.ANY,
              Resource.newInstance(1024, 1, 1), 1)){
                @Override
                public ApplicationReport createAndGetApplicationReport(
                    String clientUserName, boolean allowAccess) {
                  ApplicationReport report = super.createAndGetApplicationReport(
                      clientUserName, allowAccess);
                  ApplicationResourceUsageReport usageReport = 
                      report.getApplicationResourceUsageReport();
                  usageReport.setMemorySeconds(memorySeconds);
                  usageReport.setVcoreSeconds(vcoreSeconds);
                  usageReport.setGcoreSeconds(gcoreSeconds);
                  report.setApplicationResourceUsageReport(usageReport);
                  return report;
                }
            });

  ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance(
      ApplicationId.newInstance(123456, 1), 1);
  RMAppAttemptImpl rmAppAttemptImpl = spy(new RMAppAttemptImpl(attemptId,
      rmContext, yarnScheduler, null, asContext, config, false, null));
  Container container = Container.newInstance(
      ContainerId.newContainerId(attemptId, 1), null, "", null, null, null);
  RMContainerImpl containerimpl = spy(new RMContainerImpl(container,
      attemptId, null, "", rmContext));
  Map<ApplicationAttemptId, RMAppAttempt> attempts = 
    new HashMap<ApplicationAttemptId, RMAppAttempt>();
  attempts.put(attemptId, rmAppAttemptImpl);
  when(app.getCurrentAppAttempt()).thenReturn(rmAppAttemptImpl);
  when(app.getAppAttempts()).thenReturn(attempts);
  when(rmAppAttemptImpl.getMasterContainer()).thenReturn(container);
  ResourceScheduler rs = mock(ResourceScheduler.class);
  when(rmContext.getScheduler()).thenReturn(rs);
  when(rmContext.getScheduler().getRMContainer(any(ContainerId.class)))
      .thenReturn(containerimpl);
  SchedulerAppReport sAppReport = mock(SchedulerAppReport.class);
  when(
      rmContext.getScheduler().getSchedulerAppInfo(
          any(ApplicationAttemptId.class))).thenReturn(sAppReport);
  List<RMContainer> rmContainers = new ArrayList<RMContainer>();
  rmContainers.add(containerimpl);
  when(
      rmContext.getScheduler().getSchedulerAppInfo(attemptId)
          .getLiveContainers()).thenReturn(rmContainers);
  ContainerStatus cs = mock(ContainerStatus.class);
  when(containerimpl.getFinishedStatus()).thenReturn(cs);
  when(containerimpl.getDiagnosticsInfo()).thenReturn("N/A");
  when(containerimpl.getContainerExitStatus()).thenReturn(0);
  when(containerimpl.getContainerState()).thenReturn(ContainerState.COMPLETE);
  return app;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:63,代码来源:TestClientRMService.java

示例14: transition

import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerImpl; //导入依赖的package包/类
@Override
public RMAppAttemptState transition(RMAppAttemptImpl appAttempt,
    RMAppAttemptEvent event) {
  // Acquire the AM container from the scheduler.
  Allocation amContainerAllocation =
      appAttempt.scheduler.allocate(appAttempt.applicationAttemptId,
        EMPTY_CONTAINER_REQUEST_LIST, EMPTY_CONTAINER_RELEASE_LIST, null,
        null, null, null);
  // There must be at least one container allocated, because a
  // CONTAINER_ALLOCATED is emitted after an RMContainer is constructed,
  // and is put in SchedulerApplication#newlyAllocatedContainers.

  // Note that YarnScheduler#allocate is not guaranteed to be able to
  // fetch it since container may not be fetchable for some reason like
  // DNS unavailable causing container token not generated. As such, we
  // return to the previous state and keep retry until am container is
  // fetched.
  if (amContainerAllocation.getContainers().size() == 0) {
    appAttempt.retryFetchingAMContainer(appAttempt);
    return RMAppAttemptState.SCHEDULED;
  }

  // Set the masterContainer
  appAttempt.setMasterContainer(amContainerAllocation.getContainers()
      .get(0));
  RMContainerImpl rmMasterContainer = (RMContainerImpl)appAttempt.scheduler
      .getRMContainer(appAttempt.getMasterContainer().getId());
  rmMasterContainer.setAMContainer(true);
  // The node set in NMTokenSecrentManager is used for marking whether the
  // NMToken has been issued for this node to the AM.
  // When AM container was allocated to RM itself, the node which allocates
  // this AM container was marked as the NMToken already sent. Thus,
  // clear this node set so that the following allocate requests from AM are
  // able to retrieve the corresponding NMToken.
  appAttempt.rmContext.getNMTokenSecretManager()
    .clearNodeSetForAttempt(appAttempt.applicationAttemptId);
  appAttempt.getSubmissionContext().setResource(
    appAttempt.getMasterContainer().getResource());
  appAttempt.storeAttempt();
  return RMAppAttemptState.ALLOCATED_SAVING;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:42,代码来源:RMAppAttemptImpl.java

示例15: allocate

import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerImpl; //导入依赖的package包/类
synchronized public RMContainer allocate(NodeType type, FiCaSchedulerNode node,
    Priority priority, ResourceRequest request, 
    Container container) {

  if (isStopped) {
    return null;
  }
  
  // Required sanity check - AM can call 'allocate' to update resource 
  // request without locking the scheduler, hence we need to check
  if (getTotalRequiredResources(priority) <= 0) {
    return null;
  }
  
  // Create RMContainer
  RMContainer rmContainer =
      new RMContainerImpl(container, this.getApplicationAttemptId(),
          node.getNodeID(), appSchedulingInfo.getUser(), this.rmContext,
          request.getNodeLabelExpression());

  updateAMContainerDiagnostics(AMState.ASSIGNED, null);

  // Add it to allContainers list.
  newlyAllocatedContainers.add(rmContainer);
  liveContainers.put(container.getId(), rmContainer);    

  // Update consumption and track allocations
  List<ResourceRequest> resourceRequestList = appSchedulingInfo.allocate(
      type, node, priority, request, container);

  attemptResourceUsage.incUsed(node.getPartition(), container.getResource());

  // Update resource requests related to "request" and store in RMContainer
  ((RMContainerImpl)rmContainer).setResourceRequests(resourceRequestList);

  // Inform the container
  rmContainer.handle(
      new RMContainerEvent(container.getId(), RMContainerEventType.START));

  if (LOG.isDebugEnabled()) {
    LOG.debug("allocate: applicationAttemptId=" 
        + container.getId().getApplicationAttemptId() 
        + " container=" + container.getId() + " host="
        + container.getNodeId().getHost() + " type=" + type);
  }
  RMAuditLogger.logSuccess(getUser(),
      AuditConstants.ALLOC_CONTAINER, "SchedulerApp",
      getApplicationId(), container.getId());
  
  return rmContainer;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:52,代码来源:FiCaSchedulerApp.java


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