Search in sources :

Example 6 with ResourceManagerAdministrationProtocol

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

the class RMAdminCLI method refreshClusterMaxPriority.

private int refreshClusterMaxPriority() throws IOException, YarnException {
    // Refresh cluster max priority
    ResourceManagerAdministrationProtocol adminProtocol = createAdminProtocol();
    RefreshClusterMaxPriorityRequest request = recordFactory.newRecordInstance(RefreshClusterMaxPriorityRequest.class);
    adminProtocol.refreshClusterMaxPriority(request);
    return 0;
}
Also used : ResourceManagerAdministrationProtocol(org.apache.hadoop.yarn.server.api.ResourceManagerAdministrationProtocol) RefreshClusterMaxPriorityRequest(org.apache.hadoop.yarn.server.api.protocolrecords.RefreshClusterMaxPriorityRequest)

Example 7 with ResourceManagerAdministrationProtocol

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

the class RMAdminCLI method getGroups.

private int getGroups(String[] usernames) throws IOException {
    // Get groups users belongs to
    ResourceManagerAdministrationProtocol adminProtocol = createAdminProtocol();
    if (usernames.length == 0) {
        usernames = new String[] { UserGroupInformation.getCurrentUser().getUserName() };
    }
    for (String username : usernames) {
        StringBuilder sb = new StringBuilder();
        sb.append(username + " :");
        for (String group : adminProtocol.getGroupsForUser(username)) {
            sb.append(" ");
            sb.append(group);
        }
        System.out.println(sb);
    }
    return 0;
}
Also used : ResourceManagerAdministrationProtocol(org.apache.hadoop.yarn.server.api.ResourceManagerAdministrationProtocol)

Example 8 with ResourceManagerAdministrationProtocol

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

the class RMAdminCLI method refreshNodesResources.

private int refreshNodesResources() throws IOException, YarnException {
    // Refresh the resources at the Nodemanager
    ResourceManagerAdministrationProtocol adminProtocol = createAdminProtocol();
    RefreshNodesResourcesRequest request = recordFactory.newRecordInstance(RefreshNodesResourcesRequest.class);
    adminProtocol.refreshNodesResources(request);
    return 0;
}
Also used : ResourceManagerAdministrationProtocol(org.apache.hadoop.yarn.server.api.ResourceManagerAdministrationProtocol) RefreshNodesResourcesRequest(org.apache.hadoop.yarn.server.api.protocolrecords.RefreshNodesResourcesRequest)

Example 9 with ResourceManagerAdministrationProtocol

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

the class RMAdminCLI method refreshAdminAcls.

private int refreshAdminAcls() throws IOException, YarnException {
    // Refresh the admin acls
    ResourceManagerAdministrationProtocol adminProtocol = createAdminProtocol();
    RefreshAdminAclsRequest request = recordFactory.newRecordInstance(RefreshAdminAclsRequest.class);
    adminProtocol.refreshAdminAcls(request);
    return 0;
}
Also used : RefreshAdminAclsRequest(org.apache.hadoop.yarn.server.api.protocolrecords.RefreshAdminAclsRequest) ResourceManagerAdministrationProtocol(org.apache.hadoop.yarn.server.api.ResourceManagerAdministrationProtocol)

Example 10 with ResourceManagerAdministrationProtocol

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

the class RMAdminCLI method refreshNodes.

