Search in sources :

Example 1 with RemoveFromClusterNodeLabelsRequest

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

the class RMAdminCLI method handleRemoveFromClusterNodeLabels.

private int handleRemoveFromClusterNodeLabels(String[] args, String cmd, boolean isHAEnabled) throws IOException, YarnException, ParseException {
    Options opts = new Options();
    opts.addOption("removeFromClusterNodeLabels", true, "Remove From 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;
    }
    Set<String> labels = buildNodeLabelNamesFromStr(cliParser.getOptionValue("removeFromClusterNodeLabels"));
    if (cliParser.hasOption("directlyAccessNodeLabelStore")) {
        getNodeLabelManagerInstance(getConf()).removeFromClusterNodeLabels(labels);
    } else {
        ResourceManagerAdministrationProtocol adminProtocol = createAdminProtocol();
        RemoveFromClusterNodeLabelsRequest request = RemoveFromClusterNodeLabelsRequest.newInstance(labels);
        adminProtocol.removeFromClusterNodeLabels(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) MissingArgumentException(org.apache.commons.cli.MissingArgumentException) GnuParser(org.apache.commons.cli.GnuParser) RemoveFromClusterNodeLabelsRequest(org.apache.hadoop.yarn.server.api.protocolrecords.RemoveFromClusterNodeLabelsRequest)

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 ResourceManagerAdministrationProtocol (org.apache.hadoop.yarn.server.api.ResourceManagerAdministrationProtocol)1 RemoveFromClusterNodeLabelsRequest (org.apache.hadoop.yarn.server.api.protocolrecords.RemoveFromClusterNodeLabelsRequest)1