sentry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ak...@apache.org
Subject sentry git commit: SENTRY-1638: Update MSentryPermChange table to add a column for notification ID (Lei Xu, Reviewed by: Alex Kolbasov)
Date Wed, 01 Mar 2017 22:42:13 GMT
Repository: sentry
Updated Branches:
  refs/heads/sentry-ha-redesign c0333a9cf -> 520907641


SENTRY-1638: Update MSentryPermChange table to add a column for notification ID (Lei Xu, Reviewed
by: Alex Kolbasov)


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

Branch: refs/heads/sentry-ha-redesign
Commit: 5209076418d93c12404057ac52bf5c21c783fea9
Parents: c0333a9
Author: Alexander Kolbasov <akolb@cloudera.com>
Authored: Wed Mar 1 14:41:41 2017 -0800
Committer: Alexander Kolbasov <akolb@cloudera.com>
Committed: Wed Mar 1 14:41:41 2017 -0800

----------------------------------------------------------------------
 .../db/service/model/MSentryPermChange.java       | 18 +++++++++++++++---
 .../sentry/provider/db/service/model/package.jdo  |  5 +++++
 2 files changed, 20 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sentry/blob/52090764/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/MSentryPermChange.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/MSentryPermChange.java
b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/MSentryPermChange.java
index 476fbcb..7f1b739 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/MSentryPermChange.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/MSentryPermChange.java
@@ -27,7 +27,7 @@ import javax.jdo.annotations.PrimaryKey;
 
 /**
  * Database backend store for Sentry permission delta change. Each record
- * contains change ID, JSON format of a single Sentry permission change,
+ * contains change ID, HMS notification ID, JSON format of a single Sentry permission change,
  * and timestamp.
  * <p>
  * e.g. for rename privileges change in JSON format.
@@ -63,8 +63,14 @@ public class MSentryPermChange implements MSentryChange {
   // Permission change in JSON format.
   private String permChange;
   private long createTimeMs;
+  private long notificationID;
 
   public MSentryPermChange(PermissionsUpdate permChange) throws TException {
+    // Each PathsUpdate maps to a MSentryPermChange object.
+    // The PathsUpdate is generated from a HMS notification log,
+    // the notification ID is stored as seqNum and
+    // the notification update is serialized as JSON string.
+    this.notificationID = permChange.getSeqNum();
     this.permChange = permChange.JSONSerialize();
     this.createTimeMs = System.currentTimeMillis();
   }
@@ -83,8 +89,9 @@ public class MSentryPermChange implements MSentryChange {
 
   @Override
   public String toString() {
-    return "MSentryPermChange [changeID=" + changeID + ", permChange= " + permChange +
-        ", createTimeMs=" + createTimeMs +  "]";
+    return String.format(
+        "MSentryPermChange [changeID=%d, notificationID=%d, permChange=%s, createTimeMs=%d]",
+        changeID, notificationID, permChange, createTimeMs);
   }
 
   @Override
@@ -92,6 +99,7 @@ public class MSentryPermChange implements MSentryChange {
     final int prime = 31;
     int result = 1;
     result = prime * result + Long.valueOf(changeID).hashCode();
+    result = prime * result + Long.valueOf(notificationID).hashCode();
     result = prime * result + ((permChange == null) ? 0 : permChange.hashCode());
     return result;
   }
@@ -115,6 +123,10 @@ public class MSentryPermChange implements MSentryChange {
       return false;
     }
 
+    if (notificationID != other.notificationID) {
+      return false;
+    }
+
     if (createTimeMs != other.createTimeMs) {
       return false;
     }

http://git-wip-us.apache.org/repos/asf/sentry/blob/52090764/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/package.jdo
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/package.jdo
b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/package.jdo
index e981bcf..fc84df6 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/package.jdo
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/package.jdo
@@ -266,6 +266,10 @@
        <field name="changeID" primary-key="true" value-strategy="increment">
          <column name="CHANGE_ID" jdbc-type="BIGINT" allows-null="false"/>
        </field>
+       <field name="notificationID">
+         <column name="NOTIFICATION_ID" jdbc-type="BIGINT" allows-null="false"/>
+         <index name="NotificationID" unique="true"/>
+       </field>
        <field name ="permChange">
          <column name="PERM_CHANGE" length="4000" jdbc-type="VARCHAR" allows-null="false"/>
        </field>
@@ -280,6 +284,7 @@
        </field>
        <field name="notificationID">
          <column name="NOTIFICATION_ID" jdbc-type="BIGINT" allows-null="false"/>
+         <index name="NotificationID" unique="true"/>
        </field>
        <field name ="pathChange">
          <column name="PATH_CHANGE" length="4000" jdbc-type="VARCHAR" allows-null="false"/>


Mime
View raw message