You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by el...@apache.org on 2014/10/20 03:05:55 UTC

[14/16] git commit: ACCUMULO-3242 Some general code cleanup. Unnecessary javadoc and duplicative ZooReaderWriter.getInstance() calls

ACCUMULO-3242 Some general code cleanup. Unnecessary javadoc and duplicative ZooReaderWriter.getInstance() calls


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

Branch: refs/heads/master
Commit: 0e4159c3f389b71c36f81e07dce0e541ec40b183
Parents: 423cf10
Author: Josh Elser <el...@apache.org>
Authored: Sun Oct 19 20:36:08 2014 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Sun Oct 19 20:36:08 2014 -0400

----------------------------------------------------------------------
 .../fate/zookeeper/IZooReaderWriter.java        |  1 -
 .../server/security/handler/ZKPermHandler.java  | 24 +++++++++++---------
 2 files changed, 13 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/0e4159c3/fate/src/main/java/org/apache/accumulo/fate/zookeeper/IZooReaderWriter.java
----------------------------------------------------------------------
diff --git a/fate/src/main/java/org/apache/accumulo/fate/zookeeper/IZooReaderWriter.java b/fate/src/main/java/org/apache/accumulo/fate/zookeeper/IZooReaderWriter.java
index 2f3ed62..5b0a304 100644
--- a/fate/src/main/java/org/apache/accumulo/fate/zookeeper/IZooReaderWriter.java
+++ b/fate/src/main/java/org/apache/accumulo/fate/zookeeper/IZooReaderWriter.java
@@ -65,7 +65,6 @@ public interface IZooReaderWriter extends IZooReader {
 
   void mkdirs(String path) throws KeeperException, InterruptedException;
 
-  @Override
   void sync(String path) throws KeeperException, InterruptedException;
 
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/0e4159c3/server/base/src/main/java/org/apache/accumulo/server/security/handler/ZKPermHandler.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/security/handler/ZKPermHandler.java b/server/base/src/main/java/org/apache/accumulo/server/security/handler/ZKPermHandler.java
index 3cac2e9..be4806b 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/security/handler/ZKPermHandler.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/security/handler/ZKPermHandler.java
@@ -45,7 +45,7 @@ import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.KeeperException.Code;
 
 /**
- * 
+ *
  */
 public class ZKPermHandler implements PermissionHandler {
   private static final Logger log = Logger.getLogger(ZKAuthorizor.class);
@@ -79,16 +79,17 @@ public class ZKPermHandler implements PermissionHandler {
   @Override
   public boolean hasTablePermission(String user, String table, TablePermission permission) throws TableNotFoundException {
     byte[] serializedPerms;
+    final ZooReaderWriter zrw = ZooReaderWriter.getInstance();
     try {
       String path = ZKUserPath + "/" + user + ZKUserTablePerms + "/" + table;
-      ZooReaderWriter.getInstance().sync(path);
-      serializedPerms = ZooReaderWriter.getInstance().getData(path, null);
+      zrw.sync(path);
+      serializedPerms = zrw.getData(path, null);
     } catch (KeeperException e) {
       if (e.code() == Code.NONODE) {
         // maybe the table was just deleted?
         try {
           // check for existence:
-          ZooReaderWriter.getInstance().getData(ZKTablePath + "/" + table, null);
+          zrw.getData(ZKTablePath + "/" + table, null);
           // it's there, you don't have permission
           return false;
         } catch (InterruptedException ex) {
@@ -127,16 +128,17 @@ public class ZKPermHandler implements PermissionHandler {
   @Override
   public boolean hasNamespacePermission(String user, String namespace, NamespacePermission permission) throws NamespaceNotFoundException {
     byte[] serializedPerms;
+    final ZooReaderWriter zrw = ZooReaderWriter.getInstance();
     try {
       String path = ZKUserPath + "/" + user + ZKUserNamespacePerms + "/" + namespace;
-      ZooReaderWriter.getInstance().sync(path);
-      serializedPerms = ZooReaderWriter.getInstance().getData(path, null);
+      zrw.sync(path);
+      serializedPerms = zrw.getData(path, null);
     } catch (KeeperException e) {
       if (e.code() == Code.NONODE) {
         // maybe the namespace was just deleted?
         try {
           // check for existence:
-          ZooReaderWriter.getInstance().getData(ZKNamespacePath + "/" + namespace, null);
+          zrw.getData(ZKNamespacePath + "/" + namespace, null);
           // it's there, you don't have permission
           return false;
         } catch (InterruptedException ex) {
@@ -213,8 +215,8 @@ public class ZKPermHandler implements PermissionHandler {
       if (tablePerms.add(permission)) {
         synchronized (zooCache) {
           zooCache.clear(ZKUserPath + "/" + user + ZKUserTablePerms + "/" + table);
-          IZooReaderWriter zoo = ZooReaderWriter.getInstance();
-          zoo.putPersistentData(ZKUserPath + "/" + user + ZKUserTablePerms + "/" + table, ZKSecurityTool.convertTablePermissions(tablePerms),
+          ZooReaderWriter.getInstance().putPersistentData(ZKUserPath + "/" + user + ZKUserTablePerms + "/" + table,
+              ZKSecurityTool.convertTablePermissions(tablePerms),
               NodeExistsPolicy.OVERWRITE);
         }
       }
@@ -240,8 +242,8 @@ public class ZKPermHandler implements PermissionHandler {
       if (namespacePerms.add(permission)) {
         synchronized (zooCache) {
           zooCache.clear(ZKUserPath + "/" + user + ZKUserNamespacePerms + "/" + namespace);
-          IZooReaderWriter zoo = ZooReaderWriter.getInstance();
-          zoo.putPersistentData(ZKUserPath + "/" + user + ZKUserNamespacePerms + "/" + namespace, ZKSecurityTool.convertNamespacePermissions(namespacePerms),
+          ZooReaderWriter.getInstance().putPersistentData(ZKUserPath + "/" + user + ZKUserNamespacePerms + "/" + namespace,
+              ZKSecurityTool.convertNamespacePermissions(namespacePerms),
               NodeExistsPolicy.OVERWRITE);
         }
       }