Java Code Examples for org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager

The following examples show how to use org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: hadoop   Source File: RMWebServices.java    License: Apache License 2.0 6 votes vote down vote up
@GET
@Path("/scheduler")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public SchedulerTypeInfo getSchedulerInfo() {
  init();
  ResourceScheduler rs = rm.getResourceScheduler();
  SchedulerInfo sinfo;
  if (rs instanceof CapacityScheduler) {
    CapacityScheduler cs = (CapacityScheduler) rs;
    CSQueue root = cs.getRootQueue();
    sinfo =
        new CapacitySchedulerInfo(root, cs, new NodeLabel(
            RMNodeLabelsManager.NO_LABEL));
  } else if (rs instanceof FairScheduler) {
    FairScheduler fs = (FairScheduler) rs;
    sinfo = new FairSchedulerInfo(fs);
  } else if (rs instanceof FifoScheduler) {
    sinfo = new FifoSchedulerInfo(this.rm);
  } else {
    throw new NotFoundException("Unknown scheduler configured");
  }
  return new SchedulerTypeInfo(sinfo);
}
 
Example 2
Source Project: hadoop   Source File: SchedulerUtils.java    License: Apache License 2.0 6 votes vote down vote up
public static boolean checkQueueAccessToNode(Set<String> queueLabels,
    Set<String> nodeLabels) {
  // if queue's label is *, it can access any node
  if (queueLabels != null && queueLabels.contains(RMNodeLabelsManager.ANY)) {
    return true;
  }
  // any queue can access to a node without label
  if (nodeLabels == null || nodeLabels.isEmpty()) {
    return true;
  }
  // a queue can access to a node only if it contains any label of the node
  if (queueLabels != null
      && Sets.intersection(queueLabels, nodeLabels).size() > 0) {
    return true;
  }
  // sorry, you cannot access
  return false;
}
 
Example 3
Source Project: hadoop   Source File: SchedulerUtils.java    License: Apache License 2.0 6 votes vote down vote up
public static void checkIfLabelInClusterNodeLabels(RMNodeLabelsManager mgr,
    Set<String> labels) throws IOException {
  if (mgr == null) {
    if (labels != null && !labels.isEmpty()) {
      throw new IOException("NodeLabelManager is null, please check");
    }
    return;
  }

  if (labels != null) {
    for (String label : labels) {
      if (!label.equals(RMNodeLabelsManager.ANY)
          && !mgr.containsNodeLabel(label)) {
        throw new IOException("NodeLabelManager doesn't include label = "
            + label + ", please check.");
      }
    }
  }
}
 
Example 4
Source Project: hadoop   Source File: AbstractCSQueue.java    License: Apache License 2.0 6 votes vote down vote up
synchronized void allocateResource(Resource clusterResource, 
    Resource resource, Set<String> nodeLabels) {
  
  // Update usedResources by labels
  if (nodeLabels == null || nodeLabels.isEmpty()) {
    queueUsage.incUsed(resource);
  } else {
    Set<String> anls = (accessibleLabels.contains(RMNodeLabelsManager.ANY))
        ? labelManager.getClusterNodeLabels() : accessibleLabels;
    for (String label : Sets.intersection(anls, nodeLabels)) {
      queueUsage.incUsed(label, resource);
    }
  }

  ++numContainers;
  if (null == nodeLabels || nodeLabels.isEmpty()) {
    CSQueueUtils.updateQueueStatistics(resourceCalculator, this, getParent(),
        labelManager.getResourceByLabel(RMNodeLabelsManager.NO_LABEL, clusterResource), minimumAllocation);
  }
}
 
Example 5
Source Project: hadoop   Source File: AbstractCSQueue.java    License: Apache License 2.0 6 votes vote down vote up
private Resource getCurrentLimitResource(String nodeLabel,
    Resource clusterResource, ResourceLimits currentResourceLimits) {
  /*
   * Current limit resource: For labeled resource: limit = queue-max-resource
   * (TODO, this part need update when we support labeled-limit) For
   * non-labeled resource: limit = min(queue-max-resource,
   * limit-set-by-parent)
   */
  Resource queueMaxResource =
      Resources.multiplyAndNormalizeDown(resourceCalculator,
          labelManager.getResourceByLabel(nodeLabel, clusterResource),
          queueCapacities.getAbsoluteMaximumCapacity(nodeLabel), minimumAllocation);
  if (nodeLabel.equals(RMNodeLabelsManager.NO_LABEL)) {
    return Resources.min(resourceCalculator, clusterResource,
        queueMaxResource, currentResourceLimits.getLimit());
  }
  return queueMaxResource;
}
 
