sentry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asur...@apache.org
Subject incubator-sentry git commit: SENTRY-556: Remove NPE logging when Sentry Service is not reachable (Reviewed by: Lenni Kuff)
Date Mon, 01 Dec 2014 21:35:58 GMT
Repository: incubator-sentry
Updated Branches:
  refs/heads/master 3d3f96ca7 -> c5cc86a80


SENTRY-556: Remove NPE logging when Sentry Service is not reachable (Reviewed by: Lenni Kuff)


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

Branch: refs/heads/master
Commit: c5cc86a802ba5e17e78df9ee7671ca42bb1fe465
Parents: 3d3f96c
Author: Arun Suresh <asuresh@cloudera.com>
Authored: Mon Dec 1 13:35:44 2014 -0800
Committer: Arun Suresh <asuresh@cloudera.com>
Committed: Mon Dec 1 13:35:44 2014 -0800

----------------------------------------------------------------------
 .../sentry/hdfs/SentryAuthorizationInfo.java    | 63 ++++++++++++--------
 1 file changed, 38 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/c5cc86a8/sentry-hdfs/sentry-hdfs-namenode-plugin/src/main/java/org/apache/sentry/hdfs/SentryAuthorizationInfo.java
----------------------------------------------------------------------
diff --git a/sentry-hdfs/sentry-hdfs-namenode-plugin/src/main/java/org/apache/sentry/hdfs/SentryAuthorizationInfo.java
b/sentry-hdfs/sentry-hdfs-namenode-plugin/src/main/java/org/apache/sentry/hdfs/SentryAuthorizationInfo.java
index 3081ae1..c0889f2 100644
--- a/sentry-hdfs/sentry-hdfs-namenode-plugin/src/main/java/org/apache/sentry/hdfs/SentryAuthorizationInfo.java
+++ b/sentry-hdfs/sentry-hdfs-namenode-plugin/src/main/java/org/apache/sentry/hdfs/SentryAuthorizationInfo.java
@@ -100,30 +100,34 @@ public class SentryAuthorizationInfo implements Runnable {
     return authzPermissions;
   }
 
-  private void update() {
+  private boolean update() {
     SentryAuthzUpdate updates = updater.getUpdates();
-    UpdateableAuthzPaths newAuthzPaths = processUpdates(
-        updates.getPathUpdates(), authzPaths);
-    UpdateableAuthzPermissions newAuthzPerms = processUpdates(
-        updates.getPermUpdates(), authzPermissions);
-    // If there were any FULL updates the returned instance would be
-    // different
-    if ((newAuthzPaths != authzPaths)||(newAuthzPerms != authzPermissions)) {
-      lock.writeLock().lock();
-      try {
-        authzPaths = newAuthzPaths;
-        if (LOG.isDebugEnabled()) {
-          LOG.debug("FULL Updated paths seq Num [" + authzPaths.getLastUpdatedSeqNum() +
"]");
-        }
-        authzPermissions = newAuthzPerms;
-        if (LOG.isDebugEnabled()) {
-          LOG.debug("FULL Updated perms seq Num [" + authzPermissions.getLastUpdatedSeqNum()
+ "]");
+    // Updates can be null if Sentry Service is un-reachable
+    if (updates != null) {
+      UpdateableAuthzPaths newAuthzPaths = processUpdates(
+          updates.getPathUpdates(), authzPaths);
+      UpdateableAuthzPermissions newAuthzPerms = processUpdates(
+          updates.getPermUpdates(), authzPermissions);
+      // If there were any FULL updates the returned instance would be
+      // different
+      if ((newAuthzPaths != authzPaths)||(newAuthzPerms != authzPermissions)) {
+        lock.writeLock().lock();
+        try {
+          authzPaths = newAuthzPaths;
+          if (LOG.isDebugEnabled()) {
+            LOG.debug("FULL Updated paths seq Num [" + authzPaths.getLastUpdatedSeqNum()
+ "]");
+          }
+          authzPermissions = newAuthzPerms;
+          if (LOG.isDebugEnabled()) {
+            LOG.debug("FULL Updated perms seq Num [" + authzPermissions.getLastUpdatedSeqNum()
+ "]");
+          }
+        } finally {
+          lock.writeLock().unlock();
         }
-      } finally {
-        lock.writeLock().unlock();
       }
+      return true;
     }
-
+    return false;
   }
 
   private <K extends Update, V extends Updateable<K>> V processUpdates(List<K>
updates,
@@ -143,6 +147,7 @@ public class SentryAuthorizationInfo implements Runnable {
   }
 
   public void run() {
+    boolean success = false;
     try {
       // In case of previous preUpdate failure, we sleep for a retry wait 
       // interval we can do this because we are using a singledthreadedexecutor
@@ -151,24 +156,32 @@ public class SentryAuthorizationInfo implements Runnable {
       if (waitUntil > currTime) {
         Thread.sleep(waitUntil - currTime);
       }
-      update();
-      // we reset lastUpdate only on successful pulling
-      lastUpdate = System.currentTimeMillis();
-      waitUntil = lastUpdate;
+      success = update();
     } catch (Exception ex) {
+      success = false;
       LOG.warn("Failed to update, will retry in [{}]ms, error: ", 
           new Object[]{ retryWaitMillisec, ex.getMessage(), ex});
+    }
+    if (success) {
+      // we reset lastUpdate only on successful pulling
+      lastUpdate = System.currentTimeMillis();
+      waitUntil = lastUpdate;
+    } else {
       waitUntil = System.currentTimeMillis() + retryWaitMillisec;
     }
   }
 
   public void start() {
     if (authzPaths != null) {
+      boolean success = false;
       try {
-        update();
+        success = update();
       } catch (Exception ex) {
+        success = false;
         LOG.warn("Failed to do initial update, will retry in [{}]ms, error: ",
             new Object[]{retryWaitMillisec, ex.getMessage(), ex});
+      }
+      if (!success) {
         waitUntil = System.currentTimeMillis() + retryWaitMillisec;
       }
       executor = Executors.newSingleThreadScheduledExecutor(


Mime
View raw message