ARGUS-186: Updated usersync service for better handling of failures in sending users/groups to policy admin.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/e88740f5 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/e88740f5 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/e88740f5 Branch: refs/heads/ranger-0.4 Commit: e88740f5f8f3615bc115e9c17bc35a1a269bf7e9 Parents: b041642 Author: Madhan Neethiraj <[email protected]> Authored: Tue Nov 18 13:54:18 2014 -0800 Committer: sneethiraj <[email protected]> Committed: Sun Dec 7 01:18:12 2014 -0500 ---------------------------------------------------------------------- .../com/xasecure/usergroupsync/UserGroupSync.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/e88740f5/ugsync/src/main/java/com/xasecure/usergroupsync/UserGroupSync.java ---------------------------------------------------------------------- diff --git a/ugsync/src/main/java/com/xasecure/usergroupsync/UserGroupSync.java b/ugsync/src/main/java/com/xasecure/usergroupsync/UserGroupSync.java index 6456a96..81643da 100644 --- a/ugsync/src/main/java/com/xasecure/usergroupsync/UserGroupSync.java +++ b/ugsync/src/main/java/com/xasecure/usergroupsync/UserGroupSync.java @@ -19,13 +19,10 @@ package com.xasecure.usergroupsync; -import java.util.List; import org.apache.log4j.Logger; import com.xasecure.unixusersync.config.UserGroupSyncConfig; -import com.xasecure.unixusersync.process.PolicyMgrUserGroupBuilder; -import com.xasecure.unixusersync.process.UnixUserGroupBuilder; public class UserGroupSync implements Runnable { @@ -77,6 +74,8 @@ public class UserGroupSync implements Runnable { } } + boolean forceSync = false; + while (! shutdownFlag ) { try { Thread.sleep(sleepTimeBetweenCycleInMillis); @@ -85,12 +84,14 @@ public class UserGroupSync implements Runnable { } try { - syncUserGroup() ; + syncUserGroup(forceSync) ; + + forceSync = false; } catch(Throwable t) { LOG.error("Failed to synchronize UserGroup information. Error details: ", t) ; - System.exit(1); + forceSync = true; // force sync to the destination in the next attempt } } @@ -103,11 +104,11 @@ public class UserGroupSync implements Runnable { } } - private void syncUserGroup() throws Throwable { + private void syncUserGroup(boolean forceSync) throws Throwable { UserGroupSyncConfig config = UserGroupSyncConfig.getInstance() ; if (config.isUserSyncEnabled()) { - if (ugSource.isChanged()) { + if (forceSync || ugSource.isChanged()) { LOG.info("Begin: update user/group from source==>sink"); ugSource.updateSink(ugSink); LOG.info("End: update user/group from source==>sink");
