You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sentry.apache.org by ak...@apache.org on 2017/04/04 20:37:58 UTC
sentry git commit: SENTRY-1680: MetastoreCacheInitializer is lo
longer used and should be removed (Alex Kolbasov,
Reviewed by Hao Hao and Na Li)
Repository: sentry
Updated Branches:
refs/heads/sentry-ha-redesign 7b3878cf3 -> 085b1c2d1
SENTRY-1680: MetastoreCacheInitializer is lo longer used and should be removed (Alex Kolbasov, Reviewed by Hao Hao and Na Li)
Project: http://git-wip-us.apache.org/repos/asf/sentry/repo
Commit: http://git-wip-us.apache.org/repos/asf/sentry/commit/085b1c2d
Tree: http://git-wip-us.apache.org/repos/asf/sentry/tree/085b1c2d
Diff: http://git-wip-us.apache.org/repos/asf/sentry/diff/085b1c2d
Branch: refs/heads/sentry-ha-redesign
Commit: 085b1c2d181a2a83251d0886e799393bd47f8970
Parents: 7b3878c
Author: Alexander Kolbasov <ak...@cloudera.com>
Authored: Tue Apr 4 13:37:18 2017 -0700
Committer: Alexander Kolbasov <ak...@cloudera.com>
Committed: Tue Apr 4 13:37:52 2017 -0700
----------------------------------------------------------------------
.../db/service/persistent/SentryStore.java | 36 ++++++++++++++++----
.../db/service/thrift/SentryMetrics.java | 3 +-
2 files changed, 31 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/sentry/blob/085b1c2d/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
index bbfa713..802b9c6 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
@@ -105,8 +105,8 @@ public class SentryStore {
.getLogger(SentryStore.class);
public static final String NULL_COL = "__NULL__";
- public static int INDEX_GROUP_ROLES_MAP = 0;
- public static int INDEX_USER_ROLES_MAP = 1;
+ public static final int INDEX_GROUP_ROLES_MAP = 0;
+ public static final int INDEX_USER_ROLES_MAP = 1;
// String constants for field names
public static final String SERVER_NAME = "serverName";
@@ -125,7 +125,10 @@ public class SentryStore {
public static final long EMPTY_CHANGE_ID = 0L;
// For counters, representation of the "unknown value"
- private static final long COUNT_VALUE_UNKNOWN = -1;
+ private static final long COUNT_VALUE_UNKNOWN = -1L;
+
+ // Representation for unknown HMS notification ID
+ private static final long NOTIFICATION_UNKNOWN = -1L;
private static final Set<String> ALL_ACTIONS = Sets.newHashSet(AccessConstants.ALL,
AccessConstants.SELECT, AccessConstants.INSERT, AccessConstants.ALTER,
@@ -448,6 +451,23 @@ public class SentryStore {
}
/**
+ * @return current value of last processed notification ID
+ */
+ public Gauge<Long> getLastNotificationIdGauge() {
+ return new Gauge<Long>() {
+ @Override
+ public Long getValue() {
+ try {
+ return getLastProcessedNotificationID();
+ } catch (Exception e) {
+ LOGGER.error("Can not read current notificationId", e);
+ return NOTIFICATION_UNKNOWN;
+ }
+ }
+ };
+ }
+
+ /**
* Lets the test code know how many privs are in the db, so that we know
* if they are in fact being cleaned up when not being referenced any more.
* @return The number of rows in the db priv table.
@@ -3238,8 +3258,9 @@ public class SentryStore {
query.declareParameters("long id");
List<MSentryPermChange> permChanges = (List<MSentryPermChange>)query.execute(changeID);
if (permChanges == null) {
- noSuchUpdate(changeID);
- } else if (permChanges.size() > 1) {
+ throw noSuchUpdate(changeID);
+ }
+ if (permChanges.size() > 1) {
throw new Exception("Inconsistent permission delta: " + permChanges.size()
+ " permissions for the same id, " + changeID);
}
@@ -3347,8 +3368,9 @@ public class SentryStore {
query.declareParameters("long id");
List<MSentryPathChange> pathChanges = (List<MSentryPathChange>)query.execute(changeID);
if (pathChanges == null) {
- noSuchUpdate(changeID);
- } else if (pathChanges.size() > 1) {
+ throw noSuchUpdate(changeID);
+ }
+ if (pathChanges.size() > 1) {
throw new Exception("Inconsistent path delta: " + pathChanges.size()
+ " paths for the same id, " + changeID);
}
http://git-wip-us.apache.org/repos/asf/sentry/blob/085b1c2d/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryMetrics.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryMetrics.java b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryMetrics.java
index 6ed2c78..e3691a9 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryMetrics.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryMetrics.java
@@ -122,6 +122,7 @@ public final class SentryMetrics {
sentryStore.getPrivilegeCountGauge());
addGauge(SentryStore.class, "group_count", sentryStore.getGroupCountGauge());
addGauge(SentryStore.class, "hms.waiters", sentryStore.getHMSWaitersCountGauge());
+ addGauge(SentryStore.class, "hms.notification.id", sentryStore.getLastNotificationIdGauge());
gaugesAdded = true;
}
}
@@ -151,7 +152,7 @@ public final class SentryMetrics {
*/
void initReporting(Configuration conf) {
final String reporter = conf.get(ServerConfig.SENTRY_REPORTER);
- if (reporter == null || reporter.isEmpty() || reportingInitialized.getAndSet(true)) {
+ if ((reporter == null) || reporter.isEmpty() || reportingInitialized.getAndSet(true)) {
// Nothing to do, just return
return;
}