You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2021/12/04 15:24:46 UTC

[hbase] branch branch-2 updated (d504504 -> b471d75)

This is an automated email from the ASF dual-hosted git repository.

zhangduo pushed a change to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git.


    from d504504  HBASE-26304 Reflect out of band locality improvements in metrics and balancer (#3895)
     new 19d991d  HBASE-26517 Add auth method information to AccessChecker audit log (#3897)
     new b471d75  HBASE-26490 Add builder for class ReplicationLoadSink (#3883)

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../hbase/replication/ReplicationLoadSink.java     | 44 ++++++++++++++++++++--
 .../hadoop/hbase/shaded/protobuf/ProtobufUtil.java | 10 +++--
 .../hbase/security/access/AccessChecker.java       | 11 ++++--
 3 files changed, 55 insertions(+), 10 deletions(-)

[hbase] 01/02: HBASE-26517 Add auth method information to AccessChecker audit log (#3897)

Posted by zh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

zhangduo pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git

commit 19d991d291acc183ba07f7dfeb07da228cec5880
Author: Tomu Tsuruhara <to...@gmail.com>
AuthorDate: Sat Dec 4 23:59:29 2021 +0900

    HBASE-26517 Add auth method information to AccessChecker audit log (#3897)
    
    Signed-off-by: Duo Zhang <zh...@apache.org>
---
 .../apache/hadoop/hbase/security/access/AccessChecker.java    | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessChecker.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessChecker.java
index 7282a1f..15e5e09 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessChecker.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessChecker.java
@@ -47,6 +47,7 @@ import org.apache.hadoop.hbase.security.access.Permission.Action;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.security.Groups;
 import org.apache.hadoop.security.HadoopKerberosName;
+import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.yetus.audience.InterfaceAudience;
 import org.apache.yetus.audience.InterfaceStability;
 import org.slf4j.Logger;
@@ -366,12 +367,16 @@ public class AccessChecker {
 
   public static void logResult(AuthResult result) {
     if (AUDITLOG.isTraceEnabled()) {
+      User user = result.getUser();
+      UserGroupInformation ugi = user != null ? user.getUGI() : null;
       AUDITLOG.trace(
-        "Access {} for user {}; reason: {}; remote address: {}; request: {}; context: {}",
+        "Access {} for user {}; reason: {}; remote address: {}; request: {}; context: {};" +
+          "auth method: {}",
         (result.isAllowed() ? "allowed" : "denied"),
-        (result.getUser() != null ? result.getUser().getShortName() : "UNKNOWN"),
+        (user != null ? user.getShortName() : "UNKNOWN"),
         result.getReason(), RpcServer.getRemoteAddress().map(InetAddress::toString).orElse(""),
-        result.getRequest(), result.toContextString());
+        result.getRequest(), result.toContextString(),
+        ugi != null ? ugi.getAuthenticationMethod() : "UNKNOWN");
     }
   }
 

[hbase] 02/02: HBASE-26490 Add builder for class ReplicationLoadSink (#3883)

Posted by zh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

zhangduo pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git

commit b471d753d3ca23df732b97e1f76fe1b95cd1ab62
Author: Yutong Xiao <yu...@gmail.com>
AuthorDate: Sat Dec 4 23:00:22 2021 +0800

    HBASE-26490 Add builder for class ReplicationLoadSink (#3883)
    
    Signed-off-by: Reid Chan <re...@apache.org>
    Signed-off-by: Duo Zhang <zh...@apache.org>
---
 .../hbase/replication/ReplicationLoadSink.java     | 44 ++++++++++++++++++++--
 .../hadoop/hbase/shaded/protobuf/ProtobufUtil.java | 10 +++--
 2 files changed, 47 insertions(+), 7 deletions(-)

diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/replication/ReplicationLoadSink.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/replication/ReplicationLoadSink.java
index f9afddd..7551560 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/replication/ReplicationLoadSink.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/replication/ReplicationLoadSink.java
@@ -22,9 +22,7 @@ public class ReplicationLoadSink {
   private final long timestampStarted;
   private final long totalOpsProcessed;
 
-  // TODO: add the builder for this class
-  @InterfaceAudience.Private
-  public ReplicationLoadSink(long age, long timestamp, long timestampStarted,
+  private ReplicationLoadSink(long age, long timestamp, long timestampStarted,
       long totalOpsProcessed) {
     this.ageOfLastAppliedOp = age;
     this.timestampsOfLastAppliedOp = timestamp;
@@ -56,4 +54,44 @@ public class ReplicationLoadSink {
   public long getTotalOpsProcessed() {
     return totalOpsProcessed;
   }
+
+  @InterfaceAudience.Private
+  public static ReplicationLoadSinkBuilder newBuilder() {
+    return new ReplicationLoadSinkBuilder();
+  }
+
+  @InterfaceAudience.Private
+  public static final class ReplicationLoadSinkBuilder {
+    private long ageOfLastAppliedOp;
+    private long timestampsOfLastAppliedOp;
+    private long timestampStarted;
+    private long totalOpsProcessed;
+
+    private ReplicationLoadSinkBuilder() {}
+
+    public ReplicationLoadSinkBuilder setAgeOfLastAppliedOp(long ageOfLastAppliedOp) {
+      this.ageOfLastAppliedOp = ageOfLastAppliedOp;
+      return this;
+    }
+
+    public ReplicationLoadSinkBuilder setTimestampsOfLastAppliedOp(long timestampsOfLastAppliedOp) {
+      this.timestampsOfLastAppliedOp = timestampsOfLastAppliedOp;
+      return this;
+    }
+
+    public ReplicationLoadSinkBuilder setTimestampStarted(long timestampStarted) {
+      this.timestampStarted = timestampStarted;
+      return this;
+    }
+
+    public ReplicationLoadSinkBuilder setTotalOpsProcessed(long totalOpsProcessed) {
+      this.totalOpsProcessed = totalOpsProcessed;
+      return this;
+    }
+
+    public ReplicationLoadSink build() {
+      return new ReplicationLoadSink(ageOfLastAppliedOp, timestampsOfLastAppliedOp,
+        timestampStarted, totalOpsProcessed);
+    }
+  }
 }
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java
index 2297732..92915ec 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java
@@ -2798,10 +2798,12 @@ public final class ProtobufUtil {
 
   public static ReplicationLoadSink toReplicationLoadSink(
       ClusterStatusProtos.ReplicationLoadSink rls) {
-    return new ReplicationLoadSink(rls.getAgeOfLastAppliedOp(),
-        rls.getTimeStampsOfLastAppliedOp(),
-        rls.hasTimestampStarted()? rls.getTimestampStarted(): -1L,
-        rls.hasTotalOpsProcessed()? rls.getTotalOpsProcessed(): -1L);
+    ReplicationLoadSink.ReplicationLoadSinkBuilder builder = ReplicationLoadSink.newBuilder();
+    builder.setAgeOfLastAppliedOp(rls.getAgeOfLastAppliedOp()).
+      setTimestampsOfLastAppliedOp(rls.getTimeStampsOfLastAppliedOp()).
+      setTimestampStarted(rls.hasTimestampStarted()? rls.getTimestampStarted(): -1L).
+      setTotalOpsProcessed(rls.hasTotalOpsProcessed()? rls.getTotalOpsProcessed(): -1L);
+    return builder.build();
   }
 
   public static ReplicationLoadSource toReplicationLoadSource(