ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ab...@apache.org
Subject ranger git commit: RANGER-2087: Use qualifiedName first to figure out HDFS path, clusterName and Ranger service-name from Atlas Hdfs entity
Date Thu, 26 Apr 2018 18:11:36 GMT
Repository: ranger
Updated Branches:
  refs/heads/master d9ace0393 -> fbaa4537c


RANGER-2087: Use qualifiedName first to figure out HDFS path, clusterName and Ranger service-name
from Atlas Hdfs entity


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

Branch: refs/heads/master
Commit: fbaa4537c6fb75b500c4917c76358cbd0cdf3877
Parents: d9ace03
Author: Abhay Kulkarni <akulkarni@hortonworks.com>
Authored: Thu Apr 26 10:50:26 2018 -0700
Committer: Abhay Kulkarni <akulkarni@hortonworks.com>
Committed: Thu Apr 26 10:50:26 2018 -0700

----------------------------------------------------------------------
 .../source/atlas/AtlasHdfsResourceMapper.java   | 37 ++++++++++----------
 1 file changed, 19 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ranger/blob/fbaa4537/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlas/AtlasHdfsResourceMapper.java
----------------------------------------------------------------------
diff --git a/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlas/AtlasHdfsResourceMapper.java
b/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlas/AtlasHdfsResourceMapper.java
index 8355c91..ef81d4a 100644
--- a/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlas/AtlasHdfsResourceMapper.java
+++ b/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlas/AtlasHdfsResourceMapper.java
@@ -35,14 +35,12 @@ public class AtlasHdfsResourceMapper extends AtlasResourceMapper {
 	public static final String TAGSYNC_ATLAS_NAME_SERVICE_IDENTIFIER = ".nameservice.";
 	public static final String ENTITY_TYPE_HDFS_CLUSTER_AND_NAME_SERVICE_SEPARATOR = "_";
 
-
 	public static final String ENTITY_ATTRIBUTE_PATH           = "path";
 	public static final String ENTITY_ATTRIBUTE_CLUSTER_NAME   = "clusterName";
 	public static final String ENTITY_ATTRIBUTE_NAME_SERVICE_ID   = "nameServiceId";
 
 	public static final String[] SUPPORTED_ENTITY_TYPES = { ENTITY_TYPE_HDFS_PATH };
 
-
 	public AtlasHdfsResourceMapper() {
 		super("hdfs", SUPPORTED_ENTITY_TYPES);
 	}
@@ -85,29 +83,32 @@ public class AtlasHdfsResourceMapper extends AtlasResourceMapper {
 
 	@Override
 	public RangerServiceResource buildResource(final RangerAtlasEntity entity) throws Exception
{
-		String path          = (String)entity.getAttributes().get(ENTITY_ATTRIBUTE_PATH);
-		String clusterName   = (String)entity.getAttributes().get(ENTITY_ATTRIBUTE_CLUSTER_NAME);
 		String qualifiedName = (String)entity.getAttributes().get(AtlasResourceMapper.ENTITY_ATTRIBUTE_QUALIFIED_NAME);
 		String nameServiceId = (String)entity.getAttributes().get(ENTITY_ATTRIBUTE_NAME_SERVICE_ID);
 
-		if(StringUtils.isEmpty(path)) {
-			path = getResourceNameFromQualifiedName(qualifiedName);
-
-			if(StringUtils.isEmpty(path)) {
-				throwExceptionWithMessage("path not found in attribute '" + ENTITY_ATTRIBUTE_PATH + "'
or '" + ENTITY_ATTRIBUTE_QUALIFIED_NAME +  "'");
-			}
-		}
+		String path          = null;
+		String clusterName   = null;
 
-		if(StringUtils.isEmpty(clusterName)) {
+		if (StringUtils.isNotEmpty(qualifiedName)) {
+			path = getResourceNameFromQualifiedName(qualifiedName);
 			clusterName = getClusterNameFromQualifiedName(qualifiedName);
+		}
 
-			if(StringUtils.isEmpty(clusterName)) {
-				clusterName = defaultClusterName;
-			}
+		if (StringUtils.isEmpty(path)) {
+			path = (String) entity.getAttributes().get(ENTITY_ATTRIBUTE_PATH);
+		}
+		if (StringUtils.isEmpty(path)) {
+			throwExceptionWithMessage("path not found in attribute '" + ENTITY_ATTRIBUTE_QUALIFIED_NAME
+ "' or '" + ENTITY_ATTRIBUTE_PATH +  "'");
+		}
 
-			if(StringUtils.isEmpty(clusterName)) {
-				throwExceptionWithMessage("attributes " + ENTITY_ATTRIBUTE_CLUSTER_NAME + ", " + ENTITY_ATTRIBUTE_QUALIFIED_NAME
+  "' not found in entity");
-			}
+		if (StringUtils.isEmpty(clusterName)) {
+			clusterName = (String) entity.getAttributes().get(ENTITY_ATTRIBUTE_CLUSTER_NAME);
+		}
+		if (StringUtils.isEmpty(clusterName)) {
+			clusterName = defaultClusterName;
+		}
+		if (StringUtils.isEmpty(clusterName)) {
+			throwExceptionWithMessage("clusterName not found in attribute '" + ENTITY_ATTRIBUTE_QUALIFIED_NAME
+ "' or '" + ENTITY_ATTRIBUTE_CLUSTER_NAME +  "'");
 		}
 
 		String  entityGuid  = entity.getGuid();


Mime
View raw message