This is an automated email from the ASF dual-hosted git repository. madhan pushed a commit to branch ranger-2.6 in repository https://gitbox.apache.org/repos/asf/ranger.git
commit 378a0fd0fd59b125331a388d16bd6090bb593a0c Author: 朱通通 <[email protected]> AuthorDate: Fri Sep 13 09:03:05 2024 +0800 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. (cherry picked from commit 854a113f22f36c49d2c3837663132c0324473acb) --- .../apache/ranger/unixusersync/config/UserGroupSyncConfig.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ugsync/src/main/java/org/apache/ranger/unixusersync/config/UserGroupSyncConfig.java b/ugsync/src/main/java/org/apache/ranger/unixusersync/config/UserGroupSyncConfig.java index 325e74547..a10b8233e 100644 --- a/ugsync/src/main/java/org/apache/ranger/unixusersync/config/UserGroupSyncConfig.java +++ b/ugsync/src/main/java/org/apache/ranger/unixusersync/config/UserGroupSyncConfig.java @@ -98,6 +98,8 @@ public class UserGroupSyncConfig { private static final String UGSYNC_SLEEP_TIME_IN_MILLIS_BETWEEN_CYCLE_PARAM = "ranger.usersync.sleeptimeinmillisbetweensynccycle"; + private static final String UGSYNC_SLEEP_LDAP_FORCE_TIME_IN_MILLIS_BETWEEN_CYCLE_PARAM_ENABLED = "ranger.usersync.ldap.force.sleeptimeinmillisbetweensynccycle.enabled"; + private static final long UGSYNC_SLEEP_TIME_IN_MILLIS_BETWEEN_CYCLE_MIN_VALUE = 60000L; private static final long UGSYNC_SLEEP_TIME_IN_MILLIS_BETWEEN_CYCLE_UNIX_DEFAULT_VALUE = 60000L; @@ -517,6 +519,7 @@ public class UserGroupSyncConfig { } public long getSleepTimeInMillisBetweenCycle() throws Throwable { String val = prop.getProperty(UGSYNC_SLEEP_TIME_IN_MILLIS_BETWEEN_CYCLE_PARAM); + boolean is_ldap_force = Boolean.parseBoolean(prop.getProperty(UGSYNC_SLEEP_LDAP_FORCE_TIME_IN_MILLIS_BETWEEN_CYCLE_PARAM_ENABLED)); String className = getUserGroupSource().getClass().getName(); if (val == null) { if (LGSYNC_SOURCE_CLASS.equals(className)) { @@ -529,7 +532,12 @@ public class UserGroupSyncConfig { long ret = Long.parseLong(val); long min_interval; if (LGSYNC_SOURCE_CLASS.equals(className)) { - min_interval = UGSYNC_SLEEP_TIME_IN_MILLIS_BETWEEN_CYCLE_LDAP_DEFAULT_VALUE; + if (is_ldap_force && ret < UGSYNC_SLEEP_TIME_IN_MILLIS_BETWEEN_CYCLE_LDAP_DEFAULT_VALUE) { + min_interval = ret; + 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."); + } else { + min_interval = UGSYNC_SLEEP_TIME_IN_MILLIS_BETWEEN_CYCLE_LDAP_DEFAULT_VALUE; + } }else if(UGSYNC_SOURCE_CLASS.equals(className)){ min_interval = UGSYNC_SLEEP_TIME_IN_MILLIS_BETWEEN_CYCLE_UNIX_DEFAULT_VALUE; } else {
