Search in sources :

Example 6 with ResourceOption

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();
}
Also used : ResourceOption(org.apache.hadoop.yarn.api.records.ResourceOption)

Example 7 with ResourceOption

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;
}
Also used : HashMap(java.util.HashMap) ResourceOption(org.apache.hadoop.yarn.api.records.ResourceOption) NodeId(org.apache.hadoop.yarn.api.records.NodeId) Resource(org.apache.hadoop.yarn.api.records.Resource)

Example 8 with ResourceOption

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;
}
Also used : RMNode(org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode) UpdateNodeResourceResponse(org.apache.hadoop.yarn.server.api.protocolrecords.UpdateNodeResourceResponse) ResourceOption(org.apache.hadoop.yarn.api.records.ResourceOption) NodeId(org.apache.hadoop.yarn.api.records.NodeId) RMNodeResourceUpdateEvent(org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNodeResourceUpdateEvent) Map(java.util.Map) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation)

Example 9 with ResourceOption

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()));
    }
}
Also used : NodeResourceMapProto(org.apache.hadoop.yarn.proto.YarnProtos.NodeResourceMapProto) ResourceOption(org.apache.hadoop.yarn.api.records.ResourceOption) UpdateNodeResourceRequestProtoOrBuilder(org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.UpdateNodeResourceRequestProtoOrBuilder) NodeId(org.apache.hadoop.yarn.api.records.NodeId)

Aggregations

ResourceOption (org.apache.hadoop.yarn.api.records.ResourceOption)9 NodeId (org.apache.hadoop.yarn.api.records.NodeId)8 UpdateNodeResourceRequest (org.apache.hadoop.yarn.server.api.protocolrecords.UpdateNodeResourceRequest)5 HashMap (java.util.HashMap)4 Resource (org.apache.hadoop.yarn.api.records.Resource)3 Test (org.junit.Test)3 Configuration (org.apache.hadoop.conf.Configuration)2 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)2 AllocateResponse (org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse)2 Container (org.apache.hadoop.yarn.api.records.Container)2 ContainerStatus (org.apache.hadoop.yarn.api.records.ContainerStatus)2 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)2 MockAM (org.apache.hadoop.yarn.server.resourcemanager.MockAM)2 MockNM (org.apache.hadoop.yarn.server.resourcemanager.MockNM)2 MockRM (org.apache.hadoop.yarn.server.resourcemanager.MockRM)2 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)2 RMAppAttempt (org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt)2 SchedulerNodeReport (org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerNodeReport)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1