List of usage examples for org.apache.hadoop.yarn.server.resourcemanager.rmnode RMNode getTotalCapability
public Resource getTotalCapability();
From source file:org.apache.myriad.scheduler.fgs.NMHeartBeatHandler.java
License:Apache License
@Override public void beforeRMNodeEventHandled(RMNodeEvent event, RMContext context) { switch (event.getType()) { case STARTED: // Since the RMNode was just started, it should not have a non-zero capacity RMNode rmNode = context.getRMNodes().get(event.getNodeId()); if (isNonZeroCapacityNode(rmNode)) { Resource totalCapability = rmNode.getTotalCapability(); logger.warn(/*from w w w .ja va 2 s. co m*/ "FineGrainedScaling feature got invoked for a NM with non-zero capacity. Host: {}, Mem: {}, CPU: {}. Setting the " + "NM's capacity to (0G,0CPU)", rmNode.getHostName(), totalCapability.getMemory(), totalCapability.getVirtualCores()); totalCapability.setMemory(0); totalCapability.setVirtualCores(0); } break; case STATUS_UPDATE: handleStatusUpdate(event, context); break; default: break; } }
From source file:org.apache.myriad.scheduler.fgs.NMHeartBeatHandler.java
License:Apache License
@VisibleForTesting protected boolean isNonZeroCapacityNode(RMNode node) { Resource resource = node.getTotalCapability(); return (resource.getMemory() != 0 || resource.getVirtualCores() != 0); }
From source file:org.apache.myriad.scheduler.fgs.NMHeartBeatHandlerTest.java
License:Apache License
private void resetNodeTotalCapability(RMNode node, int cpuCores, int memory) { node.getTotalCapability().setVirtualCores(cpuCores); node.getTotalCapability().setMemory(memory); }
From source file:org.apache.myriad.scheduler.fgs.YarnNodeCapacityManager.java
License:Apache License
/** * Increments the capacity for the specified RMNode * // w w w . ja va 2 s . c om * @param rmNode * @param removedCapacity */ public void incrementNodeCapacity(RMNode rmNode, Resource addedCapacity) { setNodeCapacity(rmNode, Resources.add(rmNode.getTotalCapability(), addedCapacity)); }
From source file:org.apache.myriad.scheduler.fgs.YarnNodeCapacityManager.java
License:Apache License
/** * Decrements the capacity for the specified RMNode * /*from w w w . j a v a 2 s .c o m*/ * @param rmNode * @param removedCapacity */ public void decrementNodeCapacity(RMNode rmNode, Resource removedCapacity) { setNodeCapacity(rmNode, Resources.subtract(rmNode.getTotalCapability(), removedCapacity)); }
From source file:org.apache.myriad.scheduler.fgs.YarnNodeCapacityManager.java
License:Apache License
/** * 1. Updates {@link RMNode#getTotalCapability()} with newCapacity. * 2. Sends out a {@link NodeResourceUpdateSchedulerEvent} that's handled by YARN's scheduler. * The scheduler updates the corresponding {@link SchedulerNode} with the newCapacity. * * @param rmNode/*from ww w . ja va 2s .co m*/ * @param newCapacity */ @SuppressWarnings("unchecked") 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(); } }