Skip to content

Commit

Permalink
YARN-7708. BackPort [GPG] Load based policy generator. (#5902) Contri…
Browse files Browse the repository at this point in the history
…buted by Young Chen.
  • Loading branch information
slfan1989 committed Aug 5, 2023
1 parent 6d3bcaa commit 001d353
Show file tree
Hide file tree
Showing 8 changed files with 625 additions and 7 deletions.
Expand Up @@ -209,6 +209,10 @@
<Class name="org.apache.hadoop.yarn.server.resourcemanager.scheduler.policy.RecoveryComparator" />
<Bug pattern="SE_COMPARATOR_SHOULD_BE_SERIALIZABLE" />
</Match>
<Match>
<Class name="org.apache.hadoop.yarn.server.globalpolicygenerator.policygenerator.LoadBasedGlobalPolicy$SortByDescendingLoad" />
<Bug pattern="SE_COMPARATOR_SHOULD_BE_SERIALIZABLE" />
</Match>
<!-- Ignore some irrelevant class name warning -->
<Match>
<Class name="org.apache.hadoop.yarn.api.records.SerializedException" />
Expand Down
Expand Up @@ -4427,6 +4427,24 @@ public static boolean isAclEnabled(Configuration conf) {
public static final String GPG_POLICY_GENERATOR_BLACKLIST =
FEDERATION_GPG_POLICY_PREFIX + "blacklist";

private static final String FEDERATION_GPG_LOAD_BASED_PREFIX =
YarnConfiguration.FEDERATION_GPG_PREFIX + "policy.generator.load-based.";
public static final String FEDERATION_GPG_LOAD_BASED_MIN_PENDING =
FEDERATION_GPG_LOAD_BASED_PREFIX + "pending.minimum";
public static final int DEFAULT_FEDERATION_GPG_LOAD_BASED_MIN_PENDING = 100;
public static final String FEDERATION_GPG_LOAD_BASED_MAX_PENDING =
FEDERATION_GPG_LOAD_BASED_PREFIX + "pending.maximum";
public static final int DEFAULT_FEDERATION_GPG_LOAD_BASED_MAX_PENDING = 1000;
public static final String FEDERATION_GPG_LOAD_BASED_MIN_WEIGHT =
FEDERATION_GPG_LOAD_BASED_PREFIX + "weight.minimum";
public static final float DEFAULT_FEDERATION_GPG_LOAD_BASED_MIN_WEIGHT = 0.0f;
public static final String FEDERATION_GPG_LOAD_BASED_MAX_EDIT =
FEDERATION_GPG_LOAD_BASED_PREFIX + "edit.maximum";
public static final int DEFAULT_FEDERATION_GPG_LOAD_BASED_MAX_EDIT = 3;
public static final String FEDERATION_GPG_LOAD_BASED_SCALING =
FEDERATION_GPG_LOAD_BASED_PREFIX + "scaling";
public static final String DEFAULT_FEDERATION_GPG_LOAD_BASED_SCALING = "LINEAR";

/**
* Connection and Read timeout from the Router to RM.
*/
Expand Down
Expand Up @@ -5468,4 +5468,66 @@
<value></value>
</property>

<property>
<description>
GPG load policy, the minimum number of pending applications in the subCluster.
</description>
<name>yarn.federation.gpg.policy.generator.load-based.pending.minimum</name>
<value>100</value>
</property>

<property>
<description>
GPG load policy, the maximum number of pending applications in the subCluster.
</description>
<name>yarn.federation.gpg.policy.generator.load-based.pending.maximum</name>
<value>1000</value>
</property>

<property>
<description>
GPG load policy, the subCluster minimum weight,
If a subCluster has a very high load, we will assign this value to the subCluster.
The default value is 0, which means that we no longer assign appliaction to this subCluster.
</description>
<name>yarn.federation.gpg.policy.generator.load-based.weight.minimum</name>
<value>0</value>
</property>

<property>
<description>
GPG load policy, We choose the subCluster computing load of TopN.
This value represents the number of subClusters we want to calculate.
</description>
<name>yarn.federation.gpg.policy.generator.load-based.edit.maximum</name>
<value>3</value>
</property>

<property>
<description>
GPG load policy, We provide 4 calculation methods: NONE, LINEAR, QUADRATIC, LOG.

Note, this calculation method is when the number of Pending Applications in
the subCluster is less than yarn.federation.gpg.policy.generator.load-based.pending.maximum.

maxPendingVal = yarn.federation.gpg.policy.generator.load-based.pending.maximum -
yarn.federation.gpg.policy.generator.load-based.pending.minimum
curPendingVal = Pending Applications in the subCluster -
yarn.federation.gpg.policy.generator.load-based.pending.minimum

1. NONE: No calculation is required, and the weight is 1 at this time.
2. LINEAR: For linear computation, we will use (maxPendingVal - curPendingVal) / (maxPendingVal).
3. QUADRATIC: Calculated using quadratic,
We will calculate quadratic for maxPendingVal, curPendingVal,
then use this formula = (maxPendingVal - curPendingVal) / (maxPendingVal).
4. LOG(LOGARITHM): Calculated using logarithm,
We will calculate logarithm for maxPendingVal, curPendingVal,
then use this formula = (maxPendingVal - curPendingVal) / (maxPendingVal).

LINEAR is used by default.
</description>
<name>yarn.federation.gpg.policy.generator.load-based.scaling</name>
<value>LINEAR</value>
</property>

</configuration>
Expand Up @@ -55,7 +55,7 @@ private GPGUtils() {
*/
public static <T> T invokeRMWebService(String webAddr, String path, final Class<T> returnType) {
Client client = Client.create();
T obj = null;
T obj;

WebResource webResource = client.resource(webAddr);
ClientResponse response = null;
Expand Down Expand Up @@ -86,8 +86,7 @@ public static <T> T invokeRMWebService(String webAddr, String path, final Class<
*/
public static Map<SubClusterIdInfo, Float> createUniformWeights(
Set<SubClusterId> ids) {
Map<SubClusterIdInfo, Float> weights =
new HashMap<>();
Map<SubClusterIdInfo, Float> weights = new HashMap<>();
for(SubClusterId id : ids) {
weights.put(new SubClusterIdInfo(id), 1.0f);
}
Expand Down
Expand Up @@ -53,7 +53,7 @@ public Configuration getConf() {
*
* @return a map of the object type and RM path.
*/
protected Map<Class, String> registerPaths() {
protected Map<Class<?>, String> registerPaths() {
// Default register nothing
return Collections.emptyMap();
}
Expand Down

0 comments on commit 001d353

Please sign in to comment.