Repository: sentry
Updated Branches:
  refs/heads/sentry-ha-redesign 049308d9e -> 13c3305de


http://git-wip-us.apache.org/repos/asf/sentry/blob/13c3305d/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/HMSFollower.java
----------------------------------------------------------------------
diff --git 
a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/HMSFollower.java
 
b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/HMSFollower.java
index 0baa1a2..f3cefd6 100644
--- 
a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/HMSFollower.java
+++ 
b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/HMSFollower.java
@@ -32,7 +32,6 @@ import org.apache.sentry.binding.hive.conf.HiveAuthzConf;
 import org.apache.sentry.core.common.exception.*;
 import org.apache.sentry.hdfs.UpdateableAuthzPaths;
 import org.apache.sentry.hdfs.FullUpdateInitializer;
-import org.apache.sentry.hdfs.ServiceConstants.ServerConfig;
 import org.apache.sentry.provider.db.service.persistent.SentryStore;
 import org.apache.sentry.provider.db.service.thrift.TSentryAuthorizable;
 import org.apache.thrift.TException;
@@ -43,11 +42,9 @@ import org.apache.sentry.binding.metastore.messaging.json.*;
 import javax.security.auth.Subject;
 import javax.security.auth.login.LoginException;
 import java.io.File;
-import java.io.IOException;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
 import java.util.List;
-import java.util.concurrent.atomic.AtomicBoolean;
 
 import static 
org.apache.sentry.binding.hive.conf.HiveAuthzConf.AuthzConfVars.AUTHZ_SYNC_CREATE_WITH_POLICY_STORE;
 import static 
