Return-Path: X-Original-To: apmail-curator-commits-archive@minotaur.apache.org Delivered-To: apmail-curator-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9039B11F5B for ; Wed, 14 May 2014 14:49:10 +0000 (UTC) Received: (qmail 24397 invoked by uid 500); 14 May 2014 14:42:30 -0000 Delivered-To: apmail-curator-commits-archive@curator.apache.org Received: (qmail 24146 invoked by uid 500); 14 May 2014 14:42:30 -0000 Mailing-List: contact commits-help@curator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@curator.apache.org Delivered-To: mailing list commits@curator.apache.org Received: (qmail 23993 invoked by uid 99); 14 May 2014 14:42:30 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 May 2014 14:42:30 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id CD0708C4278; Wed, 14 May 2014 14:42:29 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: randgalt@apache.org To: commits@curator.apache.org Date: Wed, 14 May 2014 14:42:30 -0000 Message-Id: <5b4a33fcadbd477d8362257388fce533@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/4] git commit: Added System property to choose if connection issues are always logged as error level or only first issue is logged as error level, and subsequent issues are logged as debug. By default only first issue is logged as error Added System property to choose if connection issues are always logged as error level or only first issue is logged as error level, and subsequent issues are logged as debug. By default only first issue is logged as error Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/048688a3 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/048688a3 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/048688a3 Branch: refs/heads/CURATOR-90 Commit: 048688a36856d1ef7e080410b8818952210fb1e8 Parents: ab3ff72 Author: eceejcr Authored: Sun May 11 01:05:03 2014 +0200 Committer: eceejcr Committed: Sun May 11 01:05:03 2014 +0200 ---------------------------------------------------------------------- .../org/apache/curator/utils/DebugUtils.java | 1 + .../framework/imps/CuratorFrameworkImpl.java | 33 ++++++++++++-------- 2 files changed, 21 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/curator/blob/048688a3/curator-client/src/main/java/org/apache/curator/utils/DebugUtils.java ---------------------------------------------------------------------- diff --git a/curator-client/src/main/java/org/apache/curator/utils/DebugUtils.java b/curator-client/src/main/java/org/apache/curator/utils/DebugUtils.java index 64c2d6e..0ce2729 100644 --- a/curator-client/src/main/java/org/apache/curator/utils/DebugUtils.java +++ b/curator-client/src/main/java/org/apache/curator/utils/DebugUtils.java @@ -22,6 +22,7 @@ public class DebugUtils { public static final String PROPERTY_LOG_EVENTS = "curator-log-events"; public static final String PROPERTY_DONT_LOG_CONNECTION_ISSUES = "curator-dont-log-connection-problems"; + public static final String PROPERTY_LOG_ALL_CONNECTION_ISSUES_AS_ERROR_LEVEL = "curator-log-all-connection-issues-as-error-level"; private DebugUtils() { http://git-wip-us.apache.org/repos/asf/curator/blob/048688a3/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java ---------------------------------------------------------------------- diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java index d6a5973..3a78967 100644 --- a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java +++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java @@ -56,7 +56,8 @@ import java.util.concurrent.atomic.AtomicReference; public class CuratorFrameworkImpl implements CuratorFramework { - private final Logger log = LoggerFactory.getLogger(getClass()); + + private final Logger log = LoggerFactory.getLogger(getClass()); private final CuratorZookeeperClient client; private final ListenerContainer listeners; private final ListenerContainer unhandledErrorListeners; @@ -73,7 +74,9 @@ public class CuratorFrameworkImpl implements CuratorFramework private final NamespaceWatcherMap namespaceWatcherMap = new NamespaceWatcherMap(this); private volatile ExecutorService executorService; - private AtomicBoolean logAsErrorConnectionErrors = new AtomicBoolean(false); + private final AtomicBoolean logAsErrorConnectionErrors = new AtomicBoolean(false); + + private static final boolean LOG_ALL_CONNECTION_ISSUES_AS_ERROR_LEVEL = Boolean.getBoolean(DebugUtils.PROPERTY_LOG_ALL_CONNECTION_ISSUES_AS_ERROR_LEVEL); interface DebugBackgroundListener { @@ -233,16 +236,20 @@ public class CuratorFrameworkImpl implements CuratorFramework try { connectionStateManager.start(); // ordering dependency - must be called before client.start() - ConnectionStateListener listener = new ConnectionStateListener() { - @Override - public void stateChanged(CuratorFramework client, ConnectionState newState) { - if ( ConnectionState.CONNECTED == newState || ConnectionState.RECONNECTED == newState ) - { - logAsErrorConnectionErrors.set(true); - } - } - }; - this.getConnectionStateListenable().addListener(listener); + + final ConnectionStateListener listener = new ConnectionStateListener() + { + @Override + public void stateChanged(CuratorFramework client, ConnectionState newState) + { + if ( ConnectionState.CONNECTED == newState || ConnectionState.RECONNECTED == newState ) + { + logAsErrorConnectionErrors.set(true); + } + } + }; + + this.getConnectionStateListenable().addListener(listener); client.start(); @@ -524,7 +531,7 @@ public class CuratorFrameworkImpl implements CuratorFramework if ( !Boolean.getBoolean(DebugUtils.PROPERTY_DONT_LOG_CONNECTION_ISSUES) || !(e instanceof KeeperException) ) { if ( e instanceof KeeperException.ConnectionLossException || e instanceof CuratorConnectionLossException ) { - if ( logAsErrorConnectionErrors.compareAndSet(true, false) ) + if ( LOG_ALL_CONNECTION_ISSUES_AS_ERROR_LEVEL || logAsErrorConnectionErrors.compareAndSet(true, false) ) { log.error(reason, e); }