sentry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lsk...@apache.org
Subject git commit: SENTRY-511: Always enable metric collection and do not fail when all metric reporters are disabled (Sravya Tirukkovalur via Lenni Kuff)
Date Fri, 31 Oct 2014 05:17:17 GMT
Repository: incubator-sentry
Updated Branches:
  refs/heads/master de0cc9e7f -> f81a224fc


SENTRY-511: Always enable metric collection and do not fail when all metric reporters are
disabled (Sravya Tirukkovalur via Lenni Kuff)


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

Branch: refs/heads/master
Commit: f81a224fc757c6204adf1aa9b7700cae38b05343
Parents: de0cc9e
Author: Lenni Kuff <lskuff@cloudera.com>
Authored: Thu Oct 30 22:15:07 2014 -0700
Committer: Lenni Kuff <lskuff@cloudera.com>
Committed: Thu Oct 30 22:15:07 2014 -0700

----------------------------------------------------------------------
 .../provider/db/service/thrift/SentryMetrics.java    | 10 +++++++---
 .../service/thrift/SentryPolicyStoreProcessor.java   | 15 ++++++++-------
 .../apache/sentry/service/thrift/SentryService.java  | 15 +++++++++------
 .../sentry/service/thrift/ServiceConstants.java      |  8 +++++---
 .../hive/AbstractTestWithStaticConfiguration.java    |  1 -
 5 files changed, 29 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/f81a224f/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 6bd7e2b..55bec0b 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
