Skip to content

Commit 854a113

Browse files
authored
RANGER-4307: Allow users customize the time interval (#269)
Modified the UserGroupSyncConfig.java file and added the configuration of user forced custom time synchronization. If enabled, LDAP users can be synchronized according to the user defined time.
1 parent e671f86 commit 854a113

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

ugsync/src/main/java/org/apache/ranger/unixusersync/config/UserGroupSyncConfig.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ public class UserGroupSyncConfig {
9898

9999
private static final String UGSYNC_SLEEP_TIME_IN_MILLIS_BETWEEN_CYCLE_PARAM = "ranger.usersync.sleeptimeinmillisbetweensynccycle";
100100

101+
private static final String UGSYNC_SLEEP_LDAP_FORCE_TIME_IN_MILLIS_BETWEEN_CYCLE_PARAM_ENABLED = "ranger.usersync.ldap.force.sleeptimeinmillisbetweensynccycle.enabled";
102+
101103
private static final long UGSYNC_SLEEP_TIME_IN_MILLIS_BETWEEN_CYCLE_MIN_VALUE = 60000L;
102104

103105
private static final long UGSYNC_SLEEP_TIME_IN_MILLIS_BETWEEN_CYCLE_UNIX_DEFAULT_VALUE = 60000L;
@@ -517,6 +519,7 @@ public long getInitSleepTimeInMillisBetweenCycle() throws Throwable{
517519
}
518520
public long getSleepTimeInMillisBetweenCycle() throws Throwable {
519521
String val = prop.getProperty(UGSYNC_SLEEP_TIME_IN_MILLIS_BETWEEN_CYCLE_PARAM);
522+
boolean is_ldap_force = Boolean.parseBoolean(prop.getProperty(UGSYNC_SLEEP_LDAP_FORCE_TIME_IN_MILLIS_BETWEEN_CYCLE_PARAM_ENABLED));
520523
String className = getUserGroupSource().getClass().getName();
521524
if (val == null) {
522525
if (LGSYNC_SOURCE_CLASS.equals(className)) {
@@ -529,7 +532,12 @@ public long getSleepTimeInMillisBetweenCycle() throws Throwable {
529532
long ret = Long.parseLong(val);
530533
long min_interval;
531534
if (LGSYNC_SOURCE_CLASS.equals(className)) {
532-
min_interval = UGSYNC_SLEEP_TIME_IN_MILLIS_BETWEEN_CYCLE_LDAP_DEFAULT_VALUE;
535+
if (is_ldap_force && ret < UGSYNC_SLEEP_TIME_IN_MILLIS_BETWEEN_CYCLE_LDAP_DEFAULT_VALUE) {
536+
min_interval = ret;
537+
LOG.info("If you force the synchronization time of ldap users to be less than the default of 3600s, this setting [" + min_interval + "] millisec will take effect.");
538+
} else {
539+
min_interval = UGSYNC_SLEEP_TIME_IN_MILLIS_BETWEEN_CYCLE_LDAP_DEFAULT_VALUE;
540+
}
533541
}else if(UGSYNC_SOURCE_CLASS.equals(className)){
534542
min_interval = UGSYNC_SLEEP_TIME_IN_MILLIS_BETWEEN_CYCLE_UNIX_DEFAULT_VALUE;
535543
} else {

0 commit comments

Comments
 (0)