You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by mp...@apache.org on 2016/03/24 20:33:22 UTC

ambari git commit: AMBARI-15567. UrlStreamProvider emits critical exceptions in debug mode only. (mpapirkovskyy)

Repository: ambari
Updated Branches:
  refs/heads/trunk 126c226d8 -> e308b8a96


AMBARI-15567. UrlStreamProvider emits critical exceptions in debug mode only. (mpapirkovskyy)


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

Branch: refs/heads/trunk
Commit: e308b8a966aad651c8ba1fcd5e63181400538460
Parents: 126c226
Author: Myroslav Papirkovskyi <mp...@hortonworks.com>
Authored: Thu Mar 24 20:00:03 2016 +0200
Committer: Myroslav Papirkovskyi <mp...@hortonworks.com>
Committed: Thu Mar 24 21:33:17 2016 +0200

----------------------------------------------------------------------
 .../ThreadPoolEnabledPropertyProvider.java      | 26 +++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e308b8a9/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/ThreadPoolEnabledPropertyProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/ThreadPoolEnabledPropertyProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/ThreadPoolEnabledPropertyProvider.java
index 0e7a1bd..fba1ef5 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/ThreadPoolEnabledPropertyProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/ThreadPoolEnabledPropertyProvider.java
@@ -18,6 +18,8 @@
 
 package org.apache.ambari.server.controller.metrics;
 
+import com.google.common.cache.Cache;
+import com.google.common.cache.CacheBuilder;
 import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.controller.internal.AbstractPropertyProvider;
 import org.apache.ambari.server.controller.internal.PropertyInfo;
@@ -79,6 +81,10 @@ public abstract class ThreadPoolEnabledPropertyProvider extends AbstractProperty
   protected long populateTimeout = DEFAULT_POPULATE_TIMEOUT_MILLIS;
   public static final String TIMED_OUT_MSG = "Timed out waiting for metrics.";
 
+  private static final Cache<String, Throwable> exceptionsCache = CacheBuilder.newBuilder()
+          .expireAfterWrite(5, TimeUnit.MINUTES)
+          .build();
+
   // ----- Constructors ------------------------------------------------------
 
   /**
@@ -225,10 +231,24 @@ public abstract class ThreadPoolEnabledPropertyProvider extends AbstractProperty
    *
    * @return the error message that was logged
    */
-  protected static String logException(Throwable throwable) {
-    String msg = "Caught exception getting JMX metrics : " + throwable.getLocalizedMessage();
+  protected static String logException(final Throwable throwable) {
+    final String msg = "Caught exception getting JMX metrics : " + throwable.getLocalizedMessage();
+
+    if (LOG.isDebugEnabled()) {
+      LOG.debug(msg, throwable);
+    } else {
+      try {
+        exceptionsCache.get(msg, new Callable<Throwable>() {
+          @Override
+          public Throwable call() {
+            LOG.error(msg + ", skipping same exceptions for next 5 minutes", throwable);
+            return throwable;
+          }
+        });
+      } catch (ExecutionException ignored) {
+      }
+    }
 
-    LOG.debug(msg, throwable);
 
     return msg;
   }