@@ -40,6 +40,7 @@ import java.util.concurrent.TimeUnit;
 public class SentryMetrics {
   private static SentryMetrics sentryMetrics = null;
   private boolean reportingInitialized = false;
+  private boolean gaugesAdded = false;
 
   public final Timer createRoleTimer = SentryMetricsServletContextListener.METRIC_REGISTRY.timer(
       MetricRegistry.name(SentryPolicyStoreProcessor.class, "create-role"));
@@ -84,9 +85,12 @@ public class SentryMetrics {
   }
 
   public void addSentryStoreGauges(SentryStore sentryStore) {
-    addGauge(SentryStore.class, "role_count", sentryStore.getRoleCountGauge());
-    addGauge(SentryStore.class, "privilege_count", sentryStore.getPrivilegeCountGauge());
-    addGauge(SentryStore.class, "group_count", sentryStore.getGroupCountGauge());
+    if(!gaugesAdded) {
+      addGauge(SentryStore.class, "role_count", sentryStore.getRoleCountGauge());
+      addGauge(SentryStore.class, "privilege_count", sentryStore.getPrivilegeCountGauge());
+      addGauge(SentryStore.class, "group_count", sentryStore.getGroupCountGauge());
+      gaugesAdded = true;
+    }
   }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/f81a224f/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyStoreProcessor.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyStoreProcessor.java
b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyStoreProcessor.java
index 01077da..b20e71e 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyStoreProcessor.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyStoreProcessor.java
@@ -81,22 +81,23 @@ public class SentryPolicyStoreProcessor implements SentryPolicyService.Iface
{
     isReady = true;
     adminGroups = ImmutableSet.copyOf(toTrimedLower(Sets.newHashSet(conf.getStrings(
         ServerConfig.ADMIN_GROUPS, new String[]{}))));
-    initReporting();
+    initMetrics();
   }
 
-  private void initReporting() {
-    String sentryReporting = conf.get(ServerConfig.SENTRY_REPORTING);
+  private void initMetrics() {
+    sentryMetrics = SentryMetrics.getInstance();
+    sentryMetrics.addSentryStoreGauges(sentryStore);
+
+    String sentryReporting = conf.get(ServerConfig.SENTRY_REPORTER);
     if( sentryReporting != null) {
       SentryMetrics.Reporting reporting;
       try {
         reporting = SentryMetrics.Reporting.valueOf(sentryReporting.toUpperCase());
-        sentryMetrics = SentryMetrics.getInstance();
-        sentryMetrics.addSentryStoreGauges(sentryStore);
         sentryMetrics.initReporting(reporting);
 
       } catch (IllegalArgumentException e) {
-        LOGGER.warn("Metrics reporting not configured correctly, please set " + ServerConfig.SENTRY_REPORTING
+
-            " to: " + ServerConfig.SENTRY_REPORTING_CONSOLE + "/" + ServerConfig.SENTRY_REPORTING_JMX);
+        LOGGER.warn("Metrics reporting not configured correctly, please set " + ServerConfig.SENTRY_REPORTER
+
+            " to: " + ServerConfig.SENTRY_REPORTER_CONSOLE + "/" + ServerConfig.SENTRY_REPORTER_JMX);
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/f81a224f/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/SentryService.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/SentryService.java
b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/SentryService.java
index 8915b4d..ec17480 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/SentryService.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/SentryService.java
@@ -27,7 +27,6 @@ import java.net.ServerSocket;
 import java.security.PrivilegedExceptionAction;
 import java.util.ArrayList;
 import java.util.EventListener;
-import java.util.HashSet;
 import java.util.List;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutorService;
@@ -222,11 +221,15 @@ public class SentryService implements Callable {
   }
 
   private void startSentryWebServer() throws Exception{
-    List<EventListener> listenerList = new ArrayList<EventListener>();
-    listenerList.add(new SentryHealthCheckServletContextListener());
-    listenerList.add(new SentryMetricsServletContextListener());
-    sentryWebServer = new SentryWebServer(listenerList, webServerPort);
-    sentryWebServer.start();
+    Boolean sentryReportingEnable = conf.getBoolean(ServerConfig.SENTRY_WEB_ENABLE,
+        ServerConfig.SENTRY_WEB_ENABLE_DEFAULT);
+    if(sentryReportingEnable) {
+      List<EventListener> listenerList = new ArrayList<EventListener>();
+      listenerList.add(new SentryHealthCheckServletContextListener());
+      listenerList.add(new SentryMetricsServletContextListener());
+      sentryWebServer = new SentryWebServer(listenerList, webServerPort);
+      sentryWebServer.start();
+    }
 
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/f81a224f/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/ServiceConstants.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/ServiceConstants.java
b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/ServiceConstants.java
index 29a7a1c..bc86963 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/ServiceConstants.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/ServiceConstants.java
@@ -123,11 +123,13 @@ public class ServiceConstants {
     .put("javax.jdo.option.Multithreaded", "true")
     .build();
 
+    public static final String SENTRY_WEB_ENABLE = "sentry.service.web.enable";
+    public static final Boolean SENTRY_WEB_ENABLE_DEFAULT = false;
     public static final String SENTRY_WEB_PORT = "sentry.service.web.port";
     public static final int SENTRY_WEB_PORT_DEFAULT = 51000;
-    public static final String SENTRY_REPORTING = "sentry.service.reporting";
-    public static final String SENTRY_REPORTING_JMX = SentryMetrics.Reporting.JMX.name();
//case insensitive
-    public static final String SENTRY_REPORTING_CONSOLE = SentryMetrics.Reporting.CONSOLE.name();//case
insensitive
+    public static final String SENTRY_REPORTER = "sentry.service.reporter";
+    public static final String SENTRY_REPORTER_JMX = SentryMetrics.Reporting.JMX.name();
//case insensitive
+    public static final String SENTRY_REPORTER_CONSOLE = SentryMetrics.Reporting.CONSOLE.name();//case
insensitive
 
 
   }

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/f81a224f/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/AbstractTestWithStaticConfiguration.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/AbstractTestWithStaticConfiguration.java
b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/AbstractTestWithStaticConfiguration.java
index f6b6ad4..84b91c3 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/AbstractTestWithStaticConfiguration.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/AbstractTestWithStaticConfiguration.java
@@ -360,7 +360,6 @@ public abstract class AbstractTestWithStaticConfiguration {
     for (Map.Entry<String, String> entry : properties.entrySet()) {
       sentryConf.set(entry.getKey(), entry.getValue());
     }
-    sentryConf.set(ServerConfig.SENTRY_REPORTING, ServerConfig.SENTRY_REPORTING_CONSOLE);
     sentryServer = new SentryServiceFactory().create(sentryConf);
     properties.put(ClientConfig.SERVER_RPC_ADDRESS, sentryServer.getAddress()
         .getHostName());


Mime
View raw message