Example 6
Source Project: hadoop   Source File: LeafQueue.java    License: Apache License 2.0 6 votes vote down vote up
private void updateCurrentResourceLimits(
    ResourceLimits currentResourceLimits, Resource clusterResource) {
  // TODO: need consider non-empty node labels when resource limits supports
  // node labels
  // Even if ParentQueue will set limits respect child's max queue capacity,
  // but when allocating reserved container, CapacityScheduler doesn't do
  // this. So need cap limits by queue's max capacity here.
  this.cachedResourceLimitsForHeadroom = new ResourceLimits(currentResourceLimits.getLimit());
  Resource queueMaxResource =
      Resources.multiplyAndNormalizeDown(resourceCalculator, labelManager
          .getResourceByLabel(RMNodeLabelsManager.NO_LABEL, clusterResource),
          queueCapacities
              .getAbsoluteMaximumCapacity(RMNodeLabelsManager.NO_LABEL),
          minimumAllocation);
  this.cachedResourceLimitsForHeadroom.setLimit(Resources.min(resourceCalculator,
      clusterResource, queueMaxResource, currentResourceLimits.getLimit()));
}
 
Example 7
Source Project: big-c   Source File: SchedulerUtils.java    License: Apache License 2.0 6 votes vote down vote up
private static void normalizeNodeLabelExpressionInRequest(
    ResourceRequest resReq, QueueInfo queueInfo) {

  String labelExp = resReq.getNodeLabelExpression();

  // if queue has default label expression, and RR doesn't have, use the
  // default label expression of queue
  if (labelExp == null && queueInfo != null && ResourceRequest.ANY
      .equals(resReq.getResourceName())) {
    labelExp = queueInfo.getDefaultNodeLabelExpression();
  }

  // If labelExp still equals to null, set it to be NO_LABEL
  if (labelExp == null) {
    labelExp = RMNodeLabelsManager.NO_LABEL;
  }
  resReq.setNodeLabelExpression(labelExp);
}
 
Example 8
Source Project: hadoop   Source File: TestQueueParsing.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testQueueParsingWhenLabelsNotExist() throws IOException {
  YarnConfiguration conf = new YarnConfiguration();
  CapacitySchedulerConfiguration csConf =
      new CapacitySchedulerConfiguration(conf);
  setupQueueConfigurationWithLabels(csConf);

  CapacityScheduler capacityScheduler = new CapacityScheduler();
  RMContextImpl rmContext =
      new RMContextImpl(null, null, null, null, null, null,
          new RMContainerTokenSecretManager(csConf),
          new NMTokenSecretManagerInRM(csConf),
          new ClientToAMTokenSecretManagerInRM(), null);
  
  RMNodeLabelsManager nodeLabelsManager = new NullRMNodeLabelsManager();
  nodeLabelsManager.init(conf);
  nodeLabelsManager.start();
  
  rmContext.setNodeLabelManager(nodeLabelsManager);
  capacityScheduler.setConf(csConf);
  capacityScheduler.setRMContext(rmContext);
  capacityScheduler.init(csConf);
  capacityScheduler.start();
  ServiceOperations.stopQuietly(capacityScheduler);
  ServiceOperations.stopQuietly(nodeLabelsManager);
}
 
Example 9
Source Project: big-c   Source File: SchedulerUtils.java    License: Apache License 2.0 6 votes vote down vote up
public static void checkIfLabelInClusterNodeLabels(RMNodeLabelsManager mgr,
    Set<String> labels) throws IOException {
  if (mgr == null) {
    if (labels != null && !labels.isEmpty()) {
      throw new IOException("NodeLabelManager is null, please check");
    }
    return;
  }

  if (labels != null) {
    for (String label : labels) {
      if (!label.equals(RMNodeLabelsManager.ANY)
          && !mgr.containsNodeLabel(label)) {
        throw new IOException("NodeLabelManager doesn't include label = "
            + label + ", please check.");
      }
    }
  }
}
 
