You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by ma...@apache.org on 2016/12/20 05:51:19 UTC

incubator-ranger git commit: RANGER-1251: Plugin status tracking: fix empty value for tag active version/time [Forced Update!]

Repository: incubator-ranger
Updated Branches:
  refs/heads/master 1b5147318 -> fcb9a9bc9 (forced update)


RANGER-1251: Plugin status tracking: fix empty value for tag active version/time


Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/fcb9a9bc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/fcb9a9bc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/fcb9a9bc

Branch: refs/heads/master
Commit: fcb9a9bc9a48aac62b29f8b3cdf26c8326c7a9a7
Parents: 7676341
Author: Abhay Kulkarni <ak...@hortonworks.com>
Authored: Wed Dec 14 21:08:09 2016 -0800
Committer: Madhan Neethiraj <ma...@apache.org>
Committed: Mon Dec 19 21:48:49 2016 -0800

----------------------------------------------------------------------
 .../java/org/apache/ranger/biz/AssetMgr.java    | 59 +++++++++++---------
 1 file changed, 32 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/fcb9a9bc/security-admin/src/main/java/org/apache/ranger/biz/AssetMgr.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/biz/AssetMgr.java b/security-admin/src/main/java/org/apache/ranger/biz/AssetMgr.java
index fbe846d..7e50fd5 100644
--- a/security-admin/src/main/java/org/apache/ranger/biz/AssetMgr.java
+++ b/security-admin/src/main/java/org/apache/ranger/biz/AssetMgr.java
@@ -750,23 +750,23 @@ public class AssetMgr extends AssetMgrBase {
 
 			boolean isPolicyInfo = pluginInfo.getPolicyDownloadedVersion() != null;
 
-			// If the ranger-admin is restarted, plugin contains latest version and there is no row for this pluginInfo
-			if (isPolicyInfo) {
-				if (pluginInfo.getPolicyDownloadedVersion().equals(pluginInfo.getPolicyActiveVersion())) {
-					// This is our best guess of when policies may have been downloaded
-					pluginInfo.setPolicyDownloadTime(pluginInfo.getPolicyActivationTime());
-				}
-			} else {
-				if (pluginInfo.getTagDownloadedVersion() != null && pluginInfo.getTagDownloadedVersion().equals(pluginInfo.getTagActiveVersion())) {
-					// This is our best guess of when tags may have been downloaded
-					pluginInfo.setTagDownloadTime(pluginInfo.getTagActivationTime());
-				}
-			}
-
 			XXPluginInfo xObj = rangerDaoManager.getXXPluginInfo().find(pluginInfo.getServiceName(),
 					pluginInfo.getHostName(), pluginInfo.getAppType());
 
 			if (xObj == null) {
+				// ranger-admin is restarted, plugin contains latest versions and no earlier record for this plug-in client
+				if (isPolicyInfo) {
+					if (pluginInfo.getPolicyDownloadedVersion().equals(pluginInfo.getPolicyActiveVersion())) {
+						// This is our best guess of when policies may have been downloaded
+						pluginInfo.setPolicyDownloadTime(pluginInfo.getPolicyActivationTime());
+					}
+				} else if (pluginInfo.getTagDownloadedVersion() != null) {
+					if (pluginInfo.getTagDownloadedVersion().equals(pluginInfo.getTagActiveVersion())) {
+						// This is our best guess of when tags may have been downloaded
+						pluginInfo.setTagDownloadTime(pluginInfo.getTagActivationTime());
+					}
+				}
+
 				xObj = pluginInfoService.populateDBObject(pluginInfo);
 
 				if (logger.isDebugEnabled()) {
@@ -790,37 +790,42 @@ public class AssetMgr extends AssetMgrBase {
 					Long lastKnownPolicyVersion = pluginInfo.getPolicyActiveVersion();
 					Long lastPolicyActivationTime = pluginInfo.getPolicyActivationTime();
 
+					if (lastKnownPolicyVersion != null && lastKnownPolicyVersion == -1) {
+						// First download request after plug-in's policy-refresher starts
+						dbObj.setPolicyDownloadTime(pluginInfo.getPolicyDownloadTime());
+						needsUpdating = true;
+					}
 					if (lastKnownPolicyVersion != null && lastKnownPolicyVersion > 0 && (dbObj.getPolicyActiveVersion() == null || !dbObj.getPolicyActiveVersion().equals(lastKnownPolicyVersion))) {
 						dbObj.setPolicyActiveVersion(lastKnownPolicyVersion);
-						if (lastPolicyActivationTime != null && lastPolicyActivationTime > 0) {
-							dbObj.setPolicyActivationTime(lastPolicyActivationTime);
-						}
 						needsUpdating = true;
-					} else if (lastKnownPolicyVersion != null && lastKnownPolicyVersion == -1) {
-						dbObj.setPolicyDownloadTime(pluginInfo.getPolicyDownloadTime());
-						dbObj.setPolicyActiveVersion(null);
-						dbObj.setPolicyActivationTime(null);
+					}
+					if (lastPolicyActivationTime != null && lastPolicyActivationTime > 0 && (dbObj.getPolicyActivationTime() == null || !dbObj.getPolicyActivationTime().equals(lastPolicyActivationTime))) {
+						dbObj.setPolicyActivationTime(lastPolicyActivationTime);
 						needsUpdating = true;
 					}
 				} else {
 					if (dbObj.getTagDownloadedVersion() == null || !dbObj.getTagDownloadedVersion().equals(pluginInfo.getTagDownloadedVersion())) {
+						// First download for tags after tag-service is associated with resource-service
 						dbObj.setTagDownloadedVersion(pluginInfo.getTagDownloadedVersion());
 						dbObj.setTagDownloadTime(pluginInfo.getTagDownloadTime());
 						needsUpdating = true;
 					}
+
 					Long lastKnownTagVersion = pluginInfo.getTagActiveVersion();
 					Long lastTagActivationTime = pluginInfo.getTagActivationTime();
 
+					if (lastKnownTagVersion != null && lastKnownTagVersion == -1) {
+						// First download request after plug-in's tag-refresher restarts
+						dbObj.setTagDownloadTime(pluginInfo.getTagDownloadTime());
+						needsUpdating = true;
+					}
 					if (lastKnownTagVersion != null && lastKnownTagVersion > 0 && (dbObj.getTagActiveVersion() == null || !dbObj.getTagActiveVersion().equals(lastKnownTagVersion))) {
 						dbObj.setTagActiveVersion(lastKnownTagVersion);
-						if (lastTagActivationTime != null && lastTagActivationTime > 0) {
-							dbObj.setTagActivationTime(lastTagActivationTime);
-						}
 						needsUpdating = true;
-					} else if (lastKnownTagVersion != null && lastKnownTagVersion == -1) {
-						dbObj.setTagDownloadTime(pluginInfo.getTagDownloadTime());
-						dbObj.setTagActiveVersion(null);
-						dbObj.setTagActivationTime(null);
+					}
+
+					if (lastTagActivationTime != null && lastTagActivationTime > 0 && (dbObj.getTagActivationTime() == null || !dbObj.getTagActivationTime().equals(lastTagActivationTime))) {
+						dbObj.setTagActivationTime(lastTagActivationTime);
 						needsUpdating = true;
 					}
 				}