Search in sources :

Example 1 with RefreshNodesResourcesResponse

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

the class AdminService method refreshNodesResources.

@Override
public RefreshNodesResourcesResponse refreshNodesResources(RefreshNodesResourcesRequest request) throws YarnException, StandbyException {
    final String operation = "refreshNodesResources";
    UserGroupInformation user = checkAcls(operation);
    final String msg = "refresh nodes.";
    checkRMStatus(user.getShortUserName(), operation, msg);
    RefreshNodesResourcesResponse response = recordFactory.newRecordInstance(RefreshNodesResourcesResponse.class);
    try {
        Configuration conf = getConfig();
        Configuration configuration = new Configuration(conf);
        DynamicResourceConfiguration newConf;
        InputStream drInputStream = this.rmContext.getConfigurationProvider().getConfigurationInputStream(configuration, YarnConfiguration.DR_CONFIGURATION_FILE);
        if (drInputStream != null) {
            newConf = new DynamicResourceConfiguration(configuration, drInputStream);
        } else {
            newConf = new DynamicResourceConfiguration(configuration);
        }
        if (newConf.getNodes() != null && newConf.getNodes().length != 0) {
            Map<NodeId, ResourceOption> nodeResourceMap = newConf.getNodeResourceMap();
            UpdateNodeResourceRequest updateRequest = UpdateNodeResourceRequest.newInstance(nodeResourceMap);
            updateNodeResource(updateRequest);
        }
        // refresh dynamic resource in ResourceTrackerService
        this.rmContext.getResourceTrackerService().updateDynamicResourceConfiguration(newConf);
        RMAuditLogger.logSuccess(user.getShortUserName(), operation, "AdminService");
        return response;
    } catch (IOException ioe) {
        throw logAndWrapException(ioe, user.getShortUserName(), operation, msg);
    }
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) DynamicResourceConfiguration(org.apache.hadoop.yarn.server.resourcemanager.resource.DynamicResourceConfiguration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) ResourceOption(org.apache.hadoop.yarn.api.records.ResourceOption) InputStream(java.io.InputStream) NodeId(org.apache.hadoop.yarn.api.records.NodeId) IOException(java.io.IOException) RefreshNodesResourcesResponse(org.apache.hadoop.yarn.server.api.protocolrecords.RefreshNodesResourcesResponse) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation) DynamicResourceConfiguration(org.apache.hadoop.yarn.server.resourcemanager.resource.DynamicResourceConfiguration) UpdateNodeResourceRequest(org.apache.hadoop.yarn.server.api.protocolrecords.UpdateNodeResourceRequest)

Aggregations

IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Configuration (org.apache.hadoop.conf.Configuration)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 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)1 RefreshNodesResourcesResponse (org.apache.hadoop.yarn.server.api.protocolrecords.RefreshNodesResourcesResponse)1 UpdateNodeResourceRequest (org.apache.hadoop.yarn.server.api.protocolrecords.UpdateNodeResourceRequest)1 DynamicResourceConfiguration (org.apache.hadoop.yarn.server.resourcemanager.resource.DynamicResourceConfiguration)1