Example 10
Source Project: big-c   Source File: LeafQueue.java    License: Apache License 2.0 6 votes vote down vote up
private void updateCurrentResourceLimits(
    ResourceLimits currentResourceLimits, Resource clusterResource) {
  // TODO: need consider non-empty node labels when resource limits supports
  // node labels
  // Even if ParentQueue will set limits respect child's max queue capacity,
  // but when allocating reserved container, CapacityScheduler doesn't do
  // this. So need cap limits by queue's max capacity here.
  this.cachedResourceLimitsForHeadroom = new ResourceLimits(currentResourceLimits.getLimit());
  Resource queueMaxResource =
      Resources.multiplyAndNormalizeDown(resourceCalculator, labelManager
          .getResourceByLabel(RMNodeLabelsManager.NO_LABEL, clusterResource),
          queueCapacities
              .getAbsoluteMaximumCapacity(RMNodeLabelsManager.NO_LABEL),
          minimumAllocation);
  this.cachedResourceLimitsForHeadroom.setLimit(Resources.min(resourceCalculator,
      clusterResource, queueMaxResource, currentResourceLimits.getLimit()));
}
 
Example 11
Source Project: big-c   Source File: TestCapacityScheduler.java    License: Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
  resourceManager = new ResourceManager() {
    @Override
    protected RMNodeLabelsManager createNodeLabelManager() {
      RMNodeLabelsManager mgr = new NullRMNodeLabelsManager();
      mgr.init(getConfig());
      return mgr;
    }
  };
  CapacitySchedulerConfiguration csConf 
     = new CapacitySchedulerConfiguration();
  setupQueueConfiguration(csConf);
  YarnConfiguration conf = new YarnConfiguration(csConf);
  conf.setClass(YarnConfiguration.RM_SCHEDULER, 
      CapacityScheduler.class, ResourceScheduler.class);
  resourceManager.init(conf);
  resourceManager.getRMContext().getContainerTokenSecretManager().rollMasterKey();
  resourceManager.getRMContext().getNMTokenSecretManager().rollMasterKey();
  ((AsyncDispatcher)resourceManager.getRMContext().getDispatcher()).start();
  mockContext = mock(RMContext.class);
  when(mockContext.getConfigurationProvider()).thenReturn(
      new LocalConfigurationProvider());
}
 
Example 12
Source Project: big-c   Source File: TestQueueParsing.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testQueueParsingWhenLabelsNotExist() throws IOException {
  YarnConfiguration conf = new YarnConfiguration();
  CapacitySchedulerConfiguration csConf =
      new CapacitySchedulerConfiguration(conf);
  setupQueueConfigurationWithLabels(csConf);

  CapacityScheduler capacityScheduler = new CapacityScheduler();
  RMContextImpl rmContext =
      new RMContextImpl(null, null, null, null, null, null,
          new RMContainerTokenSecretManager(csConf),
          new NMTokenSecretManagerInRM(csConf),
          new ClientToAMTokenSecretManagerInRM(), null);
  
  RMNodeLabelsManager nodeLabelsManager = new NullRMNodeLabelsManager();
  nodeLabelsManager.init(conf);
  nodeLabelsManager.start();
  
  rmContext.setNodeLabelManager(nodeLabelsManager);
  capacityScheduler.setConf(csConf);
  capacityScheduler.setRMContext(rmContext);
  capacityScheduler.init(csConf);
  capacityScheduler.start();
  ServiceOperations.stopQuietly(capacityScheduler);
  ServiceOperations.stopQuietly(nodeLabelsManager);
}
 
Example 13
Source Project: hadoop   Source File: CapacitySchedulerPage.java    License: Apache License 2.0 5 votes vote down vote up
@Inject QueuesBlock(ResourceManager rm, CSQInfo info) {
  cs = (CapacityScheduler) rm.getResourceScheduler();
  csqinfo = info;
  RMNodeLabelsManager nodeLabelManager =
      rm.getRMContext().getNodeLabelManager();
  nodeLabelsInfo = nodeLabelManager.pullRMNodeLabelsInfo();      
}
 
Example 14
Source Project: hadoop   Source File: ClientRMService.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public GetNodesToLabelsResponse getNodeToLabels(
    GetNodesToLabelsRequest request) throws YarnException, IOException {
  RMNodeLabelsManager labelsMgr = rmContext.getNodeLabelManager();
  GetNodesToLabelsResponse response =
      GetNodesToLabelsResponse.newInstance(labelsMgr.getNodeLabels());
  return response;
}
 
