-
Notifications
You must be signed in to change notification settings - Fork 435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correct way of using Double Barries #37
Comments
Also, I'd be very interested to know how I can use an Executor for a PathChildrenCache. |
Additionally, it seems like that during the consumeMessage of the DistributedQueue, all other watchers are blocked and no other watch fires before that method has left. |
A quick glance suggests that the QueueConsumer/Executor mechanism is broken in DistributedQueue. I'll work on a fix for that and open a separate issue. |
Thanks Jordan! |
All the listeners in Curator are implemented using a ExecutorService executor = Executors.newSingleThreadExecutor(); // an example thread pool
cache.getListenable().addListener(myListener, myExecutor); You don't have to use a thread pool for the Executor. Use whatever works for your app. |
I am curious to know how DistributedDoubleBarries can be correctly used in the same JVM. Allocate a new DistributedDoubleBarrier instance for each thread that needs to be part of the barrier using the same barrierPath. |
Thanks Jordan. I think I have verified that when the thread waits for the DoubleBarrier in QueueConsumer, other watches in my app are blocked. Do you think if I use a different CuratorFramework for each of my objects it could help resolving this problem? |
I see - so you have a QueueConsumer. When the consumer gets notified of a message it uses a DoubleBarrier. Can you write an example that exposes the problem? |
Sure. I'll work on an example project. It'll be a bit involved but I guess it's worth doing it to make sure that is actually the problem. Also, for leader election, do I have to do a Thread.currentThread().join() at the end of takeLeadership() like you have done in the tests? It seems like the leadership is passed on to the next Participant if I don't do so. |
Sure. I'll work on an example project. It'll be a bit involved but I guess it's worth doing it to make sure that is actually the problem. That will be necessary. I took a look at the code and see no reason why you should be getting the behavior your seeing. BTW - why are you using a Barrier? |
Also, for leader election, do I have to do a Thread.currentThread().join() at the end of takeLeadership() like you have done in the tests? It seems like the leadership is passed on to the next Participant if I don't do so. takeLeadership() should only exit if you no longer want to be the leader. Thread.join() wouldn't be correct as you'd never exit. |
But that's what I want. I want to stay the leader unless my sever dies. What would be the alternative way? |
OK - then sure Thread.join(). |
Oh! I found out what the issue was after trying to create the test case! I think the PathChildrenCache should check for existence of the path and error out if it doesn't to prevent future confusion. Thanks a lot! :) |
This is addressed by #34 and will be in the next release. |
Oh cool. Thanks Jordan for your help. I think I'm good to go for now :) Amir On Mar 6, 2012, at 2:19 PM, Jordan Zimmerman wrote:
|
(moved from ZooKeeper users mailing list)
Dear JZ,
I am curious to know how DistributedDoubleBarries can be correctly used in the same JVM. I basically want to sync the start and end of an execution inside a DistributedQueue's consume method and a Listener call for a PathChildrenCache.
I would truly appreciate an example snippet.
Cheers,
Amir
The text was updated successfully, but these errors were encountered: