use of org.apache.hadoop.yarn.api.records.ResourceOption in project hadoop by apache.
the class RMNodeImpl method updateNodeResourceFromEvent.
private static void updateNodeResourceFromEvent(RMNodeImpl rmNode, RMNodeResourceUpdateEvent event) {
ResourceOption resourceOption = event.getResourceOption();
// Set resource on RMNode
rmNode.totalCapability = resourceOption.getResource();
}
use of org.apache.hadoop.yarn.api.records.ResourceOption in project hadoop by apache.
the class DynamicResourceConfiguration method getNodeResourceMap.
public Map<NodeId, ResourceOption> getNodeResourceMap() {
String[] nodes = getNodes();
Map<NodeId, ResourceOption> resourceOptions = new HashMap<NodeId, ResourceOption>();
for (String node : nodes) {
NodeId nid = NodeId.fromString(node);
int vcores = getVcoresPerNode(node);
int memory = getMemoryPerNode(node);
int overCommitTimeout = getOverCommitTimeoutPerNode(node);
Resource resource = Resources.createResource(memory, vcores);
ResourceOption resourceOption = ResourceOption.newInstance(resource, overCommitTimeout);
resourceOptions.put(nid, resourceOption);
}
return resourceOptions;
}
use of org.apache.hadoop.yarn.api.records.ResourceOption in project hadoop by apache.
the class AdminService method updateNodeResource.
@SuppressWarnings("unchecked")
@Override
public UpdateNodeResourceResponse updateNodeResource(UpdateNodeResourceRequest request) throws YarnException, IOException {
final String operation = "updateNodeResource";
UserGroupInformation user = checkAcls(operation);
checkRMStatus(user.getShortUserName(), operation, "update node resource.");
Map<NodeId, ResourceOption> nodeResourceMap = request.getNodeResourceMap();
Set<NodeId> nodeIds = nodeResourceMap.keySet();
// valid nodes.
for (NodeId nodeId : nodeIds) {
RMNode node = this.rmContext.getRMNodes().get(nodeId);
if (node == null) {
LOG.error("Resource update get failed on all nodes due to change " + "resource on an unrecognized node: " + nodeId);
throw RPCUtil.getRemoteException("Resource update get failed on all nodes due to change resource " + "on an unrecognized node: " + nodeId);
}
}
// do resource update on each node.
// Notice: it is still possible to have invalid NodeIDs as nodes decommission
// may happen just at the same time. This time, only log and skip absent
// nodes without throwing any exceptions.
boolean allSuccess = true;
for (Map.Entry<NodeId, ResourceOption> entry : nodeResourceMap.entrySet()) {
ResourceOption newResourceOption = entry.getValue();
NodeId nodeId = entry.getKey();
RMNode node = this.rmContext.getRMNodes().get(nodeId);
if (node == null) {
LOG.warn("Resource update get failed on an unrecognized node: " + nodeId);
allSuccess = false;
} else {
// update resource to RMNode
this.rmContext.getDispatcher().getEventHandler().handle(new RMNodeResourceUpdateEvent(nodeId, newResourceOption));
LOG.info("Update resource on node(" + node.getNodeID() + ") with resource(" + newResourceOption.toString() + ")");
}
}
if (allSuccess) {
RMAuditLogger.logSuccess(user.getShortUserName(), operation, "AdminService");
}
UpdateNodeResourceResponse response = UpdateNodeResourceResponse.newInstance();
return response;
}
use of org.apache.hadoop.yarn.api.records.ResourceOption in project hadoop by apache.
the class UpdateNodeResourceRequestPBImpl method initNodeResourceMap.
private void initNodeResourceMap() {
if (this.nodeResourceMap != null) {
return;
}
UpdateNodeResourceRequestProtoOrBuilder p = viaProto ? proto : builder;
List<NodeResourceMapProto> list = p.getNodeResourceMapList();
this.nodeResourceMap = new HashMap<NodeId, ResourceOption>(list.size());
for (NodeResourceMapProto nodeResourceProto : list) {
this.nodeResourceMap.put(convertFromProtoFormat(nodeResourceProto.getNodeId()), convertFromProtoFormat(nodeResourceProto.getResourceOption()));
}
}
Aggregations