Search in sources :

Example 1 with AddToClusterNodeLabelsRequest

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

the class RMAdminCLI method handleAddToClusterNodeLabels.

private int handleAddToClusterNodeLabels(String[] args, String cmd, boolean isHAEnabled) throws IOException, YarnException, ParseException {
    Options opts = new Options();
    opts.addOption("addToClusterNodeLabels", true, "Add to cluster node labels.");
    opts.addOption("directlyAccessNodeLabelStore", false, "Directly access node label store.");
    int exitCode = -1;
    CommandLine cliParser = null;
    try {
        cliParser = new GnuParser().parse(opts, args);
    } catch (MissingArgumentException ex) {
        System.err.println(NO_LABEL_ERR_MSG);
        printUsage(args[0], isHAEnabled);
        return exitCode;
    }
    List<NodeLabel> labels = buildNodeLabelsFromStr(cliParser.getOptionValue("addToClusterNodeLabels"));
    if (cliParser.hasOption("directlyAccessNodeLabelStore")) {
        getNodeLabelManagerInstance(getConf()).addToCluserNodeLabels(labels);
    } else {
        ResourceManagerAdministrationProtocol adminProtocol = createAdminProtocol();
        AddToClusterNodeLabelsRequest request = AddToClusterNodeLabelsRequest.newInstance(labels);
        adminProtocol.addToClusterNodeLabels(request);
    }
    return 0;
}
Also used : Options(org.apache.commons.cli.Options) ResourceManagerAdministrationProtocol(org.apache.hadoop.yarn.server.api.ResourceManagerAdministrationProtocol) CommandLine(org.apache.commons.cli.CommandLine) NodeLabel(org.apache.hadoop.yarn.api.records.NodeLabel) MissingArgumentException(org.apache.commons.cli.MissingArgumentException) GnuParser(org.apache.commons.cli.GnuParser) AddToClusterNodeLabelsRequest(org.apache.hadoop.yarn.server.api.protocolrecords.AddToClusterNodeLabelsRequest)

Aggregations

CommandLine (org.apache.commons.cli.CommandLine)1 GnuParser (org.apache.commons.cli.GnuParser)1 MissingArgumentException (org.apache.commons.cli.MissingArgumentException)1 Options (org.apache.commons.cli.Options)1 NodeLabel (org.apache.hadoop.yarn.api.records.NodeLabel)1 ResourceManagerAdministrationProtocol (org.apache.hadoop.yarn.server.api.ResourceManagerAdministrationProtocol)1 AddToClusterNodeLabelsRequest (org.apache.hadoop.yarn.server.api.protocolrecords.AddToClusterNodeLabelsRequest)1