ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gau...@apache.org
Subject ranger git commit: RANGER-1548 : Display detailed error messages in Ranger for Audit store issues
Date Mon, 01 May 2017 19:37:11 GMT
Repository: ranger
Updated Branches:
  refs/heads/ranger-0.7 0a5265a54 -> ce7169f8f


RANGER-1548 : Display detailed error messages in Ranger for Audit store issues

Signed-off-by: Gautam Borad <gautam@apache.org>


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

Branch: refs/heads/ranger-0.7
Commit: ce7169f8f62fbadba516ea7af89a9ab9f9b5fb76
Parents: 0a5265a
Author: Ankita Sinha <ankita@apache.org>
Authored: Fri Apr 28 11:45:45 2017 +0530
Committer: Gautam Borad <gautam@apache.org>
Committed: Tue May 2 01:06:55 2017 +0530

----------------------------------------------------------------------
 .../java/org/apache/ranger/solr/SolrUtil.java   | 34 ++++++++++++--------
 1 file changed, 21 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ranger/blob/ce7169f8/security-admin/src/main/java/org/apache/ranger/solr/SolrUtil.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/solr/SolrUtil.java b/security-admin/src/main/java/org/apache/ranger/solr/SolrUtil.java
index 592b233..d17e581 100644
--- a/security-admin/src/main/java/org/apache/ranger/solr/SolrUtil.java
+++ b/security-admin/src/main/java/org/apache/ranger/solr/SolrUtil.java
@@ -63,19 +63,20 @@ public class SolrUtil {
 			try {
 				dateFormat.setTimeZone(TimeZone.getTimeZone(timeZone));
 			} catch (Throwable t) {
-				logger.error("Error setting timezone. timeZone=" + timeZone);
+                                logger.error("Error setting timezone. TimeZone = " + timeZone);
 			}
 		}
 	}
 
-	public QueryResponse runQuery(SolrClient solrClient, SolrQuery solrQuery) {
+        public QueryResponse runQuery(SolrClient solrClient, SolrQuery solrQuery) throws
Throwable {
 		if (solrQuery != null) {
-			QueryResponse response;
+                        QueryResponse response = null;
 			try {
 				response = solrClient.query(solrQuery, METHOD.POST);
 				return response;
 			} catch (Throwable e) {
-				logger.error("Error from Solr server.", e);
+                                logger.error("Error from Solr server. ", e);
+                                throw e;
 			}
 		}
 		return null;
@@ -107,7 +108,7 @@ public class SolrUtil {
 					}
 				} else if (searchField.getDataType() == SearchField.DATA_TYPE.DATE) {
 					if (!(paramValue instanceof Date)) {
-						logger.error("Search file is not of java object instanceof Date");
+                                                logger.error("Search field is not a Java
Date Object, paramValue = " + paramValue);
 					} else {
 						if (searchField.getSearchType() == SEARCH_TYPE.GREATER_EQUAL_THAN
 								|| searchField.getSearchType() == SEARCH_TYPE.GREATER_THAN) {
@@ -151,13 +152,20 @@ public class SolrUtil {
 		// Fields to get
 		// query.setFields("myClassType", "id", "score", "globalId");
 		if (logger.isDebugEnabled()) {
-			logger.debug("SOLR QUERY=" + query.toString());
+                        logger.debug("SOLR QUERY = " + query);
+                }
+                QueryResponse response = null;
+                try {
+                        response = runQuery(solrClient, query);
+                } catch(Throwable e) {
+                        logger.error("Error running solr query. Query = " + query
+                                        + ", response = " + response);
+                        throw restErrorUtil.createRESTException("Error running solr query,
please check solr configs. " + e.getMessage(),
+                                        MessageEnums.ERROR_SYSTEM);
 		}
-		QueryResponse response = runQuery(solrClient, query);
-
 		if (response == null || response.getStatus() != 0) {
-                        logger.error("Unable to connect to Audit store!! Error running query.
query=" + query.toString()
-					+ ", response=" + response);
+                        logger.error("Error running solr query. Query = " + query
+                                        + ", response = " + response);
                         throw restErrorUtil.createRESTException("Unable to connect to Audit
store !!",
 					MessageEnums.ERROR_SYSTEM);
 		}
@@ -297,7 +305,7 @@ public class SolrUtil {
 		try {
 			return Integer.valueOf(value.toString());
 		} catch (Throwable t) {
-			logger.error("Error converting value to integer. value=" + value, t);
+                        logger.error("Error converting value to integer. Value = " + value,
t);
 		}
 		return 0;
 	}
@@ -315,7 +323,7 @@ public class SolrUtil {
 		try {
 			return Long.valueOf(value.toString());
 		} catch (Throwable t) {
-			logger.error("Error converting value to long. value=" + value, t);
+                        logger.error("Error converting value to long. Value = " + value,
t);
 		}
 		return 0;
 	}
@@ -331,7 +339,7 @@ public class SolrUtil {
 			// TODO: Do proper parsing based on Solr response value
 			return new Date(value.toString());
 		} catch (Throwable t) {
-			logger.error("Error converting value to date. value=" + value, t);
+                        logger.error("Error converting value to date. Value = " + value,
t);
 		}
 		return null;
 	}


Mime
View raw message