Search in sources :

Example 1 with ScriptBasedNodeLabelsProvider

use of org.apache.hadoop.yarn.server.nodemanager.nodelabels.ScriptBasedNodeLabelsProvider in project hadoop by apache.

the class NodeManager method createNodeLabelsProvider.

protected NodeLabelsProvider createNodeLabelsProvider(Configuration conf) throws IOException {
    NodeLabelsProvider provider = null;
    String providerString = conf.get(YarnConfiguration.NM_NODE_LABELS_PROVIDER_CONFIG, null);
    if (providerString == null || providerString.trim().length() == 0) {
        // Seems like Distributed Node Labels configuration is not enabled
        return provider;
    }
    switch(providerString.trim().toLowerCase()) {
        case YarnConfiguration.CONFIG_NODE_LABELS_PROVIDER:
            provider = new ConfigurationNodeLabelsProvider();
            break;
        case YarnConfiguration.SCRIPT_NODE_LABELS_PROVIDER:
            provider = new ScriptBasedNodeLabelsProvider();
            break;
        default:
            try {
                Class<? extends NodeLabelsProvider> labelsProviderClass = conf.getClass(YarnConfiguration.NM_NODE_LABELS_PROVIDER_CONFIG, null, NodeLabelsProvider.class);
                provider = labelsProviderClass.newInstance();
            } catch (InstantiationException | IllegalAccessException | RuntimeException e) {
                LOG.error("Failed to create NodeLabelsProvider based on Configuration", e);
                throw new IOException("Failed to create NodeLabelsProvider : " + e.getMessage(), e);
            }
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("Distributed Node Labels is enabled" + " with provider class as : " + provider.getClass().toString());
    }
    return provider;
}
Also used : ScriptBasedNodeLabelsProvider(org.apache.hadoop.yarn.server.nodemanager.nodelabels.ScriptBasedNodeLabelsProvider) YarnRuntimeException(org.apache.hadoop.yarn.exceptions.YarnRuntimeException) NodeLabelsProvider(org.apache.hadoop.yarn.server.nodemanager.nodelabels.NodeLabelsProvider) ScriptBasedNodeLabelsProvider(org.apache.hadoop.yarn.server.nodemanager.nodelabels.ScriptBasedNodeLabelsProvider) ConfigurationNodeLabelsProvider(org.apache.hadoop.yarn.server.nodemanager.nodelabels.ConfigurationNodeLabelsProvider) IOException(java.io.IOException) ConfigurationNodeLabelsProvider(org.apache.hadoop.yarn.server.nodemanager.nodelabels.ConfigurationNodeLabelsProvider)

Aggregations

IOException (java.io.IOException)1 YarnRuntimeException (org.apache.hadoop.yarn.exceptions.YarnRuntimeException)1 ConfigurationNodeLabelsProvider (org.apache.hadoop.yarn.server.nodemanager.nodelabels.ConfigurationNodeLabelsProvider)1 NodeLabelsProvider (org.apache.hadoop.yarn.server.nodemanager.nodelabels.NodeLabelsProvider)1 ScriptBasedNodeLabelsProvider (org.apache.hadoop.yarn.server.nodemanager.nodelabels.ScriptBasedNodeLabelsProvider)1