• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Allocation类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getAllocation

import org.apache.hadoop.yarn.server.resourcemanager.scheduler.Allocation; //导入依赖的package包/类
/**
 * This method produces an Allocation that includes the current view
 * of the resources that will be allocated to and preempted from this
 * application.
 *
 * @param rc
 * @param clusterResource
 * @param minimumAllocation
 * @return an allocation
 */
public synchronized Allocation getAllocation(ResourceCalculator rc,
    Resource clusterResource, Resource minimumAllocation) {

  Set<ContainerId> currentContPreemption = Collections.unmodifiableSet(
      new HashSet<ContainerId>(containersToPreempt));
  containersToPreempt.clear();
  Resource tot = Resource.newInstance(0, 0, 0);
  for(ContainerId c : currentContPreemption){
    Resources.addTo(tot,
        liveContainers.get(c).getContainer().getResource());
  }
  int numCont = (int) Math.ceil(
      Resources.divide(rc, clusterResource, tot, minimumAllocation));
  ResourceRequest rr = ResourceRequest.newInstance(
      Priority.UNDEFINED, ResourceRequest.ANY,
      minimumAllocation, numCont);
  ContainersAndNMTokensAllocation allocation =
      pullNewlyAllocatedContainersAndNMTokens();
  Resource headroom = getHeadroom();
  setApplicationHeadroomForMetrics(headroom);
  return new Allocation(allocation.getContainerList(), headroom, null,
    currentContPreemption, Collections.singletonList(rr),
    allocation.getNMTokenList());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:35,代码来源:FiCaSchedulerApp.java


示例2: allocate

import org.apache.hadoop.yarn.server.resourcemanager.scheduler.Allocation; //导入依赖的package包/类
@Override
public synchronized Allocation allocate(
    ApplicationAttemptId applicationAttemptId, List<ResourceRequest> ask,
    List<ContainerId> release, List<String> blacklistAdditions,
    List<String> blacklistRemovals) {
  List<ResourceRequest> askCopy = new ArrayList<ResourceRequest>();
  for (ResourceRequest req : ask) {
    ResourceRequest reqCopy =
        ResourceRequest.newInstance(req.getPriority(),
            req.getResourceName(), req.getCapability(),
            req.getNumContainers(), req.getRelaxLocality());
    askCopy.add(reqCopy);
  }
  lastAsk = ask;
  lastRelease = release;
  lastBlacklistAdditions = blacklistAdditions;
  lastBlacklistRemovals = blacklistRemovals;
  return super.allocate(applicationAttemptId, askCopy, release,
      blacklistAdditions, blacklistRemovals);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:TestAMRMClientOnRMRestart.java


示例3: allocate

import org.apache.hadoop.yarn.server.resourcemanager.scheduler.Allocation; //导入依赖的package包/类
@Override
public synchronized Allocation allocate(
    ApplicationAttemptId applicationAttemptId, List<ResourceRequest> ask,
    List<ContainerId> release, 
    List<String> blacklistAdditions, List<String> blacklistRemovals) {
  List<ResourceRequest> askCopy = new ArrayList<ResourceRequest>();
  for (ResourceRequest req : ask) {
    ResourceRequest reqCopy = ResourceRequest.newInstance(req
        .getPriority(), req.getResourceName(), req.getCapability(), req
        .getNumContainers(), req.getRelaxLocality());
    askCopy.add(reqCopy);
  }
  SecurityUtil.setTokenServiceUseIp(false);
  lastAsk = ask;
  lastRelease = release;
  lastBlacklistAdditions = blacklistAdditions;
  lastBlacklistRemovals = blacklistRemovals;
  return super.allocate(
      applicationAttemptId, askCopy, release, 
      blacklistAdditions, blacklistRemovals);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:TestRMContainerAllocator.java


示例4: allocate

import org.apache.hadoop.yarn.server.resourcemanager.scheduler.Allocation; //导入依赖的package包/类
@Override
public synchronized Allocation allocate(
    ApplicationAttemptId applicationAttemptId, List<ResourceRequest> ask,
    List<ContainerId> release, List<String> blacklistAdditions,
    List<String> blacklistRemovals,
    List<ContainerResourceChangeRequest> increaseRequests,
    List<ContainerResourceChangeRequest> decreaseRequests) {
  List<ResourceRequest> askCopy = new ArrayList<ResourceRequest>();
  for (ResourceRequest req : ask) {
    ResourceRequest reqCopy =
        ResourceRequest.newInstance(req.getPriority(),
            req.getResourceName(), req.getCapability(),
            req.getNumContainers(), req.getRelaxLocality());
    askCopy.add(reqCopy);
  }
  lastAsk = ask;
  lastRelease = release;
  lastIncrease = increaseRequests;
  lastDecrease = decreaseRequests;
  lastBlacklistAdditions = blacklistAdditions;
  lastBlacklistRemovals = blacklistRemovals;
  return super.allocate(applicationAttemptId, askCopy, release,
      blacklistAdditions, blacklistRemovals, increaseRequests,
      decreaseRequests);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:26,代码来源:TestAMRMClientOnRMRestart.java


示例5: generatePreemptionMessage

import org.apache.hadoop.yarn.server.resourcemanager.scheduler.Allocation; //导入依赖的package包/类
private PreemptionMessage generatePreemptionMessage(
    Set<ContainerId> containerToPreempt,
    HashMap<ContainerId, Resource> resPerCont,
    Resource minimumAllocation, boolean strict) {

  Set<ContainerId> currentContPreemption = Collections.unmodifiableSet(
      new HashSet<ContainerId>(containerToPreempt));
  containerToPreempt.clear();
  Resource tot = Resource.newInstance(0, 0);
  for(ContainerId c : currentContPreemption){
    Resources.addTo(tot,
        resPerCont.get(c));
  }
  int numCont = (int) Math.ceil(tot.getMemory() /
            (double) minimumAllocation.getMemory());
  ResourceRequest rr = ResourceRequest.newInstance(
      Priority.newInstance(0), ResourceRequest.ANY,
      minimumAllocation, numCont);
  if (strict) {
    return generatePreemptionMessage(new Allocation(null, null,
                currentContPreemption, null, null));
  }
  return generatePreemptionMessage(new Allocation(null, null,
                        null, currentContPreemption,
                        Collections.singletonList(rr)));
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:27,代码来源:TestCheckpointPreemptionPolicy.java


示例6: getAllocation

import org.apache.hadoop.yarn.server.resourcemanager.scheduler.Allocation; //导入依赖的package包/类
/**
 * This method produces an Allocation that includes the current view
 * of the resources that will be allocated to and preempted from this
 * application.
 *
 * @param rc
 * @param clusterResource
 * @param minimumAllocation
 * @return an allocation
 */
public synchronized Allocation getAllocation(ResourceCalculator rc,
    Resource clusterResource, Resource minimumAllocation) {

  Set<ContainerId> currentContPreemption = Collections.unmodifiableSet(
      new HashSet<ContainerId>(containersToPreempt));
  containersToPreempt.clear();
  Resource tot = Resource.newInstance(0, 0);
  for(ContainerId c : currentContPreemption){
    Resources.addTo(tot,
        liveContainers.get(c).getContainer().getResource());
  }
  int numCont = (int) Math.ceil(
      Resources.divide(rc, clusterResource, tot, minimumAllocation));
  ResourceRequest rr = ResourceRequest.newInstance(
      Priority.UNDEFINED, ResourceRequest.ANY,
      minimumAllocation, numCont);
  ContainersAndNMTokensAllocation allocation =
      pullNewlyAllocatedContainersAndNMTokens();
  Resource headroom = getHeadroom();
  setApplicationHeadroomForMetrics(headroom);
  return new Allocation(allocation.getContainerList(), headroom, null,
    currentContPreemption, Collections.singletonList(rr),
    allocation.getNMTokenList());
}
 
开发者ID:yncxcw,项目名称:big-c,代码行数:35,代码来源:FiCaSchedulerApp.java


示例7: allocate

import org.apache.hadoop.yarn.server.resourcemanager.scheduler.Allocation; //导入依赖的package包/类
@Override
public synchronized Allocation allocate(
    ApplicationAttemptId applicationAttemptId, List<ResourceRequest> ask,
    List<ContainerId> release, 
    List<String> blacklistAdditions, List<String> blacklistRemovals) {
  List<ResourceRequest> askCopy = new ArrayList<ResourceRequest>();
  for (ResourceRequest req : ask) {
    ResourceRequest reqCopy = ResourceRequest.newInstance(req
        .getPriority(), req.getResourceName(), req.getCapability(), req
        .getNumContainers(), req.getRelaxLocality());
    askCopy.add(reqCopy);
  }
  lastAsk = ask;
  lastRelease = release;
  lastBlacklistAdditions = blacklistAdditions;
  lastBlacklistRemovals = blacklistRemovals;
  return super.allocate(
      applicationAttemptId, askCopy, release, 
      blacklistAdditions, blacklistRemovals);
}
 
开发者ID:yncxcw,项目名称:big-c,代码行数:21,代码来源:TestRMContainerAllocator.java


示例8: getAllocation

import org.apache.hadoop.yarn.server.resourcemanager.scheduler.Allocation; //导入依赖的package包/类
/**
 * This method produces an Allocation that includes the current view
 * of the resources that will be allocated to and preempted from this
 * application.
 *
 * @param rc
 * @param clusterResource
 * @param minimumAllocation
 * @return an allocation
 */
public synchronized Allocation getAllocation(ResourceCalculator rc,
    Resource clusterResource, Resource minimumAllocation) {

  Set<ContainerId> currentContPreemption = Collections.unmodifiableSet(
      new HashSet<ContainerId>(containersToPreempt));
  containersToPreempt.clear();
  Resource tot = Resource.newInstance(0, 0);
  for(ContainerId c : currentContPreemption){
    Resources.addTo(tot,
        liveContainers.get(c).getContainer().getResource());
  }
  int numCont = (int) Math.ceil(
      Resources.divide(rc, clusterResource, tot, minimumAllocation));
  ResourceRequest rr = ResourceRequest.newInstance(
      Priority.UNDEFINED, ResourceRequest.ANY,
      minimumAllocation, numCont);
  ContainersAndNMTokensAllocation allocation =
      pullNewlyAllocatedContainersAndNMTokens();
  return new Allocation(allocation.getContainerList(), getHeadroom(), null,
    currentContPreemption, Collections.singletonList(rr),
    allocation.getNMTokenList());
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:33,代码来源:FiCaSchedulerApp.java


示例9: transition

import org.apache.hadoop.yarn.server.resourcemanager.scheduler.Allocation; //导入依赖的package包/类
@Override
public void 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);

  // Set the masterContainer
  appAttempt.setMasterContainer(amContainerAllocation.getContainers().get(
                                                                       0));
  appAttempt.getSubmissionContext().setResource(
      appAttempt.getMasterContainer().getResource());
  RMStateStore store = appAttempt.rmContext.getStateStore();
  appAttempt.storeAttempt(store);
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:17,代码来源:RMAppAttemptImpl.java


示例10: getAllocation

import org.apache.hadoop.yarn.server.resourcemanager.scheduler.Allocation; //导入依赖的package包/类
/**
 * This method produces an Allocation that includes the current view
 * of the resources that will be allocated to and preempted from this
 * application.
 *
 * @param rc
 * @param clusterResource
 * @param minimumAllocation
 * @return an allocation
 */
public synchronized Allocation getAllocation(ResourceCalculator rc,
    Resource clusterResource, Resource minimumAllocation) {

  Set<ContainerId> currentContPreemption = Collections.unmodifiableSet(
      new HashSet<ContainerId>(containersToPreempt));
  containersToPreempt.clear();
  Resource tot = Resource.newInstance(0, 0);
  for(ContainerId c : currentContPreemption){
    Resources.addTo(tot,
        liveContainers.get(c).getContainer().getResource());
  }
  int numCont = (int) Math.ceil(
      Resources.divide(rc, clusterResource, tot, minimumAllocation));
  ResourceRequest rr = ResourceRequest.newInstance(
      Priority.UNDEFINED, ResourceRequest.ANY,
      minimumAllocation, numCont);
  return new Allocation(pullNewlyAllocatedContainers(), getHeadroom(),
                        null, currentContPreemption,
                        Collections.singletonList(rr));
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:31,代码来源:FiCaSchedulerApp.java


示例11: allocate

import org.apache.hadoop.yarn.server.resourcemanager.scheduler.Allocation; //导入依赖的package包/类
@Override
public synchronized Allocation allocate(
    ApplicationAttemptId applicationAttemptId, List<ResourceRequest> ask,
    List<ContainerId> release, 
    List<String> blacklistAdditions, List<String> blacklistRemovals) {
  List<ResourceRequest> askCopy = new ArrayList<ResourceRequest>();
  for (ResourceRequest req : ask) {
    ResourceRequest reqCopy = ResourceRequest.newInstance(req
        .getPriority(), req.getResourceName(), req.getCapability(), req
        .getNumContainers(), req.getRelaxLocality());
    askCopy.add(reqCopy);
  }
  lastAsk = ask;
  return super.allocate(
      applicationAttemptId, askCopy, release, 
      blacklistAdditions, blacklistRemovals);
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:18,代码来源:TestRMContainerAllocator.java


示例12: allocate

import org.apache.hadoop.yarn.server.resourcemanager.scheduler.Allocation; //导入依赖的package包/类
@Override
public synchronized Allocation allocate(
    ApplicationAttemptId applicationAttemptId, List<ResourceRequest> ask,
    List<ContainerId> release, List<String> blacklistAdditions,
    List<String> blacklistRemovals,
    List<UpdateContainerRequest> increaseRequests,
    List<UpdateContainerRequest> decreaseRequests) {
  List<ResourceRequest> askCopy = new ArrayList<ResourceRequest>();
  for (ResourceRequest req : ask) {
    ResourceRequest reqCopy =
        ResourceRequest.newInstance(req.getPriority(),
            req.getResourceName(), req.getCapability(),
            req.getNumContainers(), req.getRelaxLocality());
    askCopy.add(reqCopy);
  }
  lastAsk = ask;
  lastRelease = release;
  lastIncrease = increaseRequests;
  lastDecrease = decreaseRequests;
  lastBlacklistAdditions = blacklistAdditions;
  lastBlacklistRemovals = blacklistRemovals;
  return super.allocate(applicationAttemptId, askCopy, release,
      blacklistAdditions, blacklistRemovals, increaseRequests,
      decreaseRequests);
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:26,代码来源:TestAMRMClientOnRMRestart.java


示例13: allocate

import org.apache.hadoop.yarn.server.resourcemanager.scheduler.Allocation; //导入依赖的package包/类
@Override
public synchronized Allocation allocate(
    ApplicationAttemptId applicationAttemptId, List<ResourceRequest> ask,
    List<ContainerId> release, 
    List<String> blacklistAdditions, List<String> blacklistRemovals) {
  List<ResourceRequest> askCopy = new ArrayList<ResourceRequest>();
  for (ResourceRequest req : ask) {
    ResourceRequest reqCopy = ResourceRequest.newInstance(req
        .getPriority(), req.getResourceName(), req.getCapability(), req
        .getNumContainers(), req.getRelaxLocality());
    askCopy.add(reqCopy);
  }
  lastAsk = ask;
  lastBlacklistAdditions = blacklistAdditions;
  lastBlacklistRemovals = blacklistRemovals;
  return super.allocate(
      applicationAttemptId, askCopy, release, 
      blacklistAdditions, blacklistRemovals);
}
 
开发者ID:chendave,项目名称:hadoop-TCP,代码行数:20,代码来源:TestRMContainerAllocator.java


示例14: transition

import org.apache.hadoop.yarn.server.resourcemanager.scheduler.Allocation; //导入依赖的package包/类
@Override
public RMAppAttemptState transition(RMAppAttemptImpl appAttempt,
    RMAppAttemptEvent event) {
  if (!appAttempt.submissionContext.getUnmanagedAM()) {
    // Request a container for the AM.
    ResourceRequest request =
        BuilderUtils.newResourceRequest(
            AM_CONTAINER_PRIORITY, ResourceRequest.ANY, appAttempt
                .getSubmissionContext().getResource(), 1);

    // SchedulerUtils.validateResourceRequests is not necessary because
    // AM resource has been checked when submission
    Allocation amContainerAllocation = appAttempt.scheduler.allocate(
        appAttempt.applicationAttemptId,
        Collections.singletonList(request), EMPTY_CONTAINER_RELEASE_LIST, null, null);
    if (amContainerAllocation != null
        && amContainerAllocation.getContainers() != null) {
      assert (amContainerAllocation.getContainers().size() == 0);
    }
    return RMAppAttemptState.SCHEDULED;
  } else {
    // save state and then go to LAUNCHED state
    appAttempt.storeAttempt();
    return RMAppAttemptState.LAUNCHED_UNMANAGED_SAVING;
  }
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre2,代码行数:27,代码来源:RMAppAttemptImpl.java


示例15: transition

import org.apache.hadoop.yarn.server.resourcemanager.scheduler.Allocation; //导入依赖的package包/类
@Override
public RMAppAttemptState transition(RMAppAttemptImpl appAttempt,
    RMAppAttemptEvent event) {
  ApplicationSubmissionContext subCtx = appAttempt.submissionContext;
  if (!subCtx.getUnmanagedAM()) {
    // Need reset #containers before create new attempt, because this request
    // will be passed to scheduler, and scheduler will deduct the number after
    // AM container allocated
    
    // Currently, following fields are all hard code,
    // TODO: change these fields when we want to support
    // priority/resource-name/relax-locality specification for AM containers
    // allocation.
    appAttempt.amReq.setNumContainers(1);
    appAttempt.amReq.setPriority(AM_CONTAINER_PRIORITY);
    appAttempt.amReq.setResourceName(ResourceRequest.ANY);
    appAttempt.amReq.setRelaxLocality(true);
    
    // AM resource has been checked when submission
    Allocation amContainerAllocation =
        appAttempt.scheduler.allocate(appAttempt.applicationAttemptId,
            Collections.singletonList(appAttempt.amReq),
            EMPTY_CONTAINER_RELEASE_LIST, null, null);
    if (amContainerAllocation != null
        && amContainerAllocation.getContainers() != null) {
      assert (amContainerAllocation.getContainers().size() == 0);
    }
    return RMAppAttemptState.SCHEDULED;
  } else {
    // save state and then go to LAUNCHED state
    appAttempt.storeAttempt();
    return RMAppAttemptState.LAUNCHED_UNMANAGED_SAVING;
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:35,代码来源:RMAppAttemptImpl.java


示例16: getResources

import org.apache.hadoop.yarn.server.resourcemanager.scheduler.Allocation; //导入依赖的package包/类
public synchronized List<Container> getResources() throws IOException {
  if(LOG.isDebugEnabled()) {
    LOG.debug("getResources begin:" + " application=" + applicationId
      + " #ask=" + ask.size());

    for (ResourceRequest request : ask) {
      LOG.debug("getResources:" + " application=" + applicationId
        + " ask-request=" + request);
    }
  }
  
  // Get resources from the ResourceManager
  Allocation allocation = resourceManager.getResourceScheduler().allocate(
      applicationAttemptId, new ArrayList<ResourceRequest>(ask),
      new ArrayList<ContainerId>(), null, null);
  System.out.println("-=======" + applicationAttemptId);
  System.out.println("----------" + resourceManager.getRMContext().getRMApps()
      .get(applicationId).getRMAppAttempt(applicationAttemptId));
  List<Container> containers = allocation.getContainers();

  // Clear state for next interaction with ResourceManager
  ask.clear();
  
  if(LOG.isDebugEnabled()) {
    LOG.debug("getResources() for " + applicationId + ":"
      + " ask=" + ask.size() + " recieved=" + containers.size());
  }
  
  return containers;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:31,代码来源:Application.java


示例17: allocateApplicationAttempt

import org.apache.hadoop.yarn.server.resourcemanager.scheduler.Allocation; //导入依赖的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


示例18: allocate

import org.apache.hadoop.yarn.server.resourcemanager.scheduler.Allocation; //导入依赖的package包/类
@Override
public Allocation allocate(ApplicationAttemptId attemptId,
                           List<ResourceRequest> resourceRequests,
                           List<ContainerId> containerIds,
                           List<String> strings, List<String> strings2) {
  if (metricsON) {
    final Timer.Context context = schedulerAllocateTimer.time();
    Allocation allocation = null;
    try {
      allocation = scheduler.allocate(attemptId, resourceRequests,
              containerIds, strings, strings2);
      return allocation;
    } finally {
      context.stop();
      schedulerAllocateCounter.inc();
      try {
        updateQueueWithAllocateRequest(allocation, attemptId,
                resourceRequests, containerIds);
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
  } else {
    return scheduler.allocate(attemptId,
            resourceRequests, containerIds, strings, strings2);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:28,代码来源:ResourceSchedulerWrapper.java


示例19: getAllocation

import org.apache.hadoop.yarn.server.resourcemanager.scheduler.Allocation; //导入依赖的package包/类
/**
 * This method produces an Allocation that includes the current view
 * of the resources that will be allocated to and preempted from this
 * application.
 *
 * @param rc
 * @param clusterResource
 * @param minimumAllocation
 * @return an allocation
 */
public synchronized Allocation getAllocation(ResourceCalculator rc,
    Resource clusterResource, Resource minimumAllocation) {

  Set<ContainerId> currentContPreemption = Collections.unmodifiableSet(
      new HashSet<ContainerId>(containersToPreempt));
  containersToPreempt.clear();
  Resource tot = Resource.newInstance(0, 0);
  for(ContainerId c : currentContPreemption){
    Resources.addTo(tot,
        liveContainers.get(c).getContainer().getResource());
  }
  int numCont = (int) Math.ceil(
      Resources.divide(rc, clusterResource, tot, minimumAllocation));
  ResourceRequest rr = ResourceRequest.newInstance(
      Priority.UNDEFINED, ResourceRequest.ANY,
      minimumAllocation, numCont);
  List<Container> newlyAllocatedContainers = pullNewlyAllocatedContainers();
  List<Container> newlyIncreasedContainers = pullNewlyIncreasedContainers();
  List<Container> newlyDecreasedContainers = pullNewlyDecreasedContainers();
  List<NMToken> updatedNMTokens = pullUpdatedNMTokens();
  Resource headroom = getHeadroom();
  setApplicationHeadroomForMetrics(headroom);
  return new Allocation(newlyAllocatedContainers, headroom, null,
      currentContPreemption, Collections.singletonList(rr), updatedNMTokens,
      newlyIncreasedContainers, newlyDecreasedContainers);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:37,代码来源:FiCaSchedulerApp.java


示例20: getResources

import org.apache.hadoop.yarn.server.resourcemanager.scheduler.Allocation; //导入依赖的package包/类
public synchronized List<Container> getResources() throws IOException {
  if(LOG.isDebugEnabled()) {
    LOG.debug("getResources begin:" + " application=" + applicationId
      + " #ask=" + ask.size());

    for (ResourceRequest request : ask) {
      LOG.debug("getResources:" + " application=" + applicationId
        + " ask-request=" + request);
    }
  }
  
  // Get resources from the ResourceManager
  Allocation allocation = resourceManager.getResourceScheduler().allocate(
      applicationAttemptId, new ArrayList<ResourceRequest>(ask),
      new ArrayList<ContainerId>(), null, null, null, null);
  System.out.println("-=======" + applicationAttemptId);
  System.out.println("----------" + resourceManager.getRMContext().getRMApps()
      .get(applicationId).getRMAppAttempt(applicationAttemptId));
  List<Container> containers = allocation.getContainers();

  // Clear state for next interaction with ResourceManager
  ask.clear();
  
  if(LOG.isDebugEnabled()) {
    LOG.debug("getResources() for " + applicationId + ":"
      + " ask=" + ask.size() + " recieved=" + containers.size());
  }
  
  return containers;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:31,代码来源:Application.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TextMergeViewer类代码示例发布时间:2022-05-22
下一篇:
Java EntityPath类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap