accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject [accumulo] branch 2.0 updated: Drop Unused boolean flag and Remove internal static objects (#1224)
Date Thu, 20 Jun 2019 06:48:53 GMT
This is an automated email from the ASF dual-hosted git repository.

ctubbsii pushed a commit to branch 2.0
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/2.0 by this push:
     new 9e32263  Drop Unused boolean flag and Remove internal static objects (#1224)
9e32263 is described below

commit 9e32263e71ecb2dc06461869308d89740ad35270
Author: Mike Miller <mmiller@apache.org>
AuthorDate: Thu Jun 20 02:48:48 2019 -0400

    Drop Unused boolean flag and Remove internal static objects (#1224)
    
    * Remove internal static objects
    * Drop unused initialize flag
---
 .../apache/accumulo/server/init/Initialize.java    |  4 ++--
 .../server/security/AuditedSecurityOperation.java  |  9 ++------
 .../server/security/SecurityOperation.java         | 26 ++++++++++------------
 .../server/security/handler/Authenticator.java     |  2 +-
 .../server/security/handler/Authorizor.java        |  2 +-
 .../security/handler/KerberosAuthenticator.java    |  4 ++--
 .../security/handler/KerberosAuthorizor.java       |  4 ++--
 .../handler/KerberosPermissionHandler.java         |  4 ++--
 .../server/security/handler/PermissionHandler.java |  2 +-
 .../server/security/handler/ZKAuthenticator.java   |  9 +-------
 .../server/security/handler/ZKAuthorizor.java      |  9 +-------
 .../server/security/handler/ZKPermHandler.java     |  9 +-------
 .../replication/MasterReplicationCoordinator.java  |  3 ++-
 13 files changed, 30 insertions(+), 57 deletions(-)

diff --git a/server/base/src/main/java/org/apache/accumulo/server/init/Initialize.java b/server/base/src/main/java/org/apache/accumulo/server/init/Initialize.java
index 2f855b8..a28882e 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/init/Initialize.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/init/Initialize.java
@@ -792,8 +792,8 @@ public class Initialize implements KeywordExecutable {
 
   private static void initSecurity(ServerContext context, Opts opts, String rootUser)
       throws AccumuloSecurityException {
-    AuditedSecurityOperation.getInstance(context, true).initializeSecurity(context.rpcCreds(),
-        rootUser, opts.rootpass);
+    AuditedSecurityOperation.getInstance(context).initializeSecurity(context.rpcCreds(),
rootUser,
+        opts.rootpass);
   }
 
   public static void initSystemTablesConfig(ZooReaderWriter zoo, String zooKeeperRoot,
diff --git a/server/base/src/main/java/org/apache/accumulo/server/security/AuditedSecurityOperation.java
b/server/base/src/main/java/org/apache/accumulo/server/security/AuditedSecurityOperation.java
index 77d4b5f..06e1c1f 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/security/AuditedSecurityOperation.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/security/AuditedSecurityOperation.java
@@ -65,14 +65,9 @@ public class AuditedSecurityOperation extends SecurityOperation {
   }
 
   public static synchronized SecurityOperation getInstance(ServerContext context) {
-    return getInstance(context, false);
-  }
-
-  public static synchronized SecurityOperation getInstance(ServerContext context,
-      boolean initialize) {
     if (instance == null) {
-      instance = new AuditedSecurityOperation(context, getAuthorizor(context, initialize),
-          getAuthenticator(context, initialize), getPermHandler(context, initialize));
+      instance = new AuditedSecurityOperation(context, getAuthorizor(context),
+          getAuthenticator(context), getPermHandler(context));
     }
     return instance;
   }
diff --git a/server/base/src/main/java/org/apache/accumulo/server/security/SecurityOperation.java
b/server/base/src/main/java/org/apache/accumulo/server/security/SecurityOperation.java
index 6564623..4a2eb1c 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/security/SecurityOperation.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/security/SecurityOperation.java
@@ -79,35 +79,33 @@ public class SecurityOperation {
 
   static SecurityOperation instance;
 
-  public static synchronized SecurityOperation getInstance(ServerContext context,
-      boolean initialize) {
+  public static synchronized SecurityOperation getInstance(ServerContext context) {
     if (instance == null) {
-      instance = new SecurityOperation(context, getAuthorizor(context, initialize),
-          getAuthenticator(context, initialize), getPermHandler(context, initialize));
+      instance = new SecurityOperation(context, getAuthorizor(context), getAuthenticator(context),
+          getPermHandler(context));
     }
     return instance;
   }
 
-  protected static Authorizor getAuthorizor(ServerContext context, boolean initialize) {
+  protected static Authorizor getAuthorizor(ServerContext context) {
     Authorizor toRet = Property.createInstanceFromPropertyName(context.getConfiguration(),
-        Property.INSTANCE_SECURITY_AUTHORIZOR, Authorizor.class, ZKAuthorizor.getInstance());
-    toRet.initialize(context, initialize);
+        Property.INSTANCE_SECURITY_AUTHORIZOR, Authorizor.class, new ZKAuthorizor());
+    toRet.initialize(context);
     return toRet;
   }
 
-  protected static Authenticator getAuthenticator(ServerContext context, boolean initialize)
{
+  protected static Authenticator getAuthenticator(ServerContext context) {
     Authenticator toRet = Property.createInstanceFromPropertyName(context.getConfiguration(),
-        Property.INSTANCE_SECURITY_AUTHENTICATOR, Authenticator.class,
-        ZKAuthenticator.getInstance());
-    toRet.initialize(context, initialize);
+        Property.INSTANCE_SECURITY_AUTHENTICATOR, Authenticator.class, new ZKAuthenticator());
+    toRet.initialize(context);
     return toRet;
   }
 
-  protected static PermissionHandler getPermHandler(ServerContext context, boolean initialize)
{
+  protected static PermissionHandler getPermHandler(ServerContext context) {
     PermissionHandler toRet = Property.createInstanceFromPropertyName(context.getConfiguration(),
         Property.INSTANCE_SECURITY_PERMISSION_HANDLER, PermissionHandler.class,
-        ZKPermHandler.getInstance());
-    toRet.initialize(context, initialize);
+        new ZKPermHandler());
+    toRet.initialize(context);
     return toRet;
   }
 
diff --git a/server/base/src/main/java/org/apache/accumulo/server/security/handler/Authenticator.java
b/server/base/src/main/java/org/apache/accumulo/server/security/handler/Authenticator.java
index b2ab1b9..cad3fb6 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/security/handler/Authenticator.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/security/handler/Authenticator.java
@@ -29,7 +29,7 @@ import org.apache.accumulo.server.ServerContext;
  */
 public interface Authenticator {
 
-  void initialize(ServerContext context, boolean initialize);
+  void initialize(ServerContext context);
 
   boolean validSecurityHandlers();
 
diff --git a/server/base/src/main/java/org/apache/accumulo/server/security/handler/Authorizor.java
b/server/base/src/main/java/org/apache/accumulo/server/security/handler/Authorizor.java
index 8609d9c..8c82d4a 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/security/handler/Authorizor.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/security/handler/Authorizor.java
@@ -34,7 +34,7 @@ public interface Authorizor {
   /**
    * Sets up the authorizor for a new instance of Accumulo
    */
-  void initialize(ServerContext context, boolean initialize);
+  void initialize(ServerContext context);
 
   /**
    * Used to validate that the Authorizor, Authenticator, and permission handler can coexist
diff --git a/server/base/src/main/java/org/apache/accumulo/server/security/handler/KerberosAuthenticator.java
b/server/base/src/main/java/org/apache/accumulo/server/security/handler/KerberosAuthenticator.java
index c47f171..8bf43c3 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/security/handler/KerberosAuthenticator.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/security/handler/KerberosAuthenticator.java
@@ -59,11 +59,11 @@ public class KerberosAuthenticator implements Authenticator {
   private UserImpersonation impersonation;
 
   @Override
-  public void initialize(ServerContext context, boolean initialize) {
+  public void initialize(ServerContext context) {
     this.context = context;
     zooCache = new ZooCache(context.getZooReaderWriter(), null);
     impersonation = new UserImpersonation(context.getConfiguration());
-    zkAuthenticator.initialize(context, initialize);
+    zkAuthenticator.initialize(context);
     zkUserPath = Constants.ZROOT + "/" + context.getInstanceID() + "/users";
   }
 
diff --git a/server/base/src/main/java/org/apache/accumulo/server/security/handler/KerberosAuthorizor.java
b/server/base/src/main/java/org/apache/accumulo/server/security/handler/KerberosAuthorizor.java
index 9e77a08..acb0dd1 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/security/handler/KerberosAuthorizor.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/security/handler/KerberosAuthorizor.java
@@ -40,8 +40,8 @@ public class KerberosAuthorizor implements Authorizor {
   }
 
   @Override
-  public void initialize(ServerContext context, boolean initialize) {
-    zkAuthorizor.initialize(context, initialize);
+  public void initialize(ServerContext context) {
+    zkAuthorizor.initialize(context);
   }
 
   @Override
diff --git a/server/base/src/main/java/org/apache/accumulo/server/security/handler/KerberosPermissionHandler.java
b/server/base/src/main/java/org/apache/accumulo/server/security/handler/KerberosPermissionHandler.java
index 72d7d1d..1827390 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/security/handler/KerberosPermissionHandler.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/security/handler/KerberosPermissionHandler.java
@@ -42,8 +42,8 @@ public class KerberosPermissionHandler implements PermissionHandler {
   }
 
   @Override
-  public void initialize(ServerContext context, boolean initialize) {
-    zkPermissionHandler.initialize(context, initialize);
+  public void initialize(ServerContext context) {
+    zkPermissionHandler.initialize(context);
   }
 
   @Override
diff --git a/server/base/src/main/java/org/apache/accumulo/server/security/handler/PermissionHandler.java
b/server/base/src/main/java/org/apache/accumulo/server/security/handler/PermissionHandler.java
index 7e1c745..301e14d 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/security/handler/PermissionHandler.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/security/handler/PermissionHandler.java
@@ -35,7 +35,7 @@ public interface PermissionHandler {
   /**
    * Sets up the permission handler for a new instance of Accumulo
    */
-  void initialize(ServerContext context, boolean initialize);
+  void initialize(ServerContext context);
 
   /**
    * Used to validate that the Authorizor, Authenticator, and permission handler can coexist
diff --git a/server/base/src/main/java/org/apache/accumulo/server/security/handler/ZKAuthenticator.java
b/server/base/src/main/java/org/apache/accumulo/server/security/handler/ZKAuthenticator.java
index 13dfeda..d9aa8aa 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/security/handler/ZKAuthenticator.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/security/handler/ZKAuthenticator.java
@@ -40,20 +40,13 @@ import org.slf4j.LoggerFactory;
 // Utility class for adding all authentication info into ZK
 public final class ZKAuthenticator implements Authenticator {
   private static final Logger log = LoggerFactory.getLogger(ZKAuthenticator.class);
-  private static Authenticator zkAuthenticatorInstance = null;
 
   private ServerContext context;
   private String ZKUserPath;
   private ZooCache zooCache;
 
-  public static synchronized Authenticator getInstance() {
-    if (zkAuthenticatorInstance == null)
-      zkAuthenticatorInstance = new ZKAuthenticator();
-    return zkAuthenticatorInstance;
-  }
-
   @Override
-  public void initialize(ServerContext context, boolean initialize) {
+  public void initialize(ServerContext context) {
     this.context = context;
     zooCache = new ZooCache(context.getZooReaderWriter(), null);
     ZKUserPath = Constants.ZROOT + "/" + context.getInstanceID() + "/users";
diff --git a/server/base/src/main/java/org/apache/accumulo/server/security/handler/ZKAuthorizor.java
b/server/base/src/main/java/org/apache/accumulo/server/security/handler/ZKAuthorizor.java
index 6ea8cda..1b0e9fb 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/security/handler/ZKAuthorizor.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/security/handler/ZKAuthorizor.java
@@ -38,7 +38,6 @@ import org.slf4j.LoggerFactory;
 
 public class ZKAuthorizor implements Authorizor {
   private static final Logger log = LoggerFactory.getLogger(ZKAuthorizor.class);
-  private static Authorizor zkAuthorizorInstance = null;
 
   private final String ZKUserAuths = "/Authorizations";
 
@@ -46,14 +45,8 @@ public class ZKAuthorizor implements Authorizor {
   private String ZKUserPath;
   private ZooCache zooCache;
 
-  public static synchronized Authorizor getInstance() {
-    if (zkAuthorizorInstance == null)
-      zkAuthorizorInstance = new ZKAuthorizor();
-    return zkAuthorizorInstance;
-  }
-
   @Override
-  public void initialize(ServerContext context, boolean initialize) {
+  public void initialize(ServerContext context) {
     this.context = context;
     zooCache = new ZooCache(context.getZooReaderWriter(), null);
     ZKUserPath = ZKSecurityTool.getInstancePath(context.getInstanceID()) + "/users";
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 7d7e5c4..5bbc2ee 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
@@ -50,7 +50,6 @@ import org.slf4j.LoggerFactory;
 
 public class ZKPermHandler implements PermissionHandler {
   private static final Logger log = LoggerFactory.getLogger(ZKPermHandler.class);
-  private static PermissionHandler zkPermHandlerInstance = null;
 
   private ZooReaderWriter zoo;
   private String ZKUserPath;
@@ -61,14 +60,8 @@ public class ZKPermHandler implements PermissionHandler {
   private final String ZKUserTablePerms = "/Tables";
   private final String ZKUserNamespacePerms = "/Namespaces";
 
-  public static synchronized PermissionHandler getInstance() {
-    if (zkPermHandlerInstance == null)
-      zkPermHandlerInstance = new ZKPermHandler();
-    return zkPermHandlerInstance;
-  }
-
   @Override
-  public void initialize(ServerContext context, boolean initialize) {
+  public void initialize(ServerContext context) {
     zooCache = new ZooCache(context.getZooReaderWriter(), null);
     zoo = context.getZooReaderWriter();
     String instanceId = context.getInstanceID();
diff --git a/server/master/src/main/java/org/apache/accumulo/master/replication/MasterReplicationCoordinator.java
b/server/master/src/main/java/org/apache/accumulo/master/replication/MasterReplicationCoordinator.java
index c607def..f5a0171 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/replication/MasterReplicationCoordinator.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/replication/MasterReplicationCoordinator.java
@@ -33,6 +33,7 @@ import org.apache.accumulo.core.securityImpl.thrift.TCredentials;
 import org.apache.accumulo.fate.zookeeper.ZooReader;
 import org.apache.accumulo.master.Master;
 import org.apache.accumulo.server.master.state.TServerInstance;
+import org.apache.accumulo.server.security.AuditedSecurityOperation;
 import org.apache.accumulo.server.security.SecurityOperation;
 import org.apache.thrift.TException;
 import org.apache.zookeeper.KeeperException;
@@ -60,7 +61,7 @@ public class MasterReplicationCoordinator implements ReplicationCoordinator.Ifac
     this.rand = new SecureRandom();
     this.rand.setSeed(358923462L);
     this.reader = reader;
-    this.security = SecurityOperation.getInstance(master.getContext(), false);
+    this.security = AuditedSecurityOperation.getInstance(master.getContext());
   }
 
   @Override


Mime
View raw message