Search in sources :

Example 1 with UpdateNodeResourceResponse

use of org.apache.hadoop.yarn.server.api.protocolrecords.UpdateNodeResourceResponse in project hadoop by apache.

the class TestResourceManagerAdministrationProtocolPBClientImpl method testUpdateNodeResource.

@Test
public void testUpdateNodeResource() throws Exception {
    UpdateNodeResourceRequest request = recordFactory.newRecordInstance(UpdateNodeResourceRequest.class);
    UpdateNodeResourceResponse response = client.updateNodeResource(request);
    assertNotNull(response);
}
Also used : UpdateNodeResourceResponse(org.apache.hadoop.yarn.server.api.protocolrecords.UpdateNodeResourceResponse) UpdateNodeResourceRequest(org.apache.hadoop.yarn.server.api.protocolrecords.UpdateNodeResourceRequest) Test(org.junit.Test)

Example 2 with UpdateNodeResourceResponse

use of org.apache.hadoop.yarn.server.api.protocolrecords.UpdateNodeResourceResponse 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)

Aggregations

UpdateNodeResourceResponse (org.apache.hadoop.yarn.server.api.protocolrecords.UpdateNodeResourceResponse)2 Map (java.util.Map)1 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)1 NodeId (org.apache.hadoop.yarn.api.records.NodeId)1 ResourceOption (org.apache.hadoop.yarn.api.records.ResourceOption)1 UpdateNodeResourceRequest (org.apache.hadoop.yarn.server.api.protocolrecords.UpdateNodeResourceRequest)1 RMNode (org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode)1 RMNodeResourceUpdateEvent (org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNodeResourceUpdateEvent)1 Test (org.junit.Test)1