Skip to content

Commit

Permalink
YARN-7707. BackPort [GPG] Policy generator framework.
Browse files Browse the repository at this point in the history
  • Loading branch information
slfan1989 committed Jul 13, 2023
1 parent 680af87 commit f5edc1b
Show file tree
Hide file tree
Showing 18 changed files with 1,776 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4390,6 +4390,37 @@ public static boolean isAclEnabled(Configuration conf) {
public static final String GPG_KERBEROS_PRINCIPAL_HOSTNAME_KEY = FEDERATION_GPG_PREFIX +
"kerberos.principal.hostname";

public static final String FEDERATION_GPG_POLICY_PREFIX =
FEDERATION_GPG_PREFIX + "policy.generator.";

/** The interval at which the policy generator runs, default is one hour. */
public static final String GPG_POLICY_GENERATOR_INTERVAL_MS =
FEDERATION_GPG_POLICY_PREFIX + "interval-ms";
public static final long DEFAULT_GPG_POLICY_GENERATOR_INTERVAL_MS = TimeUnit.HOURS.toMillis(1);

/**
* The configured policy generator class, runs NoOpGlobalPolicy by
* default.
*/
public static final String GPG_GLOBAL_POLICY_CLASS = FEDERATION_GPG_POLICY_PREFIX + "class";
public static final String DEFAULT_GPG_GLOBAL_POLICY_CLASS =
"org.apache.hadoop.yarn.server.globalpolicygenerator.policygenerator." +
"NoOpGlobalPolicy";

/**
* Whether or not the policy generator is running in read only (won't modify
* policies), default is false.
*/
public static final String GPG_POLICY_GENERATOR_READONLY =
FEDERATION_GPG_POLICY_PREFIX + "readonly";
public static final boolean DEFAULT_GPG_POLICY_GENERATOR_READONLY = false;

/**
* Which sub-clusters the policy generator should blacklist.
*/
public static final String GPG_POLICY_GENERATOR_BLACKLIST =
FEDERATION_GPG_POLICY_PREFIX + "blacklist";

/**
* Connection and Read timeout from the Router to RM.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5408,6 +5408,14 @@
</description>
</property>

<property>
<description>
The interval at which the policy generator runs, default is one hour
</description>
<name>yarn.federation.gpg.policy.generator.interval-ms</name>
<value>1h</value>
</property>

<property>
<description>
The number of retry for Register UAM.
Expand All @@ -5419,6 +5427,30 @@

<property>
<description>
The configured policy generator class, runs NoOpGlobalPolicy by default
</description>
<name>yarn.federation.gpg.policy.generator.class</name>
<value>org.apache.hadoop.yarn.server.globalpolicygenerator.policygenerator.NoOpGlobalPolicy</value>
</property>

<property>
<description>
Whether or not the policy generator is running in read only (won't modify policies), default is false
</description>
<name>yarn.federation.gpg.policy.generator.readonly</name>
<value>false</value>
</property>

<property>
<description>
Which subclusters the gpg should blacklist, default is none
</description>
<name>yarn.federation.gpg.policy.generator.blacklist</name>
<value></value>
</property>

<property>
<description>
Interval between retry for Register UAM.
The default value is 100ms.
</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import org.apache.hadoop.yarn.server.federation.store.records.GetSubClusterPoliciesConfigurationsRequest;
import org.apache.hadoop.yarn.server.federation.store.records.GetSubClusterPolicyConfigurationRequest;
import org.apache.hadoop.yarn.server.federation.store.records.GetSubClusterPolicyConfigurationResponse;
import org.apache.hadoop.yarn.server.federation.store.records.SetSubClusterPolicyConfigurationRequest;
import org.apache.hadoop.yarn.server.federation.store.records.GetSubClustersInfoRequest;
import org.apache.hadoop.yarn.server.federation.store.records.ReservationHomeSubCluster;
import org.apache.hadoop.yarn.server.federation.store.records.SubClusterId;
Expand Down Expand Up @@ -311,6 +312,18 @@ public SubClusterPolicyConfiguration getPolicyConfiguration(final String queue)
}
}

/**
* Set a policy configuration into the state store.
*
* @param policyConf the policy configuration to set
* @throws YarnException if the request is invalid/fails
*/
public void setPolicyConfiguration(SubClusterPolicyConfiguration policyConf)
throws YarnException {
stateStore.setPolicyConfiguration(
SetSubClusterPolicyConfigurationRequest.newInstance(policyConf));
}

/**
* Get the policies that is represented as
* {@link SubClusterPolicyConfiguration} for all currently active queues in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-yarn-server-timelineservice</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-yarn-server-resourcemanager</artifactId>
Expand All @@ -72,6 +78,12 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-yarn-server-common</artifactId>
Expand Down Expand Up @@ -106,6 +118,12 @@
<plugin>
<groupId>org.apache.rat</groupId>
<artifactId>apache-rat-plugin</artifactId>
<configuration>
<excludes>
<exclude>src/test/resources/schedulerInfo1.json</exclude>
<exclude>src/test/resources/schedulerInfo2.json</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@ public interface GPGContext {
FederationStateStoreFacade getStateStoreFacade();

void setStateStoreFacade(FederationStateStoreFacade facade);

GPGPolicyFacade getPolicyFacade();

void setPolicyFacade(GPGPolicyFacade facade);
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
public class GPGContextImpl implements GPGContext {

private FederationStateStoreFacade facade;
private GPGPolicyFacade policyFacade;

@Override
public FederationStateStoreFacade getStateStoreFacade() {
Expand All @@ -38,4 +39,13 @@ public void setStateStoreFacade(
this.facade = federationStateStoreFacade;
}

@Override
public GPGPolicyFacade getPolicyFacade(){
return policyFacade;
}

@Override
public void setPolicyFacade(GPGPolicyFacade gpgPolicyfacade){
policyFacade = gpgPolicyfacade;
}
}
Loading

0 comments on commit f5edc1b

Please sign in to comment.