public void setNodeCapacity()

in myriad-scheduler/src/main/java/org/apache/myriad/scheduler/fgs/YarnNodeCapacityManager.java [277:308]


  public void setNodeCapacity(RMNode rmNode, Resource newCapacity) {
    //NOOP prevent YARN warning changing to same size
    if ((Resources.equals(rmNode.getTotalCapability(), newCapacity))) {
      return;
    }
    if (yarnScheduler.getSchedulerNode(rmNode.getNodeID()) == null) {
      LOGGER.info("Yarn Scheduler doesn't have node {}, probably UNHEALTHY", rmNode.getNodeID());
      return;
    }
    yarnSchedulerLock.lock();
    try {
      if (newCapacity.getMemory() < 0 || newCapacity.getVirtualCores() < 0) {
        Resource zeroed = ResourceUtils.componentwiseMax(ZERO_RESOURCE, newCapacity);
        rmNode.getTotalCapability().setMemory(zeroed.getMemory());
        rmNode.getTotalCapability().setVirtualCores(zeroed.getVirtualCores());
        LOGGER.warn("Asked to set Node {} to a value less than zero!  Had {}, setting to {}.",
            rmNode.getHttpAddress(), rmNode.getTotalCapability().toString(), zeroed.toString());
      } else {
        rmNode.getTotalCapability().setMemory(newCapacity.getMemory());
        rmNode.getTotalCapability().setVirtualCores(newCapacity.getVirtualCores());
        if (LOGGER.isInfoEnabled()) {
          LOGGER.info("Setting capacity for node {} to {}", rmNode.getHostName(), newCapacity);
        }
      }
      // updates the scheduler with the new capacity for the NM.
      // the event is handled by the scheduler asynchronously
      rmContext.getDispatcher().getEventHandler().handle(new NodeResourceUpdateSchedulerEvent(rmNode, ResourceOption.newInstance(
          rmNode.getTotalCapability(), RMNode.OVER_COMMIT_TIMEOUT_MILLIS_DEFAULT)));
    } finally {
      yarnSchedulerLock.unlock();
    }
  }