knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject knox git commit: KNOX-986 - JMX Metric Reporter and OutOfMemory Issues (Zsombor Gegesy via Sandeep More)
Date Wed, 02 Aug 2017 19:48:17 GMT
Repository: knox
Updated Branches:
  refs/heads/master 659e02ce3 -> cbe21a0a0


KNOX-986 - JMX Metric Reporter and OutOfMemory Issues (Zsombor Gegesy via Sandeep More)


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

Branch: refs/heads/master
Commit: cbe21a0a0728106a8bdc7b85b5094a8b2ac5e7df
Parents: 659e02c
Author: Sandeep More <more@apache.org>
Authored: Wed Aug 2 15:48:00 2017 -0400
Committer: Sandeep More <more@apache.org>
Committed: Wed Aug 2 15:48:00 2017 -0400

----------------------------------------------------------------------
 .../gateway/config/impl/GatewayConfigImpl.java  |  4 +--
 .../metrics/impl/DefaultMetricsService.java     | 37 ++++++++++++--------
 .../config/impl/GatewayConfigImplTest.java      |  4 +--
 .../metrics/impl/DefaultMetricsServiceTest.java | 15 +++++++-
 4 files changed, 41 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/cbe21a0a/gateway-server/src/main/java/org/apache/hadoop/gateway/config/impl/GatewayConfigImpl.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/hadoop/gateway/config/impl/GatewayConfigImpl.java
