Skip to content

Commit

Permalink
YARN-7707. Fix CheckStyle.
Browse files Browse the repository at this point in the history
  • Loading branch information
slfan1989 committed Jul 18, 2023
1 parent 0d8944f commit 378c25a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4394,9 +4394,15 @@ public static boolean isAclEnabled(Configuration conf) {
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 =
FEDERATION_GPG_POLICY_PREFIX + "interval";
public static final long DEFAULT_GPG_POLICY_GENERATOR_INTERVAL = TimeUnit.HOURS.toMillis(1);

/** The interval at which the policy generator runs, default is one hour.
* This is an deprecated property, We better set it
* `yarn.federation.gpg.policy.generator.interval`. */
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5430,10 +5430,20 @@
<description>
The interval at which the policy generator runs, default is one hour
</description>
<name>yarn.federation.gpg.policy.generator.interval-ms</name>
<name>yarn.federation.gpg.policy.generator.interval</name>
<value>1h</value>
</property>

<property>
<description>
The interval at which the policy generator runs, default is one hour.
This is an deprecated property, We better set it
`yarn.federation.gpg.policy.generator.interval`.
</description>
<name>yarn.federation.gpg.policy.generator.interval-ms</name>
<value>3600000</value>
</property>

<property>
<description>
The configured policy generator class, runs NoOpGlobalPolicy by default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,27 @@ protected void serviceStart() throws Exception {
}

// Schedule PolicyGenerator
long policyGeneratorIntervalMillis = config.getTimeDuration(
YarnConfiguration.GPG_POLICY_GENERATOR_INTERVAL_MS,
YarnConfiguration.DEFAULT_GPG_POLICY_GENERATOR_INTERVAL_MS, TimeUnit.MILLISECONDS);
// We recommend using yarn.federation.gpg.policy.generator.interval
// instead of yarn.federation.gpg.policy.generator.interval-ms

// To ensure compatibility,
// let's first obtain the value of "yarn.federation.gpg.policy.generator.interval-ms."
long policyGeneratorIntervalMillis = 0L;
String generatorIntervalMS = config.get(YarnConfiguration.GPG_POLICY_GENERATOR_INTERVAL_MS);
if (generatorIntervalMS != null) {
LOG.warn("yarn.federation.gpg.policy.generator.interval-ms is deprecated property, " +
" we better set it yarn.federation.gpg.policy.generator.interval.");
policyGeneratorIntervalMillis = Long.parseLong(generatorIntervalMS);
}

// If it is not available, let's retrieve
// the value of "yarn.federation.gpg.policy.generator.interval" instead.
if (policyGeneratorIntervalMillis == 0) {
policyGeneratorIntervalMillis = config.getTimeDuration(
YarnConfiguration.GPG_POLICY_GENERATOR_INTERVAL,
YarnConfiguration.DEFAULT_GPG_POLICY_GENERATOR_INTERVAL, TimeUnit.MILLISECONDS);
}

if(policyGeneratorIntervalMillis > 0){
this.scheduledExecutorService.scheduleAtFixedRate(this.policyGenerator,
0, policyGeneratorIntervalMillis, TimeUnit.MILLISECONDS);
Expand Down

0 comments on commit 378c25a

Please sign in to comment.