hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mberto...@apache.org
Subject [1/5] hbase git commit: HBASE-16522 Procedure v2 - Cache system user and avoid IOException
Date Tue, 30 Aug 2016 22:49:06 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 e46a073ed -> 57c6384b0
  refs/heads/branch-1.1 2a4b45540 -> 2250e5718
  refs/heads/branch-1.2 c16ec3d6e -> 15633a0fb
  refs/heads/branch-1.3 f4b6fdc42 -> af59baba1
  refs/heads/master c66bb48ce -> af33f9451


HBASE-16522 Procedure v2 - Cache system user and avoid IOException


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

Branch: refs/heads/branch-1.2
Commit: 15633a0fb591f9f0dadc66d9d79154b956450601
Parents: c16ec3d
Author: Matteo Bertozzi <matteo.bertozzi@cloudera.com>
Authored: Tue Aug 30 11:53:15 2016 -0700
Committer: Matteo Bertozzi <matteo.bertozzi@cloudera.com>
Committed: Tue Aug 30 11:58:50 2016 -0700

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/security/Superusers.java | 15 ++++++++++-----
 .../master/procedure/AddColumnFamilyProcedure.java   |  6 ++----
 .../hbase/master/procedure/CreateTableProcedure.java |  6 ++----
 .../procedure/DeleteColumnFamilyProcedure.java       |  6 ++----
 .../hbase/master/procedure/DeleteTableProcedure.java |  5 ++---
 .../master/procedure/DisableTableProcedure.java      | 15 ++++-----------
 .../hbase/master/procedure/EnableTableProcedure.java | 15 ++++-----------
 .../hbase/master/procedure/MasterProcedureEnv.java   |  6 +++---
 .../procedure/ModifyColumnFamilyProcedure.java       |  6 ++----
 .../hbase/master/procedure/ModifyTableProcedure.java |  4 +---
 .../master/procedure/TruncateTableProcedure.java     |  2 +-
 11 files changed, 33 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/15633a0f/hbase-common/src/main/java/org/apache/hadoop/hbase/security/Superusers.java