b/gateway-server/src/main/java/org/apache/hadoop/gateway/config/impl/GatewayConfigImpl.java
index 79140e0..3b7d19e 100644
--- a/gateway-server/src/main/java/org/apache/hadoop/gateway/config/impl/GatewayConfigImpl.java
+++ b/gateway-server/src/main/java/org/apache/hadoop/gateway/config/impl/GatewayConfigImpl.java
@@ -706,13 +706,13 @@ public class GatewayConfigImpl extends Configuration implements GatewayConfig
{
 
   @Override
   public boolean isMetricsEnabled() {
-    String metricsEnabled = get( METRICS_ENABLED, "true" );
+    String metricsEnabled = get( METRICS_ENABLED, "false" );
     return "true".equals(metricsEnabled);
   }
 
   @Override
   public boolean isJmxMetricsReportingEnabled() {
-    String enabled = get( JMX_METRICS_REPORTING_ENABLED, "true" );
+    String enabled = get( JMX_METRICS_REPORTING_ENABLED, "false" );
     return "true".equals(enabled);
   }
 

http://git-wip-us.apache.org/repos/asf/knox/blob/cbe21a0a/gateway-server/src/main/java/org/apache/hadoop/gateway/services/metrics/impl/DefaultMetricsService.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/hadoop/gateway/services/metrics/impl/DefaultMetricsService.java
b/gateway-server/src/main/java/org/apache/hadoop/gateway/services/metrics/impl/DefaultMetricsService.java
index c2a461a..f912256 100644
--- a/gateway-server/src/main/java/org/apache/hadoop/gateway/services/metrics/impl/DefaultMetricsService.java
+++ b/gateway-server/src/main/java/org/apache/hadoop/gateway/services/metrics/impl/DefaultMetricsService.java
@@ -48,18 +48,23 @@ public class DefaultMetricsService implements MetricsService {
 
   private MetricsContext context;
 
+  private GatewayConfig config;
+
   public static MetricRegistry getMetricRegistry() {
     return metrics;
   }
 
   @Override
   public void init(GatewayConfig config, Map<String, String> options) throws ServiceLifecycleException
{
+    this.config = config;
     context = new DefaultMetricsContext(this);
     context.setProperty(METRICS_REGISTRY, getMetricRegistry());
     instrumentationProviders = new HashMap<>();
     metricsReporters = new ArrayList<>();
-    loadInstrumentationProviders();
-    loadAndInitReporters(config);
+    if (config.isMetricsEnabled()) {
+      loadInstrumentationProviders();
+      loadAndInitReporters(config);
+    }
   }
 
   private void loadInstrumentationProviders() {
@@ -86,12 +91,14 @@ public class DefaultMetricsService implements MetricsService {
 
   @Override
   public void start() throws ServiceLifecycleException {
-    for (MetricsReporter reporter : metricsReporters) {
-      if ( reporter.isEnabled() ) {
-        try {
-          reporter.start(context);
-        } catch ( MetricsReporterException e ) {
-          LOG.failedToStartReporter(reporter.getName(), e);
+    if (config.isMetricsEnabled()) {
+      for (MetricsReporter reporter : metricsReporters) {
+        if ( reporter.isEnabled() ) {
+          try {
+            reporter.start(context);
+          } catch ( MetricsReporterException e ) {
+            LOG.failedToStartReporter(reporter.getName(), e);
+          }
         }
       }
     }
@@ -99,12 +106,14 @@ public class DefaultMetricsService implements MetricsService {
 
   @Override
   public void stop() throws ServiceLifecycleException {
-    for (MetricsReporter reporter : metricsReporters) {
-      if (reporter.isEnabled()) {
-        try {
-          reporter.stop();
-        } catch ( MetricsReporterException e ) {
-          LOG.failedToStopReporter(reporter.getName(), e);
+    if (config.isMetricsEnabled()) {
+      for (MetricsReporter reporter : metricsReporters) {
+        if (reporter.isEnabled()) {
+          try {
+            reporter.stop();
+          } catch ( MetricsReporterException e ) {
+            LOG.failedToStopReporter(reporter.getName(), e);
+          }
         }
       }
     }

http://git-wip-us.apache.org/repos/asf/knox/blob/cbe21a0a/gateway-server/src/test/java/org/apache/hadoop/gateway/config/impl/GatewayConfigImplTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/hadoop/gateway/config/impl/GatewayConfigImplTest.java
b/gateway-server/src/test/java/org/apache/hadoop/gateway/config/impl/GatewayConfigImplTest.java
index 8c8835c..a9347f4 100644
--- a/gateway-server/src/test/java/org/apache/hadoop/gateway/config/impl/GatewayConfigImplTest.java
+++ b/gateway-server/src/test/java/org/apache/hadoop/gateway/config/impl/GatewayConfigImplTest.java
@@ -184,8 +184,8 @@ public class GatewayConfigImplTest {
   public void testMetricsSettings() {
     GatewayConfigImpl config = new GatewayConfigImpl();
     //test defaults
-    assertThat(config.isMetricsEnabled(), is(true));
-    assertThat(config.isJmxMetricsReportingEnabled(), is(true));
+    assertThat(config.isMetricsEnabled(), is(false));
+    assertThat(config.isJmxMetricsReportingEnabled(), is(false));
     assertThat(config.isGraphiteMetricsReportingEnabled(), is(false));
     assertThat(config.getGraphiteHost(), is("localhost"));
     assertThat(config.getGraphitePort(), is(32772));

http://git-wip-us.apache.org/repos/asf/knox/blob/cbe21a0a/gateway-server/src/test/java/org/apache/hadoop/gateway/services/metrics/impl/DefaultMetricsServiceTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/hadoop/gateway/services/metrics/impl/DefaultMetricsServiceTest.java
b/gateway-server/src/test/java/org/apache/hadoop/gateway/services/metrics/impl/DefaultMetricsServiceTest.java
index 6e9b4a9..6f549b0 100644
--- a/gateway-server/src/test/java/org/apache/hadoop/gateway/services/metrics/impl/DefaultMetricsServiceTest.java
+++ b/gateway-server/src/test/java/org/apache/hadoop/gateway/services/metrics/impl/DefaultMetricsServiceTest.java
@@ -46,10 +46,22 @@ public class DefaultMetricsServiceTest {
   }
 
   @Test
-  public void instrumentationProvidersLoading() throws Exception {
+  public void instrumentationProvidersLoadingDefaultIsEmpty() throws Exception {
     DefaultMetricsService service = new DefaultMetricsService();
     service.init(new GatewayConfigImpl(), null);
     Map<Class<?>, InstrumentationProvider> map = service.getInstrumentationProviders();
+    Assert.assertTrue(map.entrySet().isEmpty());
+    Assert.assertNull(service.getInstrumented(HttpClientBuilder.class));
+
+  }
+
+  @Test
+  public void instrumentationProvidersLoading() throws Exception {
+    DefaultMetricsService service = new DefaultMetricsService();
+    GatewayConfigImpl config = new GatewayConfigImpl();
+    config.set(GatewayConfigImpl.METRICS_ENABLED, "true");
+    service.init(config, null);
+    Map<Class<?>, InstrumentationProvider> map = service.getInstrumentationProviders();
     Assert.assertTrue(map.entrySet().size() >= 2);
     Assert.assertNotNull(service.getInstrumented(HttpClientBuilder.class));
 
@@ -59,6 +71,7 @@ public class DefaultMetricsServiceTest {
   public void reportersLoading() throws Exception {
     DefaultMetricsService service = new DefaultMetricsService();
     GatewayConfigImpl config = new GatewayConfigImpl();
+    config.set(GatewayConfigImpl.METRICS_ENABLED, "true");
     config.set(GatewayConfigImpl.JMX_METRICS_REPORTING_ENABLED, "false");
     service.init(config, null);
     List<MetricsReporter> reporters = service.getMetricsReporters();


Mime
View raw message