Example 15
Source Project: hadoop   Source File: ClientRMService.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public GetClusterNodeLabelsResponse getClusterNodeLabels(
    GetClusterNodeLabelsRequest request) throws YarnException, IOException {
  RMNodeLabelsManager labelsMgr = rmContext.getNodeLabelManager();
  GetClusterNodeLabelsResponse response =
      GetClusterNodeLabelsResponse.newInstance(
          labelsMgr.getClusterNodeLabels());
  return response;
}
 
Example 16
Source Project: hadoop   Source File: SchedulerUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Check queue label expression, check if node label in queue's
 * node-label-expression existed in clusterNodeLabels if rmContext != null
 */
public static boolean checkQueueLabelExpression(Set<String> queueLabels,
    String labelExpression, RMContext rmContext) {
  // if label expression is empty, we can allocate container on any node
  if (labelExpression == null) {
    return true;
  }
  for (String str : labelExpression.split("&&")) {
    str = str.trim();
    if (!str.trim().isEmpty()) {
      // check queue label
      if (queueLabels == null) {
        return false; 
      } else {
        if (!queueLabels.contains(str)
            && !queueLabels.contains(RMNodeLabelsManager.ANY)) {
          return false;
        }
      }
      
      // check node label manager contains this label
      if (null != rmContext) {
        RMNodeLabelsManager nlm = rmContext.getNodeLabelManager();
        if (nlm != null && !nlm.containsNodeLabel(str)) {
          return false;
        }
      }
    }
  }
  return true;
}
 
Example 17
Source Project: hadoop   Source File: SchedulerNode.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get partition of which the node belongs to, if node-labels of this node is
 * empty or null, it belongs to NO_LABEL partition. And since we only support
 * one partition for each node (YARN-2694), first label will be its partition.
 */
public String getPartition() {
  if (this.labels == null || this.labels.isEmpty()) {
    return RMNodeLabelsManager.NO_LABEL; 
  } else {
    return this.labels.iterator().next();
  }
}
 
Example 18
Source Project: hadoop   Source File: QueueCapacities.java    License: Apache License 2.0 5 votes vote down vote up
public float getCapacity(String label) {
  if (StringUtils.equals(label, RMNodeLabelsManager.NO_LABEL) && isRoot) {
    return 1f;
  }
  
  return _get(label, CapacityType.CAP);
}
 
Example 19
Source Project: big-c   Source File: ParentQueue.java    License: Apache License 2.0 5 votes vote down vote up
private ResourceLimits getResourceLimitsOfChild(CSQueue child,
     Resource clusterResource, ResourceLimits parentLimits) {
   // Set resource-limit of a given child, child.limit =
   // min(my.limit - my.used + child.used, child.max)//why ?
// my.limit-my-used+child.used 等于在父队列中除去别的子对列所用资源后剩下的资源,有可能别的子对列所用资源超过了他们自身的限制

   // Parent available resource = parent-limit - parent-used-resource
   Resource parentMaxAvailableResource =
       Resources.subtract(parentLimits.getLimit(), getUsedResources());
   
   // Child's limit = parent-available-resource + child-used
   Resource childLimit =
       Resources.add(parentMaxAvailableResource, child.getUsedResources());

   // Get child's max resource
   Resource childConfiguredMaxResource =
       Resources.multiplyAndNormalizeDown(resourceCalculator, labelManager
           .getResourceByLabel(RMNodeLabelsManager.NO_LABEL, clusterResource),
           child.getAbsoluteMaximumCapacity(), minimumAllocation);

   // Child's limit should be capped by child configured max resource
   childLimit =
       Resources.min(resourceCalculator, clusterResource, childLimit,
           childConfiguredMaxResource);

   // Normalize before return
   childLimit =
       Resources.roundDown(resourceCalculator, childLimit, minimumAllocation);

   return new ResourceLimits(childLimit);
 }
 
Example 20
Source Project: big-c   Source File: ClientRMService.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public GetClusterNodeLabelsResponse getClusterNodeLabels(
    GetClusterNodeLabelsRequest request) throws YarnException, IOException {
  RMNodeLabelsManager labelsMgr = rmContext.getNodeLabelManager();
  GetClusterNodeLabelsResponse response =
      GetClusterNodeLabelsResponse.newInstance(
          labelsMgr.getClusterNodeLabels());
  return response;
}
 
