Skip to content

Commit

Permalink
YARN-9858. Optimize RMContext getExclusiveEnforcedPartitions. Contrib…
Browse files Browse the repository at this point in the history
…uted by Jonathan Hung.
  • Loading branch information
bibinchundatt committed Oct 1, 2019
1 parent 8efd25b commit 425a6c8
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.apache.hadoop.HadoopIllegalArgumentException;
import org.apache.hadoop.classification.InterfaceAudience.Private;
Expand Down Expand Up @@ -3795,6 +3797,20 @@ public static boolean isAclEnabled(Configuration conf) {
public static final String EXCLUSIVE_ENFORCED_PARTITIONS = NODE_LABELS_PREFIX
+ EXCLUSIVE_ENFORCED_PARTITIONS_SUFFIX;

@Private
public static Set<String> getExclusiveEnforcedPartitions(
Configuration conf) {
Set<String> exclusiveEnforcedPartitions = new HashSet<>();
String[] configuredPartitions = conf.getStrings(
EXCLUSIVE_ENFORCED_PARTITIONS);
if (configuredPartitions != null) {
for (String partition : configuredPartitions) {
exclusiveEnforcedPartitions.add(partition);
}
}
return exclusiveEnforcedPartitions;
}

public static final String MAX_CLUSTER_LEVEL_APPLICATION_PRIORITY =
YARN_PREFIX + "cluster.max-application-priority";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ final class DefaultAMSProcessor implements ApplicationMasterServiceProcessor {
private ResourceProfilesManager resourceProfilesManager;
private boolean timelineServiceV2Enabled;
private boolean nodelabelsEnabled;
private Set<String> exclusiveEnforcedPartitions;

@Override
public void init(ApplicationMasterServiceContext amsContext,
Expand All @@ -129,6 +130,8 @@ public void init(ApplicationMasterServiceContext amsContext,
timelineServiceV2Enabled(rmContext.getYarnConfiguration());
this.nodelabelsEnabled = YarnConfiguration
.areNodeLabelsEnabled(rmContext.getYarnConfiguration());
this.exclusiveEnforcedPartitions = YarnConfiguration
.getExclusiveEnforcedPartitions(rmContext.getYarnConfiguration());
}

@Override
Expand Down Expand Up @@ -239,8 +242,7 @@ public void allocate(ApplicationAttemptId appAttemptId,
}
if (ResourceRequest.ANY.equals(req.getResourceName())) {
SchedulerUtils.enforcePartitionExclusivity(req,
getRmContext().getExclusiveEnforcedPartitions(),
asc.getNodeLabelExpression());
exclusiveEnforcedPartitions, asc.getNodeLabelExpression());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ public RMAppManager(RMContext context,
timelineServiceV2Enabled(conf);
this.nodeLabelsEnabled = YarnConfiguration
.areNodeLabelsEnabled(rmContext.getYarnConfiguration());
this.exclusiveEnforcedPartitions = context.getExclusiveEnforcedPartitions();
this.exclusiveEnforcedPartitions = YarnConfiguration
.getExclusiveEnforcedPartitions(rmContext.getYarnConfiguration());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

package org.apache.hadoop.yarn.server.resourcemanager;

import java.util.Set;
import java.util.concurrent.ConcurrentMap;

import org.apache.hadoop.conf.Configuration;
Expand Down Expand Up @@ -204,7 +203,4 @@ void setMultiNodeSortingManager(
long getTokenSequenceNo();

void incrTokenSequenceNo();

Set<String> getExclusiveEnforcedPartitions();

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

import java.net.URI;
import java.net.URISyntaxException;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ConcurrentMap;

import org.slf4j.Logger;
Expand All @@ -34,7 +32,6 @@
import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.hadoop.yarn.api.records.NodeId;
import org.apache.hadoop.yarn.conf.ConfigurationProvider;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.event.Dispatcher;
import org.apache.hadoop.yarn.nodelabels.NodeAttributesManager;
import org.apache.hadoop.yarn.proto.YarnServerCommonServiceProtos.SystemCredentialsForAppsProto;
Expand Down Expand Up @@ -681,20 +678,4 @@ public long getTokenSequenceNo() {
public void incrTokenSequenceNo() {
this.activeServiceContext.incrTokenSequenceNo();
}

public Set<String> getExclusiveEnforcedPartitions() {
Set<String> exclusiveEnforcedPartitions = new HashSet<>();
Configuration conf = getYarnConfiguration();
if (conf == null) {
return new HashSet<>();
}
String[] configuredPartitions = conf.getStrings(
YarnConfiguration.EXCLUSIVE_ENFORCED_PARTITIONS);
if (configuredPartitions != null) {
for (String partition : configuredPartitions) {
exclusiveEnforcedPartitions.add(partition);
}
}
return exclusiveEnforcedPartitions;
}
}

0 comments on commit 425a6c8

Please sign in to comment.