You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by sy...@apache.org on 2017/01/04 07:39:41 UTC

[39/50] [abbrv] hbase git commit: HBASE-17374 ZKPermissionWatcher crashed when grant after region close (Liu Junhong)

HBASE-17374 ZKPermissionWatcher crashed when grant after region close (Liu Junhong)


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

Branch: refs/heads/hbase-12439
Commit: 001a26d404ca39ab6dbb9efeb59c08f20938f112
Parents: 05b1d91
Author: tedyu <yu...@gmail.com>
Authored: Wed Dec 28 19:54:01 2016 -0800
Committer: tedyu <yu...@gmail.com>
Committed: Wed Dec 28 19:54:01 2016 -0800

----------------------------------------------------------------------
 .../security/access/ZKPermissionWatcher.java    | 23 ++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/001a26d4/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/ZKPermissionWatcher.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/ZKPermissionWatcher.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/ZKPermissionWatcher.java
index 308ef41..f21e877 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/ZKPermissionWatcher.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/ZKPermissionWatcher.java
@@ -38,6 +38,7 @@ import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
+import java.util.concurrent.RejectedExecutionException;
 import java.util.concurrent.atomic.AtomicReference;
 
 /**
@@ -120,7 +121,7 @@ public class ZKPermissionWatcher extends ZooKeeperListener implements Closeable
   public void nodeCreated(String path) {
     waitUntilStarted();
     if (path.equals(aclZNode)) {
-      executor.submit(new Runnable() {
+      asyncProcessNodeUpdate(new Runnable() {
         @Override
         public void run() {
           try {
@@ -141,7 +142,7 @@ public class ZKPermissionWatcher extends ZooKeeperListener implements Closeable
   public void nodeDeleted(final String path) {
     waitUntilStarted();
     if (aclZNode.equals(ZKUtil.getParent(path))) {
-      executor.submit(new Runnable() {
+      asyncProcessNodeUpdate(new Runnable() {
         @Override
         public void run() {
           String table = ZKUtil.getNodeName(path);
@@ -159,7 +160,7 @@ public class ZKPermissionWatcher extends ZooKeeperListener implements Closeable
   public void nodeDataChanged(final String path) {
     waitUntilStarted();
     if (aclZNode.equals(ZKUtil.getParent(path))) {
-      executor.submit(new Runnable() {
+      asyncProcessNodeUpdate(new Runnable() {
         @Override
         public void run() {
           // update cache on an existing table node
@@ -198,7 +199,7 @@ public class ZKPermissionWatcher extends ZooKeeperListener implements Closeable
         LOG.error("Error reading data from zookeeper for path "+path, ke);
         watcher.abort("ZooKeeper error get node children for path "+path, ke);
       }
-      executor.submit(new Runnable() {
+      asyncProcessNodeUpdate(new Runnable() {
         // allows subsequent nodeChildrenChanged event to preempt current processing of
         // nodeChildrenChanged event
         @Override
@@ -211,6 +212,20 @@ public class ZKPermissionWatcher extends ZooKeeperListener implements Closeable
     }
   }
 
+  private void asyncProcessNodeUpdate(Runnable runnable) {
+    if (!executor.isShutdown()) {
+      try {
+        executor.submit(runnable);
+      } catch (RejectedExecutionException e) {
+        if (executor.isShutdown()) {
+          LOG.warn("aclZNode changed after ZKPermissionWatcher was shutdown");
+        } else {
+          throw e;
+        }
+      }
+    }
+  }
+
   private void refreshNodes(List<ZKUtil.NodeAndData> nodes, AtomicReference ref) {
     for (ZKUtil.NodeAndData n : nodes) {
       if (ref != null && ref.get() != null) {