Skip to content

Commit

Permalink
YARN-2923. Support configuration based NodeLabelsProvider Service in …
Browse files Browse the repository at this point in the history
…Distributed Node Label Configuration Setup. (Naganarasimha G R)
  • Loading branch information
wangdatan committed Aug 20, 2015
1 parent 0bc15cb commit fc07464
Show file tree
Hide file tree
Showing 11 changed files with 793 additions and 86 deletions.
3 changes: 3 additions & 0 deletions hadoop-yarn-project/CHANGES.txt
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ Release 2.8.0 - UNRELEASED
YARN-4055. Report node resource utilization in heartbeat. YARN-4055. Report node resource utilization in heartbeat.
(Inigo Goiri via kasha) (Inigo Goiri via kasha)


YARN-2923. Support configuration based NodeLabelsProvider Service in Distributed
Node Label Configuration Setup. (Naganarasimha G R)

IMPROVEMENTS IMPROVEMENTS


YARN-644. Basic null check is not performed on passed in arguments before YARN-644. Basic null check is not performed on passed in arguments before
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1967,6 +1967,36 @@ public static boolean isDistributedNodeLabelConfiguration(Configuration conf) {
NODELABEL_CONFIGURATION_TYPE, DEFAULT_NODELABEL_CONFIGURATION_TYPE)); NODELABEL_CONFIGURATION_TYPE, DEFAULT_NODELABEL_CONFIGURATION_TYPE));
} }


private static final String NM_NODE_LABELS_PREFIX = NM_PREFIX
+ "node-labels.";

public static final String NM_NODE_LABELS_PROVIDER_CONFIG =
NM_NODE_LABELS_PREFIX + "provider";

// whitelist names for the yarn.nodemanager.node-labels.provider
public static final String CONFIG_NODE_LABELS_PROVIDER = "config";

private static final String NM_NODE_LABELS_PROVIDER_PREFIX =
NM_NODE_LABELS_PREFIX + "provider.";

// If -1 is configured then no timer task should be created
public static final String NM_NODE_LABELS_PROVIDER_FETCH_INTERVAL_MS =
NM_NODE_LABELS_PROVIDER_PREFIX + "fetch-interval-ms";

public static final String NM_NODE_LABELS_PROVIDER_FETCH_TIMEOUT_MS =
NM_NODE_LABELS_PROVIDER_PREFIX + "fetch-timeout-ms";

// once in 10 mins
public static final long DEFAULT_NM_NODE_LABELS_PROVIDER_FETCH_INTERVAL_MS =
10 * 60 * 1000;

// Twice of default interval time
public static final long DEFAULT_NM_NODE_LABELS_PROVIDER_FETCH_TIMEOUT_MS =
DEFAULT_NM_NODE_LABELS_PROVIDER_FETCH_INTERVAL_MS * 2;

public static final String NM_PROVIDER_CONFIGURED_NODE_LABELS =
NM_NODE_LABELS_PROVIDER_PREFIX + "configured-node-labels";

public YarnConfiguration() { public YarnConfiguration() {
super(); super();
} }
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ public boolean isExclusiveNodeLabel(String nodeLabel) throws IOException {
} }
} }


private void checkAndThrowLabelName(String label) throws IOException { public static void checkAndThrowLabelName(String label) throws IOException {
if (label == null || label.isEmpty() || label.length() > MAX_LABEL_LENGTH) { if (label == null || label.isEmpty() || label.length() > MAX_LABEL_LENGTH) {
throw new IOException("label added is empty or exceeds " throw new IOException("label added is empty or exceeds "
+ MAX_LABEL_LENGTH + " character(s)"); + MAX_LABEL_LENGTH + " character(s)");
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2092,6 +2092,53 @@
<value>centralized</value> <value>centralized</value>
</property> </property>


<!-- Distributed Node Labels Configuration -->
<property>
<description>
When node labels "yarn.node-labels.configuration-type" is
of type "distributed" Administrators can configure the source of the
node labels provider by configuring this parameter. Administrators can
specify either "config" or the class name of the provider. Configured
class needs to extend
org.apache.hadoop.yarn.server.nodemanager.nodelabels.NodeLabelsProvider.
If "config" is specified then, "ConfigurationNodeLabelsProvider" will
be used.
</description>
<name>yarn.nodemanager.node-labels.provider</name>
</property>

<property>
<description>
When node labels "yarn.nodemanager.node-labels.provider" is of type
"config" or the configured class extends AbstractNodeLabelsProvider then
periodically node labels are retrieved from the node labels provider.
This configuration is to define the interval. If -1 is configured then
node labels are retrieved from. provider only during initialization.
Defaults to 10 mins.
</description>
<name>yarn.nodemanager.node-labels.provider.fetch-interval-ms</name>
<value>600000</value>
</property>

<property>
<description>
When node labels "yarn.nodemanager.node-labels.provider"
is of type "config" then ConfigurationNodeLabelsProvider fetches the
labels this parameter.
</description>
<name>yarn.nodemanager.node-labels.provider.configured-node-labels</name>
</property>

<property>
<description>
When node labels "yarn.nodemanager.node-labels.provider" is a class
which extends AbstractNodeLabelsProvider then this configuration provides
the timeout period after which it will stop querying the Node labels
provider. Defaults to 20 mins.
</description>
<name>yarn.nodemanager.node-labels.provider.fetch-timeout-ms</name>
<value>1200000</value>
</property>
<!-- Other Configuration --> <!-- Other Configuration -->


<property> <property>
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import org.apache.hadoop.yarn.server.nodemanager.containermanager.application.Application; import org.apache.hadoop.yarn.server.nodemanager.containermanager.application.Application;
import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container; import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container;
import org.apache.hadoop.yarn.server.nodemanager.metrics.NodeManagerMetrics; import org.apache.hadoop.yarn.server.nodemanager.metrics.NodeManagerMetrics;
import org.apache.hadoop.yarn.server.nodemanager.nodelabels.ConfigurationNodeLabelsProvider;
import org.apache.hadoop.yarn.server.nodemanager.nodelabels.NodeLabelsProvider; import org.apache.hadoop.yarn.server.nodemanager.nodelabels.NodeLabelsProvider;
import org.apache.hadoop.yarn.server.nodemanager.recovery.NMLeveldbStateStoreService; import org.apache.hadoop.yarn.server.nodemanager.recovery.NMLeveldbStateStoreService;
import org.apache.hadoop.yarn.server.nodemanager.recovery.NMNullStateStoreService; import org.apache.hadoop.yarn.server.nodemanager.recovery.NMNullStateStoreService;
Expand Down Expand Up @@ -122,12 +123,38 @@ protected NodeStatusUpdater createNodeStatusUpdater(Context context,
metrics, nodeLabelsProvider); metrics, nodeLabelsProvider);
} }


@VisibleForTesting protected NodeLabelsProvider createNodeLabelsProvider(Configuration conf)
protected NodeLabelsProvider createNodeLabelsProvider( throws IOException {
Configuration conf) throws IOException { NodeLabelsProvider provider = null;
// TODO as part of YARN-2729 String providerString =
// Need to get the implementation of provider service and return conf.get(YarnConfiguration.NM_NODE_LABELS_PROVIDER_CONFIG, null);
return 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;
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;
} }


protected NodeResourceMonitor createNodeResourceMonitor() { protected NodeResourceMonitor createNodeResourceMonitor() {
Expand Down
Loading

0 comments on commit fc07464

Please sign in to comment.