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 B9F4D11681 for ; Tue, 20 May 2014 15:32:04 +0000 (UTC) Received: (qmail 95550 invoked by uid 500); 20 May 2014 15:32:04 -0000 Delivered-To: apmail-curator-commits-archive@curator.apache.org Received: (qmail 95485 invoked by uid 500); 20 May 2014 15:32:04 -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 95384 invoked by uid 99); 20 May 2014 15:32:04 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 May 2014 15:32:04 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id D969B9380A4; Tue, 20 May 2014 15:32:03 +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: Tue, 20 May 2014 15:32:03 -0000 Message-Id: <666a240458a0428c861a04b737e356b8@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [01/13] git commit: Making Connection erros less verbose. Only first error is logged with error level; subsequent errors are logged as debug Repository: curator Updated Branches: refs/heads/CURATOR-96 449eeff54 -> 351c67c97 Making Connection erros less verbose. Only first error is logged with error level; subsequent errors are logged as debug Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/ab3ff72d Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/ab3ff72d Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/ab3ff72d Branch: refs/heads/CURATOR-96 Commit: ab3ff72d309378f3c6e166e47e75b7ba49835f20 Parents: 0f7acf7 Author: eceejcr Authored: Fri May 2 23:53:40 2014 +0200 Committer: eceejcr Committed: Fri May 2 23:53:40 2014 +0200 ---------------------------------------------------------------------- .../framework/imps/CuratorFrameworkImpl.java | 29 +++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/curator/blob/ab3ff72d/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 7854308..d6a5973 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 @@ -51,6 +51,7 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; public class CuratorFrameworkImpl implements CuratorFramework @@ -72,6 +73,7 @@ public class CuratorFrameworkImpl implements CuratorFramework private final NamespaceWatcherMap namespaceWatcherMap = new NamespaceWatcherMap(this); private volatile ExecutorService executorService; + private AtomicBoolean logAsErrorConnectionErrors = new AtomicBoolean(false); interface DebugBackgroundListener { @@ -231,7 +233,19 @@ 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); + client.start(); + executorService = Executors.newFixedThreadPool(2, threadFactory); // 1 for listeners, 1 for background ops executorService.submit @@ -509,7 +523,20 @@ public class CuratorFrameworkImpl implements CuratorFramework if ( !Boolean.getBoolean(DebugUtils.PROPERTY_DONT_LOG_CONNECTION_ISSUES) || !(e instanceof KeeperException) ) { - log.error(reason, e); + if ( e instanceof KeeperException.ConnectionLossException || e instanceof CuratorConnectionLossException ) { + if ( logAsErrorConnectionErrors.compareAndSet(true, false) ) + { + log.error(reason, e); + } + else + { + log.debug(reason, e); + } + } + else + { + log.error(reason, e); + } } final String localReason = reason;