org.apache.sentry.binding.hive.conf.HiveAuthzConf.AuthzConfVars.AUTHZ_SYNC_DROP_WITH_POLICY_STORE;
@@ -76,8 +73,7 @@ public class HMSFollower implements Runnable {
   private volatile UpdateableAuthzPaths authzPaths;
   private boolean needHiveSnapshot = true;
 
-  HMSFollower(Configuration conf) throws SentryNoSuchObjectException,
-      SentryAccessDeniedException, SentrySiteConfigurationException, 
IOException { //TODO: Handle any possible exceptions or throw specific 
exceptions
+  HMSFollower(Configuration conf) throws Exception { //TODO: Handle any 
possible exceptions or throw specific exceptions
     LOGGER.info("HMSFollower is being initialized");
     authzConf = conf;
     sentryStore = new SentryStore(authzConf);
@@ -319,7 +315,7 @@ public class HMSFollower implements Runnable {
               dropSentryDbPrivileges(dbName);
             } catch (SentryNoSuchObjectException e) {
                 LOGGER.info("Drop Sentry privilege ignored as there are no 
privileges on the database: %s", dbName);
-            } catch (SentryInvalidInputException e) {
+            } catch (Exception e) {
               throw new SentryInvalidInputException("Could not process Create 
database event. Event: " + event.toString(), e);
             }
           }
@@ -337,7 +333,7 @@ public class HMSFollower implements Runnable {
               dropSentryDbPrivileges(dbName);
             } catch (SentryNoSuchObjectException e) {
               LOGGER.info("Drop Sentry privilege ignored as there are no 
privileges on the database: %s", dbName);
-            } catch (SentryInvalidInputException e) {
+            } catch (Exception e) {
               throw new SentryInvalidInputException("Could not process Drop 
database event. Event: " + event.toString(), e);
             }
           }
@@ -357,7 +353,7 @@ public class HMSFollower implements Runnable {
               dropSentryTablePrivileges(dbName, tableName);
             } catch (SentryNoSuchObjectException e) {
               LOGGER.info("Drop Sentry privilege ignored as there are no 
privileges on the table: %s.%s", dbName, tableName);
-            } catch (SentryInvalidInputException e) {
+            } catch (Exception e) {
               throw new SentryInvalidInputException("Could not process Create 
table event. Event: " + event.toString(), e);
             }
           }
@@ -376,7 +372,7 @@ public class HMSFollower implements Runnable {
               dropSentryTablePrivileges(dbName, tableName);
             } catch (SentryNoSuchObjectException e) {
               LOGGER.info("Drop Sentry privilege ignored as there are no 
privileges on the table: %s.%s", dbName, tableName);
-            } catch (SentryInvalidInputException e) {
+            } catch (Exception e) {
               throw new SentryInvalidInputException("Could not process Drop 
table event. Event: " + event.toString(), e);
             }
           }
@@ -416,7 +412,7 @@ public class HMSFollower implements Runnable {
               renamePrivileges(oldDbName, oldTableName, newDbName, 
newTableName);
             } catch (SentryNoSuchObjectException e) {
               LOGGER.info("Rename Sentry privilege ignored as there are no 
privileges on the table: %s.%s", oldDbName, oldTableName);
-            } catch (SentryInvalidInputException e) {
+            } catch (Exception e) {
               throw new SentryInvalidInputException("Could not process Alter 
table event. Event: " + event.toString(), e);
             }
           } else if(!oldLocation.equals(newLocation)) { // Only Location has 
changed{
@@ -439,20 +435,19 @@ public class HMSFollower implements Runnable {
     }
   }
 
-  private void dropSentryDbPrivileges(String dbName) throws 
SentryNoSuchObjectException, SentryInvalidInputException {
+  private void dropSentryDbPrivileges(String dbName) throws Exception {
     TSentryAuthorizable authorizable = new TSentryAuthorizable(hiveInstance);
     authorizable.setDb(dbName);
     sentryStore.dropPrivilege(authorizable);
   }
-  private void dropSentryTablePrivileges(String dbName, String tableName) 
throws SentryNoSuchObjectException,
-      SentryInvalidInputException {
+  private void dropSentryTablePrivileges(String dbName, String tableName) 
throws Exception {
     TSentryAuthorizable authorizable = new TSentryAuthorizable(hiveInstance);
     authorizable.setDb(dbName);
     authorizable.setTable(tableName);
     sentryStore.dropPrivilege(authorizable);
   }
   private void renamePrivileges(String oldDbName, String oldTableName, String 
newDbName, String newTableName) throws
-      SentryNoSuchObjectException, SentryInvalidInputException {
+      Exception {
     TSentryAuthorizable oldAuthorizable = new 
TSentryAuthorizable(hiveInstance);
     oldAuthorizable.setDb(oldDbName);
     oldAuthorizable.setTable(oldTableName);

http://git-wip-us.apache.org/repos/asf/sentry/blob/13c3305d/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/ServiceConstants.java
----------------------------------------------------------------------
diff --git 
a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/ServiceConstants.java
 
b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/ServiceConstants.java
index f98ebd1..a249904 100644
--- 
a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/ServiceConstants.java
+++ 
b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/ServiceConstants.java
@@ -85,6 +85,15 @@ public class ServiceConstants {
     public static final String SENTRY_STORE_JDBC_PASS = 
"sentry.store.jdbc.password";
     public static final String SENTRY_STORE_JDBC_DRIVER = 
"sentry.store.jdbc.driver";
     public static final String SENTRY_STORE_JDBC_DRIVER_DEFAULT = 
"org.apache.derby.jdbc.EmbeddedDriver";
+    // The configuration for the maximum number of retries per db transaction,
+    // the default value is 3 times
+    public static final String SENTRY_STORE_TRANSACTION_RETRY = 
"sentry.store.transaction.retry";
+    public static final int SENTRY_STORE_TRANSACTION_RETRY_DEFAULT = 3;
+    // The configuration for the delay (in milliseconds) between retries,
+    // the default value is 500 ms
+    public static final String SENTRY_STORE_TRANSACTION_RETRY_WAIT_TIME_MILLIS 
=
+        "sentry.store.transaction.retry.wait.time.millis";
+    public static final int 
SENTRY_STORE_TRANSACTION_RETRY_WAIT_TIME_MILLIS_DEFAULT = 500;
 
     public static final String JAVAX_JDO_URL = 
"javax.jdo.option.ConnectionURL";
     public static final String JAVAX_JDO_USER = 
"javax.jdo.option.ConnectionUserName";

http://git-wip-us.apache.org/repos/asf/sentry/blob/13c3305d/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/generic/service/persistent/SentryStoreIntegrationBase.java
----------------------------------------------------------------------
diff --git 
a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/generic/service/persistent/SentryStoreIntegrationBase.java
 
b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/generic/service/persistent/SentryStoreIntegrationBase.java
index f14b586..d8d1261 100644
--- 
a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/generic/service/persistent/SentryStoreIntegrationBase.java
+++ 
b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/generic/service/persistent/SentryStoreIntegrationBase.java
@@ -60,7 +60,7 @@ public abstract class SentryStoreIntegrationBase {
   }
 
   @After
-  public void clearData() {
+  public void clearData() throws Exception{
     sentryStore.clearAllTables();
   }
 

http://git-wip-us.apache.org/repos/asf/sentry/blob/13c3305d/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/generic/service/persistent/TestPrivilegeOperatePersistence.java
----------------------------------------------------------------------
diff --git 
a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/generic/service/persistent/TestPrivilegeOperatePersistence.java
 
b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/generic/service/persistent/TestPrivilegeOperatePersistence.java
index 799d5ef..34c2107 100644
--- 
a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/generic/service/persistent/TestPrivilegeOperatePersistence.java
+++ 
b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/generic/service/persistent/TestPrivilegeOperatePersistence.java
@@ -26,7 +26,6 @@ import java.util.List;
 
 import com.google.common.collect.Lists;
 import org.apache.hadoop.conf.Configuration;
-import org.apache.sentry.core.common.exception.SentryUserException;
 import org.apache.sentry.core.common.Authorizable;
 import org.apache.sentry.core.common.BitFieldAction;
 import org.apache.sentry.core.common.BitFieldActionFactory;
@@ -976,12 +975,12 @@ public class TestPrivilegeOperatePersistence extends 
SentryStoreIntegrationBase
         Sets.newHashSet(roleName1,roleName2, roleName3), null).size());
   }
 
-  @Test(expected = RuntimeException.class)
-  public void testGrantPrivilegeExternalComponentMissingConf() throws 
SentryUserException {
+  @Test(expected = Exception.class)
+  public void testGrantPrivilegeExternalComponentMissingConf() throws 
Exception {
     testGrantPrivilege(sentryStore, "externalComponent");
   }
 
-  @Test(expected = RuntimeException.class)
+  @Test(expected = Exception.class)
   public void testGrantPrivilegeExternalComponentInvalidConf() throws 
Exception {
     String externalComponent = "mycomponent";
     Configuration confCopy = new Configuration(conf);
@@ -1011,7 +1010,7 @@ public class TestPrivilegeOperatePersistence extends 
SentryStoreIntegrationBase
     testGrantPrivilege(store, externalComponent);
   }
 
-  private void testGrantPrivilege(SentryStoreLayer sentryStore, String 
component) throws SentryUserException {
+  private void testGrantPrivilege(SentryStoreLayer sentryStore, String 
component) throws Exception {
     String roleName = "r1";
     /**
      * grantor is admin, there is no need to check grant option

Reply via email to