Repository: ambari Updated Branches: refs/heads/branch-2.5 91e653203 -> 7cffc49cb
AMBARI-20190. LogSearch Integration logs repeated WARN message that should be at DEBUG level. (rnettleton) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/7cffc49c Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/7cffc49c Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/7cffc49c Branch: refs/heads/branch-2.5 Commit: 7cffc49cb87f50113b36d66fcdec2afcf3b65c7a Parents: 91e6532 Author: Bob Nettleton <rnettle...@hortonworks.com> Authored: Fri Feb 24 20:08:58 2017 -0500 Committer: Bob Nettleton <rnettle...@hortonworks.com> Committed: Fri Feb 24 20:08:58 2017 -0500 ---------------------------------------------------------------------- .../logging/LoggingSearchPropertyProvider.java | 10 ++++++++-- .../ambari/server/controller/logging/Utils.java | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/7cffc49c/ambari-server/src/main/java/org/apache/ambari/server/controller/logging/LoggingSearchPropertyProvider.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/logging/LoggingSearchPropertyProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/logging/LoggingSearchPropertyProvider.java index 36c485a..a744e0e 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/logging/LoggingSearchPropertyProvider.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/logging/LoggingSearchPropertyProvider.java @@ -131,8 +131,14 @@ public class LoggingSearchPropertyProvider implements PropertyProvider { // add the logging metadata for this host component resource.setProperty("logging", loggingInfo); } else { - Utils.logErrorMessageWithCounter(LOG, errorLogCounterForLogSearchConnectionExceptions, - "Error occurred while making request to LogSearch service, unable to populate logging properties on this resource"); + if (LOG.isDebugEnabled()) { + String debugMessage = + String.format("Error occurred while making request to LogSearch service, unable to populate logging properties on this resource, component = %s, host = %s", + componentName, hostName); + + Utils.logDebugMessageWithCounter(LOG, errorLogCounterForLogSearchConnectionExceptions, + debugMessage); + } } } http://git-wip-us.apache.org/repos/asf/ambari/blob/7cffc49c/ambari-server/src/main/java/org/apache/ambari/server/controller/logging/Utils.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/logging/Utils.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/logging/Utils.java index 969d442..3350414 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/logging/Utils.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/logging/Utils.java @@ -62,4 +62,18 @@ public class Utils { atomicInteger.compareAndSet(maxCount, 0); } } + + static void logDebugMessageWithCounter(Logger logger, AtomicInteger atomicInteger, String errorMessage) { + logDebugMessageWithCounter(logger, atomicInteger, errorMessage, WAIT_COUNT_MAX); + } + + static void logDebugMessageWithCounter(Logger logger, AtomicInteger atomicInteger, String debugMessage, int maxCount) { + if (atomicInteger.getAndIncrement() == 0) { + // only log the message once every maxCount attempts + logger.debug(debugMessage); + } else { + // if we've hit maxCount attempts, reset the counter + atomicInteger.compareAndSet(maxCount, 0); + } + } }