private int refreshNodes(int timeout, String trackingMode) throws IOException, YarnException {
    boolean serverTracking = !"client".equals(trackingMode);
    // Graceful decommissioning with timeout
    ResourceManagerAdministrationProtocol adminProtocol = createAdminProtocol();
    RefreshNodesRequest gracefulRequest = RefreshNodesRequest.newInstance(DecommissionType.GRACEFUL, timeout);
    adminProtocol.refreshNodes(gracefulRequest);
    if (serverTracking) {
        return 0;
    }
    CheckForDecommissioningNodesRequest checkForDecommissioningNodesRequest = recordFactory.newRecordInstance(CheckForDecommissioningNodesRequest.class);
    long waitingTime;
    boolean nodesDecommissioning = true;
    // As RM enforces timeout automatically, client usually don't need
    // to forcefully decommission nodes upon timeout.
    // Here we let the client waits a small additional seconds so to avoid
    // unnecessary double decommission.
    final int gracePeriod = 5;
    // decommissioned
    for (waitingTime = 0; timeout == -1 || (timeout >= 0 && waitingTime < timeout + gracePeriod); waitingTime++) {
        // wait for one second to check nodes decommissioning status
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
        // Ignore the InterruptedException
        }
        CheckForDecommissioningNodesResponse checkForDecommissioningNodes = adminProtocol.checkForDecommissioningNodes(checkForDecommissioningNodesRequest);
        Set<NodeId> decommissioningNodes = checkForDecommissioningNodes.getDecommissioningNodes();
        if (decommissioningNodes.isEmpty()) {
            nodesDecommissioning = false;
            break;
        } else {
            StringBuilder nodes = new StringBuilder();
            for (NodeId nodeId : decommissioningNodes) {
                nodes.append(nodeId).append(",");
            }
            nodes.deleteCharAt(nodes.length() - 1);
            System.out.println("Nodes '" + nodes + "' are still decommissioning.");
        }
    }
    if (nodesDecommissioning) {
        System.out.println("Graceful decommissioning not completed in " + timeout + " seconds, issuing forceful decommissioning command.");
        RefreshNodesRequest forcefulRequest = RefreshNodesRequest.newInstance(DecommissionType.FORCEFUL);
        adminProtocol.refreshNodes(forcefulRequest);
    } else {
        System.out.println("Graceful decommissioning completed in " + waitingTime + " seconds.");
    }
    return 0;
}
Also used : CheckForDecommissioningNodesRequest(org.apache.hadoop.yarn.server.api.protocolrecords.CheckForDecommissioningNodesRequest) ResourceManagerAdministrationProtocol(org.apache.hadoop.yarn.server.api.ResourceManagerAdministrationProtocol) RefreshNodesRequest(org.apache.hadoop.yarn.server.api.protocolrecords.RefreshNodesRequest) NodeId(org.apache.hadoop.yarn.api.records.NodeId) CheckForDecommissioningNodesResponse(org.apache.hadoop.yarn.server.api.protocolrecords.CheckForDecommissioningNodesResponse)

Aggregations

ResourceManagerAdministrationProtocol (org.apache.hadoop.yarn.server.api.ResourceManagerAdministrationProtocol)16 CommandLine (org.apache.commons.cli.CommandLine)2 GnuParser (org.apache.commons.cli.GnuParser)2 MissingArgumentException (org.apache.commons.cli.MissingArgumentException)2 Options (org.apache.commons.cli.Options)2 Configuration (org.apache.hadoop.conf.Configuration)2 NodeId (org.apache.hadoop.yarn.api.records.NodeId)2 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)2 AddToClusterNodeLabelsRequest (org.apache.hadoop.yarn.server.api.protocolrecords.AddToClusterNodeLabelsRequest)2 RefreshNodesRequest (org.apache.hadoop.yarn.server.api.protocolrecords.RefreshNodesRequest)2 IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 HashMap (java.util.HashMap)1 HAServiceProtocol (org.apache.hadoop.ha.HAServiceProtocol)1 HAServiceStatus (org.apache.hadoop.ha.HAServiceStatus)1 HAServiceTarget (org.apache.hadoop.ha.HAServiceTarget)1 NodeLabel (org.apache.hadoop.yarn.api.records.NodeLabel)1 Resource (org.apache.hadoop.yarn.api.records.Resource)1 ResourceOption (org.apache.hadoop.yarn.api.records.ResourceOption)1 YarnRPC (org.apache.hadoop.yarn.ipc.YarnRPC)1