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);
}
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;
}
Aggregations