ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From v..@apache.org
Subject incubator-ranger git commit: RANGER-1104: Catching and Logging DB transaction exceptions during Ranger startup
Date Sun, 17 Jul 2016 12:53:52 GMT
Repository: incubator-ranger
Updated Branches:
  refs/heads/master 87fe3446d -> e3d50db85


RANGER-1104: Catching and Logging DB transaction exceptions during Ranger startup

Signed-off-by: Velmurugan Periasamy <vel@apache.org>


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

Branch: refs/heads/master
Commit: e3d50db85c289f30f71ba3ba27eb23192a554281
Parents: 87fe344
Author: Sailaja Polavarapu <spolavarapu@hortonworks.com>
Authored: Fri Jul 15 13:48:33 2016 -0700
Committer: Velmurugan Periasamy <vel@apache.org>
Committed: Sun Jul 17 08:53:41 2016 -0400

----------------------------------------------------------------------
 .../org/apache/ranger/biz/ServiceDBStore.java   | 36 +++++++++++---------
 1 file changed, 20 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/e3d50db8/security-admin/src/main/java/org/apache/ranger/biz/ServiceDBStore.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/biz/ServiceDBStore.java b/security-admin/src/main/java/org/apache/ranger/biz/ServiceDBStore.java
index 9af5b5f..7947d4b 100644
--- a/security-admin/src/main/java/org/apache/ranger/biz/ServiceDBStore.java
+++ b/security-admin/src/main/java/org/apache/ranger/biz/ServiceDBStore.java
@@ -279,15 +279,18 @@ public class ServiceDBStore extends AbstractServiceStore {
 					final ServiceDBStore dbStore = this;
 					predicateUtil = new ServicePredicateUtil(dbStore);
 
-
-					txTemplate.execute(new TransactionCallback<Object>() {
-						@Override
-	                    public Object doInTransaction(TransactionStatus status) {
-							EmbeddedServiceDefsUtil.instance().init(dbStore);
-							getServiceUpgraded();
-							return null;
-	                    }
-					});
+					try {
+						txTemplate.execute(new TransactionCallback<Object>() {
+							@Override
+							public Object doInTransaction(TransactionStatus status) {
+								EmbeddedServiceDefsUtil.instance().init(dbStore);
+								getServiceUpgraded();
+								return null;
+							}
+						});
+					} catch (Throwable ex) {
+						LOG.fatal("ServiceDefDBStore.initStore(): Failed to update DB: " + ex);
+					}
 
 					legacyServiceDefsInitDone = true;
 				}
@@ -1507,7 +1510,6 @@ public class ServiceDBStore extends AbstractServiceStore {
 			service.setCreateTime(existing.getCreateTime());
 			service.setGuid(existing.getGuid());
 			service.setVersion(existing.getVersion());
-
 			service = svcService.update(service);
 
 			if (hasTagServiceValueChanged || hasIsEnabledChanged) {
@@ -1698,9 +1700,7 @@ public class ServiceDBStore extends AbstractServiceStore {
 		}
 
 		RangerServiceList serviceList = svcService.searchRangerServices(filter);
-
 		predicateUtil.applyFilter(serviceList.getServices(), filter);
-
 		List<RangerService> ret = serviceList.getServices();
 
 		if (LOG.isDebugEnabled()) {
@@ -3749,7 +3749,9 @@ public class ServiceDBStore extends AbstractServiceStore {
 		}
 	}
 	public void getServiceUpgraded(){
+		LOG.info("==> ServiceDBStore.getServiceUpgraded()");
 		updateServiceWithCustomProperty();
+		LOG.info("<== ServiceDBStore.getServiceUpgraded()");
 	}
 	private void updateServiceWithCustomProperty() {		
 			LOG.info("Adding custom properties to services");
@@ -3760,6 +3762,7 @@ public class ServiceDBStore extends AbstractServiceStore {
 					String serviceUser = PropertiesUtil.getProperty("ranger.plugins."+rangerService.getType()+".serviceuser");
 					if(!StringUtils.isEmpty(serviceUser)){
 						boolean chkServiceUpdate = false;
+						LOG.debug("customproperty = " + rangerService.getConfigs().get(ServiceREST.Allowed_User_List_For_Download)
+ " for service = " + rangerService.getName());
 						if(!rangerService.getConfigs().containsKey(ServiceREST.Allowed_User_List_For_Download)){
 							rangerService.getConfigs().put(ServiceREST.Allowed_User_List_For_Download, serviceUser);
 							chkServiceUpdate = true;
@@ -3773,15 +3776,16 @@ public class ServiceDBStore extends AbstractServiceStore {
 							chkServiceUpdate = true;
 		                }
 		                if(chkServiceUpdate){
-							updateService(rangerService);
+		                	updateService(rangerService);
 							if(LOG.isDebugEnabled()){
 								LOG.debug("Updated service "+rangerService.getName()+" with custom properties in
secure environment");
 							}
 		                }
 					}
 				}
-			} catch (Exception e) {
-				LOG.error("Error getting Services : "+e.getMessage());
-			}		
+			} catch (Throwable e) {
+				LOG.fatal("updateServiceWithCustomProperty failed with exception : "+e.getMessage());
+				return;
+			}
 	}
 }


Mime
View raw message