use of org.apache.hadoop.yarn.server.nodemanager.nodelabels.ConfigurationNodeLabelsProvider 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;
}
Aggregations