Example 21
Source Project: hadoop   Source File: CapacitySchedulerConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
public Set<String> getAccessibleNodeLabels(String queue) {
  String accessibleLabelStr =
      get(getQueuePrefix(queue) + ACCESSIBLE_NODE_LABELS);

  // When accessible-label is null, 
  if (accessibleLabelStr == null) {
    // Only return null when queue is not ROOT
    if (!queue.equals(ROOT)) {
      return null;
    }
  } else {
    // print a warning when accessibleNodeLabel specified in config and queue
    // is ROOT
    if (queue.equals(ROOT)) {
      LOG.warn("Accessible node labels for root queue will be ignored,"
          + " it will be automatically set to \"*\".");
    }
  }

  // always return ANY for queue root
  if (queue.equals(ROOT)) {
    return ImmutableSet.of(RMNodeLabelsManager.ANY);
  }

  // In other cases, split the accessibleLabelStr by ","
  Set<String> set = new HashSet<String>();
  for (String str : accessibleLabelStr.split(",")) {
    if (!str.trim().isEmpty()) {
      set.add(str.trim());
    }
  }
  
  // if labels contains "*", only keep ANY behind
  if (set.contains(RMNodeLabelsManager.ANY)) {
    set.clear();
    set.add(RMNodeLabelsManager.ANY);
  }
  return Collections.unmodifiableSet(set);
}
 
Example 22
Source Project: hadoop   Source File: CapacitySchedulerConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get configured node labels in a given queuePath
 */
public Set<String> getConfiguredNodeLabels(String queuePath) {
  Set<String> configuredNodeLabels = new HashSet<String>();
  Entry<String, String> e = null;
  
  Iterator<Entry<String, String>> iter = iterator();
  while (iter.hasNext()) {
    e = iter.next();
    String key = e.getKey();

    if (key.startsWith(getQueuePrefix(queuePath) + ACCESSIBLE_NODE_LABELS
        + DOT)) {
      // Find <label-name> in
      // <queue-path>.accessible-node-labels.<label-name>.property
      int labelStartIdx =
          key.indexOf(ACCESSIBLE_NODE_LABELS)
              + ACCESSIBLE_NODE_LABELS.length() + 1;
      int labelEndIndx = key.indexOf('.', labelStartIdx);
      String labelName = key.substring(labelStartIdx, labelEndIndx);
      configuredNodeLabels.add(labelName);
    }
  }
  
  // always add NO_LABEL
  configuredNodeLabels.add(RMNodeLabelsManager.NO_LABEL);
  
  return configuredNodeLabels;
}
 
Example 23
Source Project: big-c   Source File: CapacitySchedulerConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
public Set<String> getAccessibleNodeLabels(String queue) {
  String accessibleLabelStr =
      get(getQueuePrefix(queue) + ACCESSIBLE_NODE_LABELS);

  // When accessible-label is null, 
  if (accessibleLabelStr == null) {
    // Only return null when queue is not ROOT
    if (!queue.equals(ROOT)) {
      return null;
    }
  } else {
    // print a warning when accessibleNodeLabel specified in config and queue
    // is ROOT
    if (queue.equals(ROOT)) {
      LOG.warn("Accessible node labels for root queue will be ignored,"
          + " it will be automatically set to \"*\".");
    }
  }

  // always return ANY for queue root
  if (queue.equals(ROOT)) {
    return ImmutableSet.of(RMNodeLabelsManager.ANY);
  }

  // In other cases, split the accessibleLabelStr by ","
  Set<String> set = new HashSet<String>();
  for (String str : accessibleLabelStr.split(",")) {
    if (!str.trim().isEmpty()) {
      set.add(str.trim());
    }
  }
  
  // if labels contains "*", only keep ANY behind
  if (set.contains(RMNodeLabelsManager.ANY)) {
    set.clear();
    set.add(RMNodeLabelsManager.ANY);
  }
  return Collections.unmodifiableSet(set);
}
 
Example 24
Source Project: hadoop   Source File: LeafQueue.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Gets the labels which are accessible by this queue. If ANY label can be
 * accessed, put all labels in the set.
 * @return accessiglbe node labels
 */
