ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mad...@apache.org
Subject incubator-ranger git commit: RANGER-523: updated sequence of embedded service-def creation
Date Wed, 03 Jun 2015 02:47:26 GMT
Repository: incubator-ranger
Updated Branches:
  refs/heads/master e7be55f7b -> 4c4567182


RANGER-523: updated sequence of embedded service-def creation


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

Branch: refs/heads/master
Commit: 4c4567182f467d5301b78e214e551801e374faaa
Parents: e7be55f
Author: Madhan Neethiraj <madhan@apache.org>
Authored: Tue Jun 2 19:21:16 2015 -0700
Committer: Madhan Neethiraj <madhan@apache.org>
Committed: Tue Jun 2 19:21:16 2015 -0700

----------------------------------------------------------------------
 .../plugin/store/EmbeddedServiceDefsUtil.java   | 38 +++++++++++---------
 .../org/apache/ranger/common/AppConstants.java  | 18 +++++-----
 .../org/apache/ranger/common/ServiceUtil.java   |  4 +--
 3 files changed, 32 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/4c456718/agents-common/src/main/java/org/apache/ranger/plugin/store/EmbeddedServiceDefsUtil.java
----------------------------------------------------------------------
diff --git a/agents-common/src/main/java/org/apache/ranger/plugin/store/EmbeddedServiceDefsUtil.java
b/agents-common/src/main/java/org/apache/ranger/plugin/store/EmbeddedServiceDefsUtil.java
index e3ecc0f..77e2c80 100755
--- a/agents-common/src/main/java/org/apache/ranger/plugin/store/EmbeddedServiceDefsUtil.java
+++ b/agents-common/src/main/java/org/apache/ranger/plugin/store/EmbeddedServiceDefsUtil.java
@@ -46,23 +46,23 @@ public class EmbeddedServiceDefsUtil {
 	public static final String EMBEDDED_SERVICEDEF_HDFS_NAME  = "hdfs";
 	public static final String EMBEDDED_SERVICEDEF_HBASE_NAME = "hbase";
 	public static final String EMBEDDED_SERVICEDEF_HIVE_NAME  = "hive";
+	public static final String EMBEDDED_SERVICEDEF_KMS_NAME   = "kms";
 	public static final String EMBEDDED_SERVICEDEF_KNOX_NAME  = "knox";
 	public static final String EMBEDDED_SERVICEDEF_STORM_NAME = "storm";
 	public static final String EMBEDDED_SERVICEDEF_YARN_NAME  = "yarn";
-	public static final String EMBEDDED_SERVICEDEF_KMS_NAME  = "kms";
-	public static final String EMBEDDED_SERVICEDEF_KAFKA_NAME  = "kafka";
+	public static final String EMBEDDED_SERVICEDEF_KAFKA_NAME = "kafka";
 	public static final String EMBEDDED_SERVICEDEF_SOLR_NAME  = "solr";
 	public static final String PROPERTY_CREATE_EMBEDDED_SERVICE_DEFS = "ranger.service.store.create.embedded.service-defs";
 
-	public static final String HDFS_IMPL_CLASS_NAME = "org.apache.ranger.services.hdfs.RangerServiceHdfs";
+	public static final String HDFS_IMPL_CLASS_NAME  = "org.apache.ranger.services.hdfs.RangerServiceHdfs";
 	public static final String HBASE_IMPL_CLASS_NAME = "org.apache.ranger.services.hbase.RangerServiceHBase";
-	public static final String HIVE_IMPL_CLASS_NAME = "org.apache.ranger.services.hive.RangerServiceHive";
-	public static final String KNOX_IMPL_CLASS_NAME = "org.apache.ranger.services.knox.RangerServiceKnox";
+	public static final String HIVE_IMPL_CLASS_NAME  = "org.apache.ranger.services.hive.RangerServiceHive";
+	public static final String KMS_IMPL_CLASS_NAME   = "org.apache.ranger.services.kms.RangerServiceKMS";
+	public static final String KNOX_IMPL_CLASS_NAME  = "org.apache.ranger.services.knox.RangerServiceKnox";
 	public static final String STORM_IMPL_CLASS_NAME = "org.apache.ranger.services.storm.RangerServiceStorm";
-	public static final String YARN_IMPL_CLASS_NAME = "org.apache.ranger.services.yarn.RangerServiceYarn";
-	public static final String KMS_IMPL_CLASS_NAME = "org.apache.ranger.services.kms.RangerServiceKMS";
+	public static final String YARN_IMPL_CLASS_NAME  = "org.apache.ranger.services.yarn.RangerServiceYarn";
 	public static final String KAFKA_IMPL_CLASS_NAME = "org.apache.ranger.services.kafka.RangerServiceKafka";
-	public static final String SOLR_IMPL_CLASS_NAME = "org.apache.ranger.services.solr.RangerServiceSolr";
+	public static final String SOLR_IMPL_CLASS_NAME  = "org.apache.ranger.services.solr.RangerServiceSolr";
 
 	private static EmbeddedServiceDefsUtil instance = new EmbeddedServiceDefsUtil();
 
@@ -70,11 +70,11 @@ public class EmbeddedServiceDefsUtil {
 	private RangerServiceDef hdfsServiceDef  = null;
 	private RangerServiceDef hBaseServiceDef = null;
 	private RangerServiceDef hiveServiceDef  = null;
+	private RangerServiceDef kmsServiceDef   = null;
 	private RangerServiceDef knoxServiceDef  = null;
 	private RangerServiceDef stormServiceDef = null;
 	private RangerServiceDef yarnServiceDef  = null;
-	private RangerServiceDef kmsServiceDef  = null;
-	private RangerServiceDef kafkaServiceDef  = null;
+	private RangerServiceDef kafkaServiceDef = null;
 	private RangerServiceDef solrServiceDef  = null;
 
 	private Gson gsonBuilder = null;
@@ -96,14 +96,18 @@ public class EmbeddedServiceDefsUtil {
 
 			gsonBuilder = new GsonBuilder().setDateFormat("yyyyMMdd-HH:mm:ss.SSS-Z").setPrettyPrinting().create();
 
+			/*
+			 * Maintaining the following service-def create-order is critical for the 
+			 * the legacy service-defs (HDFS/HBase/Hive/Knox/Storm) to be assigned IDs
+			 * that were used in earlier version (0.4) */
 			hdfsServiceDef  = getOrCreateServiceDef(store, EMBEDDED_SERVICEDEF_HDFS_NAME);
 			hBaseServiceDef = getOrCreateServiceDef(store, EMBEDDED_SERVICEDEF_HBASE_NAME);
 			hiveServiceDef  = getOrCreateServiceDef(store, EMBEDDED_SERVICEDEF_HIVE_NAME);
+			kmsServiceDef   = getOrCreateServiceDef(store, EMBEDDED_SERVICEDEF_KMS_NAME);
 			knoxServiceDef  = getOrCreateServiceDef(store, EMBEDDED_SERVICEDEF_KNOX_NAME);
 			stormServiceDef = getOrCreateServiceDef(store, EMBEDDED_SERVICEDEF_STORM_NAME);
 			yarnServiceDef  = getOrCreateServiceDef(store, EMBEDDED_SERVICEDEF_YARN_NAME);
-			kmsServiceDef  = getOrCreateServiceDef(store, EMBEDDED_SERVICEDEF_KMS_NAME);
-			kafkaServiceDef  = getOrCreateServiceDef(store, EMBEDDED_SERVICEDEF_KAFKA_NAME);
+			kafkaServiceDef = getOrCreateServiceDef(store, EMBEDDED_SERVICEDEF_KAFKA_NAME);
 			solrServiceDef  = getOrCreateServiceDef(store, EMBEDDED_SERVICEDEF_SOLR_NAME);
 		} catch(Throwable excp) {
 			LOG.fatal("EmbeddedServiceDefsUtil.init(): failed", excp);
@@ -124,6 +128,10 @@ public class EmbeddedServiceDefsUtil {
 		return getId(hiveServiceDef);
 	}
 
+	public long getKmsServiceDefId() {
+		return getId(kmsServiceDef);
+	}
+
 	public long getKnoxServiceDefId() {
 		return getId(knoxServiceDef);
 	}
@@ -136,10 +144,6 @@ public class EmbeddedServiceDefsUtil {
 		return getId(yarnServiceDef);
 	}
 	
-	public long getKmsServiceDefId() {
-		return getId(kmsServiceDef);
-	}
-	
 	public long getKafkaServiceDefId() {
 		return getId(kafkaServiceDef);
 	}
@@ -165,7 +169,7 @@ public class EmbeddedServiceDefsUtil {
 				ret = loadEmbeddedServiceDef(serviceDefName);
 
 				LOG.info("creating embedded service-def " + serviceDefName);
-				store.createServiceDef(ret);
+				ret = store.createServiceDef(ret);
 			}
 		} catch(Exception excp) {
 			LOG.fatal("EmbeddedServiceDefsUtil.getOrCreateServiceDef(): failed to load/create serviceType
" + serviceDefName, excp);

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/4c456718/security-admin/src/main/java/org/apache/ranger/common/AppConstants.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/common/AppConstants.java b/security-admin/src/main/java/org/apache/ranger/common/AppConstants.java
index b97f666..d58f221 100644
--- a/security-admin/src/main/java/org/apache/ranger/common/AppConstants.java
+++ b/security-admin/src/main/java/org/apache/ranger/common/AppConstants.java
@@ -505,14 +505,6 @@ public class AppConstants extends RangerCommonEnums {
 	 * CLASS_TYPE_XA_SERVICE_DEF is an element of enum ClassTypes. Its value is "CLASS_TYPE_XA_SERVICE_DEF".
 	 */
 	public static final int CLASS_TYPE_XA_SERVICE_DEF = 1033;
-	/**
-	 * CLASS_TYPE_RANGER_POLICY_WITH_ASSIGNED_ID is an element of enum ClassTypes. Its value
is "CLASS_TYPE_RANGER_POLICY_WITH_ASSIGNED_ID".
-	 */
-	public static final int CLASS_TYPE_RANGER_POLICY_WITH_ASSIGNED_ID = 1037;
-	/**
-	 * CLASS_TYPE_RANGER_SERVICE_WITH_ASSIGNED_ID is an element of enum ClassTypes. Its value
is "CLASS_TYPE_RANGER_SERVICE_WITH_ASSIGNED_ID".
-	 */
-	public static final int CLASS_TYPE_RANGER_SERVICE_WITH_ASSIGNED_ID = 1038;
 
 	/**
 	 * CLASS_TYPE_RANGER_MODULE_DEF is an element of enum ClassTypes. Its value is "CLASS_TYPE_RANGER_MODULE_DEF".
@@ -530,11 +522,19 @@ public class AppConstants extends RangerCommonEnums {
 	 * CLASS_TYPE_XA_KMS_KEY is an element of enum ClassTypes. Its value is "CLASS_TYPE_XA_KMS_KEY".
 	 */
 	public static final int CLASS_TYPE_XA_KMS_KEY = 1037;	
+	/**
+	 * CLASS_TYPE_RANGER_POLICY_WITH_ASSIGNED_ID is an element of enum ClassTypes. Its value
is "CLASS_TYPE_RANGER_POLICY_WITH_ASSIGNED_ID".
+	 */
+	public static final int CLASS_TYPE_RANGER_POLICY_WITH_ASSIGNED_ID = 1038;
+	/**
+	 * CLASS_TYPE_RANGER_SERVICE_WITH_ASSIGNED_ID is an element of enum ClassTypes. Its value
is "CLASS_TYPE_RANGER_SERVICE_WITH_ASSIGNED_ID".
+	 */
+	public static final int CLASS_TYPE_RANGER_SERVICE_WITH_ASSIGNED_ID = 1039;
 
 	/**
 	 * Max value for enum ClassTypes_MAX
 	 */
-	public static final int ClassTypes_MAX = 1037;
+	public static final int ClassTypes_MAX = 1039;
 	
 	/***************************************************************
 	 * Enum values for Default SortOrder

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/4c456718/security-admin/src/main/java/org/apache/ranger/common/ServiceUtil.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/common/ServiceUtil.java b/security-admin/src/main/java/org/apache/ranger/common/ServiceUtil.java
index b7a923b..2a84d6c 100644
--- a/security-admin/src/main/java/org/apache/ranger/common/ServiceUtil.java
+++ b/security-admin/src/main/java/org/apache/ranger/common/ServiceUtil.java
@@ -1310,8 +1310,8 @@ public class ServiceUtil {
 					MessageEnums.DATA_NOT_FOUND);
 		}
 		if(service==null){
-			LOG.error("Requested Service not found. Service name is null.");
-			throw restErrorUtil.createRESTException("No Data Found.",
+			LOG.error("Requested Service not found. serviceName=" + serviceName);
+			throw restErrorUtil.createRESTException("Serivce:" + serviceName + " not found",
 					MessageEnums.DATA_NOT_FOUND);
 		}
 		if(!service.getIsEnabled()){


Mime
View raw message