in myriad-scheduler/src/main/java/org/apache/myriad/scheduler/fgs/NMHeartBeatHandler.java [123:153]
protected void handleStatusUpdate(RMNodeEvent event, RMContext context) {
if (!(event instanceof RMNodeStatusEvent)) {
logger.error("{} not an instance of {}", event.getClass().getName(), RMNodeStatusEvent.class.getName());
return;
}
RMNodeStatusEvent statusEvent = (RMNodeStatusEvent) event;
RMNode rmNode = context.getRMNodes().get(event.getNodeId());
String hostName = rmNode.getNodeID().getHost();
Node host = nodeStore.getNode(hostName);
if (host != null) {
host.snapshotRunningContainers();
}
/*
* Set the new node capacity which is the sum of the current node resources plus those offered by Mesos.
* If the sum is greater than the max capacity of the node, reject the offer.
*/
Resource offeredResources = getNewResourcesOfferedByMesos(hostName);
Resource currentResources = getResourcesUnderUse(statusEvent);
if (offerWithinResourceLimits(currentResources, offeredResources)) {
yarnNodeCapacityMgr.setNodeCapacity(rmNode, Resources.add(currentResources, offeredResources));
logger.info("Updated resources for {} with {} cores and {} memory", rmNode.getNode().getName(),
offeredResources.getVirtualCores(), offeredResources.getMemory());
} else {
logger.info("Did not update {} with {} cores and {} memory, over max cpu cores and/or max memory",
rmNode.getNode().getName(), offeredResources.getVirtualCores(), offeredResources.getMemory());
}
}