----------------------------------------------------------------------
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/security/Superusers.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/security/Superusers.java
index b4ce36e..e88d205 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/security/Superusers.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/security/Superusers.java
@@ -42,6 +42,7 @@ public final class Superusers {
 
   private static List<String> superUsers;
   private static List<String> superGroups;
+  private static User systemUser;
 
   private Superusers(){}
 
@@ -55,17 +56,17 @@ public final class Superusers {
   public static void initialize(Configuration conf) throws IOException {
     superUsers = new ArrayList<>();
     superGroups = new ArrayList<>();
-    User user = User.getCurrent();
+    systemUser = User.getCurrent();
 
-    if (user == null) {
+    if (systemUser == null) {
       throw new IllegalStateException("Unable to obtain the current user, "
         + "authorization checks for internal operations will not work correctly!");
     }
 
     if (LOG.isTraceEnabled()) {
-      LOG.trace("Current user name is " + user.getShortName());
+      LOG.trace("Current user name is " + systemUser.getShortName());
     }
-    String currentUser = user.getShortName();
+    String currentUser = systemUser.getShortName();
     String[] superUserList = conf.getStrings(SUPERUSER_CONF_KEY, new String[0]);
     for (String name : superUserList) {
       if (AuthUtil.isGroupPrincipal(name)) {
@@ -121,4 +122,8 @@ public final class Superusers {
       return false;
     }
   }
-}
\ No newline at end of file
+
+  public static User getSystemUser() {
+    return systemUser;
+  }
+}

http://git-wip-us.apache.org/repos/asf/hbase/blob/15633a0f/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/AddColumnFamilyProcedure.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/AddColumnFamilyProcedure.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/AddColumnFamilyProcedure.java
index 9905767..a7e34d8 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/AddColumnFamilyProcedure.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/AddColumnFamilyProcedure.java
@@ -66,10 +66,8 @@ public class AddColumnFamilyProcedure
     this.traceEnabled = null;
   }
 
-  public AddColumnFamilyProcedure(
-      final MasterProcedureEnv env,
-      final TableName tableName,
-      final HColumnDescriptor cfDescriptor) throws IOException {
+  public AddColumnFamilyProcedure(final MasterProcedureEnv env, final TableName tableName,
+      final HColumnDescriptor cfDescriptor) {
     this.tableName = tableName;
     this.cfDescriptor = cfDescriptor;
     this.user = env.getRequestUser().getUGI();

http://git-wip-us.apache.org/repos/asf/hbase/blob/15633a0f/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/CreateTableProcedure.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/CreateTableProcedure.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/CreateTableProcedure.java
index 6d4955c..a0aa637 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/CreateTableProcedure.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/CreateTableProcedure.java
@@ -76,15 +76,13 @@ public class CreateTableProcedure
   }
 
   public CreateTableProcedure(final MasterProcedureEnv env,
-      final HTableDescriptor hTableDescriptor, final HRegionInfo[] newRegions)
-      throws IOException {
+      final HTableDescriptor hTableDescriptor, final HRegionInfo[] newRegions) {
     this(env, hTableDescriptor, newRegions, null);
   }
 
   public CreateTableProcedure(final MasterProcedureEnv env,
       final HTableDescriptor hTableDescriptor, final HRegionInfo[] newRegions,
-      final ProcedurePrepareLatch syncLatch)
-      throws IOException {
+      final ProcedurePrepareLatch syncLatch) {
     this.hTableDescriptor = hTableDescriptor;
     this.newRegions = newRegions != null ? Lists.newArrayList(newRegions) : null;
     this.user = env.getRequestUser().getUGI();

http://git-wip-us.apache.org/repos/asf/hbase/blob/15633a0f/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteColumnFamilyProcedure.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteColumnFamilyProcedure.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteColumnFamilyProcedure.java
index 54d8fe5..bb8a201 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteColumnFamilyProcedure.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteColumnFamilyProcedure.java
@@ -67,10 +67,8 @@ public class DeleteColumnFamilyProcedure
     this.traceEnabled = null;
   }
 
-  public DeleteColumnFamilyProcedure(
-      final MasterProcedureEnv env,
-      final TableName tableName,
-      final byte[] familyName) throws IOException {
+  public DeleteColumnFamilyProcedure(final MasterProcedureEnv env, final TableName tableName,
+      final byte[] familyName) {
     this.tableName = tableName;
     this.familyName = familyName;
     this.user = env.getRequestUser().getUGI();

http://git-wip-us.apache.org/repos/asf/hbase/blob/15633a0f/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteTableProcedure.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteTableProcedure.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteTableProcedure.java
index 38b83a2..44dde9e 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteTableProcedure.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteTableProcedure.java
@@ -74,13 +74,12 @@ public class DeleteTableProcedure
     syncLatch = null;
   }
 
-  public DeleteTableProcedure(final MasterProcedureEnv env, final TableName tableName)
-      throws IOException {
+  public DeleteTableProcedure(final MasterProcedureEnv env, final TableName tableName) {
     this(env, tableName, null);
   }
 
   public DeleteTableProcedure(final MasterProcedureEnv env, final TableName tableName,
-      final ProcedurePrepareLatch syncLatch) throws IOException {
+      final ProcedurePrepareLatch syncLatch) {
     this.tableName = tableName;
     this.user = env.getRequestUser().getUGI();
     this.setOwner(this.user.getShortUserName());

http://git-wip-us.apache.org/repos/asf/hbase/blob/15633a0f/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DisableTableProcedure.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DisableTableProcedure.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DisableTableProcedure.java
index 9491fb1..185c0d0 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DisableTableProcedure.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DisableTableProcedure.java
@@ -83,12 +83,9 @@ public class DisableTableProcedure
    * @param env MasterProcedureEnv
    * @param tableName the table to operate on
    * @param skipTableStateCheck whether to check table state
-   * @throws IOException
    */
-  public DisableTableProcedure(
-      final MasterProcedureEnv env,
-      final TableName tableName,
-      final boolean skipTableStateCheck) throws IOException {
+  public DisableTableProcedure(final MasterProcedureEnv env, final TableName tableName,
+      final boolean skipTableStateCheck) {
     this(env, tableName, skipTableStateCheck, null);
   }
 
@@ -97,13 +94,9 @@ public class DisableTableProcedure
    * @param env MasterProcedureEnv
    * @param tableName the table to operate on
    * @param skipTableStateCheck whether to check table state
-   * @throws IOException
    */
-  public DisableTableProcedure(
-      final MasterProcedureEnv env,
-      final TableName tableName,
-      final boolean skipTableStateCheck,
-      final ProcedurePrepareLatch syncLatch) throws IOException {
+  public DisableTableProcedure(final MasterProcedureEnv env, final TableName tableName,
+      final boolean skipTableStateCheck, final ProcedurePrepareLatch syncLatch) {
     this.tableName = tableName;
     this.skipTableStateCheck = skipTableStateCheck;
     this.user = env.getRequestUser().getUGI();

http://git-wip-us.apache.org/repos/asf/hbase/blob/15633a0f/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/EnableTableProcedure.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/EnableTableProcedure.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/EnableTableProcedure.java
index e7d6685..14f68e2 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/EnableTableProcedure.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/EnableTableProcedure.java
@@ -82,12 +82,9 @@ public class EnableTableProcedure
    * @param env MasterProcedureEnv
    * @param tableName the table to operate on
    * @param skipTableStateCheck whether to check table state
-   * @throws IOException
    */
-  public EnableTableProcedure(
-      final MasterProcedureEnv env,
-      final TableName tableName,
-      final boolean skipTableStateCheck) throws IOException {
+  public EnableTableProcedure(final MasterProcedureEnv env, final TableName tableName,
+      final boolean skipTableStateCheck) {
     this(env, tableName, skipTableStateCheck, null);
   }
 
@@ -96,13 +93,9 @@ public class EnableTableProcedure
    * @param env MasterProcedureEnv
    * @param tableName the table to operate on
    * @param skipTableStateCheck whether to check table state
-   * @throws IOException
    */
-  public EnableTableProcedure(
-      final MasterProcedureEnv env,
-      final TableName tableName,
-      final boolean skipTableStateCheck,
-      final ProcedurePrepareLatch syncLatch) throws IOException {
+  public EnableTableProcedure(final MasterProcedureEnv env, final TableName tableName,
+      final boolean skipTableStateCheck, final ProcedurePrepareLatch syncLatch) {
     this.tableName = tableName;
     this.skipTableStateCheck = skipTableStateCheck;
     this.user = env.getRequestUser().getUGI();

http://git-wip-us.apache.org/repos/asf/hbase/blob/15633a0f/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/MasterProcedureEnv.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/MasterProcedureEnv.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/MasterProcedureEnv.java
index 090b8cc..3911f54 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/MasterProcedureEnv.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/MasterProcedureEnv.java
@@ -36,7 +36,7 @@ import org.apache.hadoop.hbase.procedure2.Procedure;
 import org.apache.hadoop.hbase.procedure2.store.ProcedureStore;
 import org.apache.hadoop.hbase.procedure2.store.wal.WALProcedureStore;
 import org.apache.hadoop.hbase.security.User;
-import org.apache.hadoop.hbase.security.UserProvider;
+import org.apache.hadoop.hbase.security.Superusers;
 import org.apache.hadoop.hbase.util.CancelableProgressable;
 import org.apache.hadoop.hbase.util.FSUtils;
 
@@ -96,10 +96,10 @@ public class MasterProcedureEnv {
       master.getTableLockManager());
   }
 
-  public User getRequestUser() throws IOException {
+  public User getRequestUser() {
     User user = RpcServer.getRequestUser();
     if (user == null) {
-      user = UserProvider.instantiate(getMasterConfiguration()).getCurrent();
+      user = Superusers.getSystemUser();
     }
     return user;
   }

http://git-wip-us.apache.org/repos/asf/hbase/blob/15633a0f/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ModifyColumnFamilyProcedure.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ModifyColumnFamilyProcedure.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ModifyColumnFamilyProcedure.java
index fd212eb..5e81dbf 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ModifyColumnFamilyProcedure.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ModifyColumnFamilyProcedure.java
@@ -64,10 +64,8 @@ public class ModifyColumnFamilyProcedure
     this.traceEnabled = null;
   }
 
-  public ModifyColumnFamilyProcedure(
-      final MasterProcedureEnv env,
-      final TableName tableName,
-      final HColumnDescriptor cfDescriptor) throws IOException {
+  public ModifyColumnFamilyProcedure(final MasterProcedureEnv env, final TableName tableName,
+      final HColumnDescriptor cfDescriptor) {
     this.tableName = tableName;
     this.cfDescriptor = cfDescriptor;
     this.user = env.getRequestUser().getUGI();

http://git-wip-us.apache.org/repos/asf/hbase/blob/15633a0f/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ModifyTableProcedure.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ModifyTableProcedure.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ModifyTableProcedure.java
index ddbc9ef..71b1f95 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ModifyTableProcedure.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ModifyTableProcedure.java
@@ -71,9 +71,7 @@ public class ModifyTableProcedure
     initilize();
   }
 
-  public ModifyTableProcedure(
-    final MasterProcedureEnv env,
-    final HTableDescriptor htd) throws IOException {
+  public ModifyTableProcedure(final MasterProcedureEnv env, final HTableDescriptor htd) {
     initilize();
     this.modifiedHTableDescriptor = htd;
     this.user = env.getRequestUser().getUGI();

http://git-wip-us.apache.org/repos/asf/hbase/blob/15633a0f/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/TruncateTableProcedure.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/TruncateTableProcedure.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/TruncateTableProcedure.java
index 3623f35..3a3739d 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/TruncateTableProcedure.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/TruncateTableProcedure.java
@@ -61,7 +61,7 @@ public class TruncateTableProcedure
   }
 
   public TruncateTableProcedure(final MasterProcedureEnv env, final TableName tableName,
-      boolean preserveSplits) throws IOException {
+      boolean preserveSplits) {
     this.tableName = tableName;
     this.preserveSplits = preserveSplits;
     this.user = env.getRequestUser().getUGI();


Mime
View raw message