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 5AEE317E7C for ; Mon, 12 Jan 2015 21:03:57 +0000 (UTC) Received: (qmail 48465 invoked by uid 500); 12 Jan 2015 21:03:59 -0000 Delivered-To: apmail-curator-commits-archive@curator.apache.org Received: (qmail 48396 invoked by uid 500); 12 Jan 2015 21:03:59 -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 48371 invoked by uid 99); 12 Jan 2015 21:03:58 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 Jan 2015 21:03:58 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id A36DEA026EC; Mon, 12 Jan 2015 21:03:58 +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: Mon, 12 Jan 2015 21:03:59 -0000 Message-Id: In-Reply-To: <3f74bc8df2a340b3accaec0e7cc63e60@git.apache.org> References: <3f74bc8df2a340b3accaec0e7cc63e60@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/3] curator git commit: Merge branch 'CURATOR-111' of https://github.com/kambatla/curator into CURATOR-111 Merge branch 'CURATOR-111' of https://github.com/kambatla/curator into CURATOR-111 Conflicts: curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/58ecd64f Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/58ecd64f Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/58ecd64f Branch: refs/heads/master Commit: 58ecd64f0b0b05590f2bcd350d17c173a5c791ab Parents: 84699d3 71dc640 Author: randgalt Authored: Mon Jan 12 15:55:20 2015 -0500 Committer: randgalt Committed: Mon Jan 12 15:55:20 2015 -0500 ---------------------------------------------------------------------- .../org/apache/curator/framework/AuthInfo.java | 51 ++++++++++++++++++++ .../framework/CuratorFrameworkFactory.java | 23 +++++++++ .../framework/imps/CuratorFrameworkImpl.java | 42 ++++++---------- .../curator/framework/imps/TestFramework.java | 44 +++++++++++++++++ 4 files changed, 132 insertions(+), 28 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/curator/blob/58ecd64f/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/curator/blob/58ecd64f/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java ---------------------------------------------------------------------- diff --cc curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java index fc462d4,f7b08a6..c38617d --- 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 @@@ -60,60 -60,36 +63,39 @@@ import java.util.concurrent.atomic.Atom public class CuratorFrameworkImpl implements CuratorFramework { - - private final Logger log = LoggerFactory.getLogger(getClass()); - private final CuratorZookeeperClient client; - private final ListenerContainer listeners; - private final ListenerContainer unhandledErrorListeners; - private final ThreadFactory threadFactory; - private final BlockingQueue> backgroundOperations; - private final NamespaceImpl namespace; - private final ConnectionStateManager connectionStateManager; - private final List authInfos; - private final byte[] defaultData; - private final FailedDeleteManager failedDeleteManager; - private final CompressionProvider compressionProvider; - private final ACLProvider aclProvider; - private final NamespaceFacadeCache namespaceFacadeCache; - private final NamespaceWatcherMap namespaceWatcherMap = new NamespaceWatcherMap(this); - - private volatile ExecutorService executorService; - private final AtomicBoolean logAsErrorConnectionErrors = new AtomicBoolean(false); - - private static final boolean LOG_ALL_CONNECTION_ISSUES_AS_ERROR_LEVEL = !Boolean.getBoolean(DebugUtils.PROPERTY_LOG_ONLY_FIRST_CONNECTION_ISSUE_AS_ERROR_LEVEL); + private final Logger log = LoggerFactory.getLogger(getClass()); + private final CuratorZookeeperClient client; + private final ListenerContainer listeners; + private final ListenerContainer unhandledErrorListeners; + private final ThreadFactory threadFactory; + private final int maxCloseWaitMs; + private final BlockingQueue> backgroundOperations; + private final NamespaceImpl namespace; + private final ConnectionStateManager connectionStateManager; - private final AtomicReference authInfo = new AtomicReference(); ++ private final List authInfos; + private final byte[] defaultData; + private final FailedDeleteManager failedDeleteManager; + private final CompressionProvider compressionProvider; + private final ACLProvider aclProvider; + private final NamespaceFacadeCache namespaceFacadeCache; + private final NamespaceWatcherMap namespaceWatcherMap = new NamespaceWatcherMap(this); + + private volatile ExecutorService executorService; + private final AtomicBoolean logAsErrorConnectionErrors = new AtomicBoolean(false); + + private static final boolean LOG_ALL_CONNECTION_ISSUES_AS_ERROR_LEVEL = !Boolean.getBoolean(DebugUtils.PROPERTY_LOG_ONLY_FIRST_CONNECTION_ISSUE_AS_ERROR_LEVEL); interface DebugBackgroundListener { - void listen(OperationAndData data); + void listen(OperationAndData data); } - volatile DebugBackgroundListener debugListener = null; - private final AtomicReference state; + volatile DebugBackgroundListener debugListener = null; + @VisibleForTesting + public volatile UnhandledErrorListener debugUnhandledErrorListener = null; + + private final AtomicReference state; - private static class AuthInfo - { - final String scheme; - final byte[] auth; - - private AuthInfo(String scheme, byte[] auth) - { - this.scheme = scheme; - this.auth = auth; - } - - @Override - public String toString() - { - return "AuthInfo{" + - "scheme='" + scheme + '\'' + - ", auth=" + Arrays.toString(auth) + - '}'; - } - } - public CuratorFrameworkImpl(CuratorFrameworkFactory.Builder builder) { ZookeeperFactory localZookeeperFactory = makeZookeeperFactory(builder.getZookeeperFactory()); @@@ -138,12 -135,17 +120,17 @@@ aclProvider = builder.getAclProvider(); state = new AtomicReference(CuratorFrameworkState.LATENT); - byte[] builderDefaultData = builder.getDefaultData(); + byte[] builderDefaultData = builder.getDefaultData(); defaultData = (builderDefaultData != null) ? Arrays.copyOf(builderDefaultData, builderDefaultData.length) : new byte[0]; + authInfos = new ArrayList(); if ( builder.getAuthScheme() != null ) { - authInfo.set(new AuthInfo(builder.getAuthScheme(), builder.getAuthValue())); + authInfos.add(new AuthInfo(builder.getAuthScheme(), builder.getAuthValue())); + } + if ( builder.getAuthInfos() != null ) + { + authInfos.addAll(builder.getAuthInfos()); } failedDeleteManager = new FailedDeleteManager(this); @@@ -238,8 -226,9 +225,7 @@@ log.info("Starting"); if ( !state.compareAndSet(CuratorFrameworkState.LATENT, CuratorFrameworkState.STARTED) ) { - IllegalStateException ise = new IllegalStateException("Cannot be started more than once"); - throw ise; - IllegalStateException error = new IllegalStateException(); - log.error("Cannot be started more than once", error); - throw error; ++ throw new IllegalStateException("Cannot be started more than once"); } try http://git-wip-us.apache.org/repos/asf/curator/blob/58ecd64f/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java ---------------------------------------------------------------------- diff --cc curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java index 5a640db,0f51b25..c98dd0f --- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java +++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java @@@ -19,6 -19,9 +19,7 @@@ package org.apache.curator.framework.imps; import com.google.common.collect.Lists; + import org.apache.curator.framework.AuthInfo; -import org.apache.curator.test.BaseClassForTests; -import org.apache.curator.utils.CloseableUtils; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.CuratorFrameworkFactory; import org.apache.curator.framework.api.BackgroundCallback; @@@ -41,6 -43,8 +42,7 @@@ import org.apache.zookeeper.data.ACL import org.apache.zookeeper.data.Stat; import org.testng.Assert; import org.testng.annotations.Test; - + import java.util.ArrayList; import java.util.List; import java.util.concurrent.BlockingQueue; import java.util.concurrent.CountDownLatch;