This looks very broken to me. Please open an issue for this.

-Jordan

On Aug 28, 2013, at 7:44 AM, Henrik Nordvik <[email protected]> wrote:

> 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

Reply via email to