protected final Set<String> getAccessibleLabelSet() {
  Set<String> nodeLabels = new HashSet<String>();
  if (this.getAccessibleNodeLabels().contains(RMNodeLabelsManager.ANY)) {
    nodeLabels.addAll(labelManager.getClusterNodeLabels());
  } else {
    nodeLabels.addAll(this.getAccessibleNodeLabels());
  }
  nodeLabels.add(RMNodeLabelsManager.NO_LABEL);
  return nodeLabels;
}
 
Example 25
Source Project: big-c   Source File: TestQueueParsing.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testQueueParsingWhenLabelsInheritedNotExistedInNodeLabelManager()
    throws IOException {
  YarnConfiguration conf = new YarnConfiguration();
  CapacitySchedulerConfiguration csConf =
      new CapacitySchedulerConfiguration(conf);
  setupQueueConfigurationWithLabelsInherit(csConf);

  CapacityScheduler capacityScheduler = new CapacityScheduler();
  RMContextImpl rmContext =
      new RMContextImpl(null, null, null, null, null, null,
          new RMContainerTokenSecretManager(csConf),
          new NMTokenSecretManagerInRM(csConf),
          new ClientToAMTokenSecretManagerInRM(), null);
  
  RMNodeLabelsManager nodeLabelsManager = new NullRMNodeLabelsManager();
  nodeLabelsManager.init(conf);
  nodeLabelsManager.start();
  
  rmContext.setNodeLabelManager(nodeLabelsManager);
  capacityScheduler.setConf(csConf);
  capacityScheduler.setRMContext(rmContext);
  capacityScheduler.init(csConf);
  capacityScheduler.start();
  ServiceOperations.stopQuietly(capacityScheduler);
  ServiceOperations.stopQuietly(nodeLabelsManager);
}
 
Example 26
/**
 * This method returns all non labeled resources.
 * 
 * @param clusterResources
 * @return Resources
 */
private Resource getNonLabeledResources(Resource clusterResources) {
  RMContext rmcontext = scheduler.getRMContext();
  RMNodeLabelsManager lm = rmcontext.getNodeLabelManager();
  Resource res = lm.getResourceByLabel(RMNodeLabelsManager.NO_LABEL,
      clusterResources);
  return res == null ? clusterResources : res;
}
 
Example 27
Source Project: hadoop   Source File: MockRM.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected RMNodeLabelsManager createNodeLabelManager()
    throws InstantiationException, IllegalAccessException {
  if (useNullRMNodeLabelsManager) {
    RMNodeLabelsManager mgr = new NullRMNodeLabelsManager();
    mgr.init(getConfig());
    return mgr;
  } else {
    return super.createNodeLabelManager();
  }
}
 
Example 28
Source Project: hadoop   Source File: TestSchedulerUtils.java    License: Apache License 2.0 5 votes vote down vote up
private static RMContext getMockRMContext() {
  RMContext rmContext = mock(RMContext.class);
  RMNodeLabelsManager nlm = new NullRMNodeLabelsManager();
  nlm.init(new Configuration(false));
  when(rmContext.getNodeLabelManager()).thenReturn(nlm);
  return rmContext;
}
 
Example 29
Source Project: hadoop   Source File: FairSchedulerTestBase.java    License: Apache License 2.0 5 votes vote down vote up
protected ResourceRequest createResourceRequest(
    int memory, int vcores, int gcores, String host, int priority, int numContainers,
    boolean relaxLocality) {
  ResourceRequest request = recordFactory.newRecordInstance(ResourceRequest.class);
  request.setCapability(BuilderUtils.newResource(memory, vcores, gcores));
  request.setResourceName(host);
  request.setNumContainers(numContainers);
  Priority prio = recordFactory.newRecordInstance(Priority.class);
  prio.setPriority(priority);
  request.setPriority(prio);
  request.setRelaxLocality(relaxLocality);
  request.setNodeLabelExpression(RMNodeLabelsManager.NO_LABEL);
  return request;
}
 
Example 30
Source Project: big-c   Source File: TestSchedulerUtils.java    License: Apache License 2.0 5 votes vote down vote up
private static RMContext getMockRMContext() {
  RMContext rmContext = mock(RMContext.class);
  RMNodeLabelsManager nlm = new NullRMNodeLabelsManager();
  nlm.init(new Configuration(false));
  when(rmContext.getNodeLabelManager()).thenReturn(nlm);
  return rmContext;
}