Return-Path: X-Original-To: apmail-curator-user-archive@minotaur.apache.org Delivered-To: apmail-curator-user-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D730110CF2 for ; Wed, 28 Aug 2013 14:46:00 +0000 (UTC) Received: (qmail 67293 invoked by uid 500); 28 Aug 2013 14:46:00 -0000 Delivered-To: apmail-curator-user-archive@curator.apache.org Received: (qmail 67213 invoked by uid 500); 28 Aug 2013 14:45:55 -0000 Mailing-List: contact user-help@curator.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@curator.incubator.apache.org Delivered-To: mailing list user@curator.incubator.apache.org Received: (qmail 67093 invoked by uid 99); 28 Aug 2013 14:45:52 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Aug 2013 14:45:52 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of henrikno@gmail.com designates 209.85.215.44 as permitted sender) Received: from [209.85.215.44] (HELO mail-la0-f44.google.com) (209.85.215.44) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Aug 2013 14:45:46 +0000 Received: by mail-la0-f44.google.com with SMTP id eo20so4898289lab.31 for ; Wed, 28 Aug 2013 07:45:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=PrX7Dt4O1btoliy+VVzs4a0RmBkXmKj5AY7ojrlou8o=; b=1D30y7+jXzZyEPpMNj8sZjp853ebU82lmw7UjfpueLcK7n8NOMrUmE4Rd3HwoX/XZI aIW00UHP+0tQSoE9e+FM06CslM4StHBXVTcCf8+HcHU/G1K05+TQ9UAzvhBZAJevuNGf ILzb/oauNYcqGt5Ji2PKFY5Ihb4bDvMcK+TczkL0C0cjxSj6Vh7kfxXd0s6CAHSz/XYf FrrAI0GThOMer1qZ3aMrVhEM4UMMC/BGdU5Adrl7v2pMNbKk7D+faIweZph1R+VFpE1M 4D5Vjt/2bhLMFtlM6IMLaOjk/iIq1XXWFJQQK1HsxkXsKOw465h88J0s2Z8xdzno88Ml KOsg== X-Received: by 10.152.28.105 with SMTP id a9mr1590601lah.41.1377701125125; Wed, 28 Aug 2013 07:45:25 -0700 (PDT) MIME-Version: 1.0 Received: by 10.112.88.131 with HTTP; Wed, 28 Aug 2013 07:44:55 -0700 (PDT) From: Henrik Nordvik Date: Wed, 28 Aug 2013 16:44:55 +0200 Message-ID: Subject: LeaderSelector Executor To: user@curator.incubator.apache.org Content-Type: multipart/alternative; boundary=089e0160a2402b801604e5030a28 X-Virus-Checked: Checked by ClamAV on apache.org --089e0160a2402b801604e5030a28 Content-Type: text/plain; charset=ISO-8859-1 Hi, The LeaderSelector has a constructor which takes in ThreadFactory and Executor as parameters. The "default" constructor uses MoreExecutors.sameThreadExecutor(). I tried using my own ThreadPool with multiple threads, because I thought that was they way of using multiple leaders. When I did that, to my surprise, it started multiple leaders per path. After reading the code it makes sense, it only guarantees that you are the leader when submitting the thread to the executor. It seems to me like using anything other than sameThreadExecutor makes little sense. When would you want to use it? Example snippet: LeaderSelectorListener listener = new MyLeaderSelectorListener("1"); ExecutorService executorPool = Executors.newFixedThreadPool(20); LeaderSelector leaderSelector = new LeaderSelector(client, path, threadFactory, executorPool, listener); leaderSelector.autoRequeue(); leaderSelector.start(); // MyLeaderSelectorListener.takeLeadership is called multiple times here, even though it is in a sleep-loop. -- Henrik Nordvik --089e0160a2402b801604e5030a28 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Hi,

The LeaderSelector has a c= onstructor which takes in ThreadFactory and Executor as parameters. The &qu= ot;default" constructor uses MoreExecutors.sameThreadExecutor().
I tried using my own ThreadPool with multiple threads, because I thought th= at was they way of using multiple leaders.
When I did that, to my surpr= ise, it started multiple leaders per path. After reading the code it makes = sense, it only guarantees that you are the leader when submitting the threa= d to the executor.

It seems to me like using anything other than sameThreadExecutor makes = little sense.
When would you want to use it?


Example snippet:
=A0=A0=A0 LeaderSelectorListener listener =3D new= MyLeaderSelectorListener("1");
=A0=A0=A0 ExecutorService executorPool =3D Executors.newFixedThreadPool(20)= ;
=A0=A0=A0 LeaderSelector leaderSelector =3D new LeaderSelector(client,= path, threadFactory, executorPool, listener);
=A0=A0=A0 leaderSelector.= autoRequeue();
=A0=A0=A0 leaderSelector.start();
=A0=A0=A0 // MyLeaderSelect= orListener.takeLeadership is called multiple times here, even though it is = in a sleep-loop.


<= div>
--
Henrik Nordvik
--089e0160a2402b801604e5030a28--