Skip to content
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

Recipe: Barrier #42

Open
eric opened this issue Aug 27, 2012 · 2 comments
Open

Recipe: Barrier #42

eric opened this issue Aug 27, 2012 · 2 comments

Comments

@eric
Copy link
Member

eric commented Aug 27, 2012

From http://zookeeper.apache.org/doc/trunk/recipes.html

Distributed systems use barriers to block processing of a set of nodes until a condition is met at which time all the nodes are allowed to proceed. Barriers are implemented in ZooKeeper by designating a barrier node. The barrier is in place if the barrier node exists. Here's the pseudo code:

  1. Client calls the ZooKeeper API's exists() function on the barrier node, with watch set to true.
  2. If exists() returns false, the barrier is gone and the client proceeds
  3. Else, if exists() returns true, the clients wait for a watch event from ZooKeeper for the barrier node.
  4. When the watch event is triggered, the client reissues the exists( ) call, again waiting until the barrier node is removed.

I plan on implementing this at some point if no one else does first...

I haven't decided if it makes sense to be in this gem or in a recipes gem. It seems reasonable it should be in the same place the locker is...

@ryanlecompte
Copy link
Member

This would be a great addition for redis_failover, since it would be used for coordinated failover.

I had two rough implementations of a latch / barrier based on ZK groups. I am sure they have holes, however.

Latch: https://gist.github.com/3f262126207fe55141d2
Barrier: https://gist.github.com/aae42d31922f07bc5912

It probably makes sense to implement the barrier based on the recipe that @eric pasted above, as opposed to trying to overlay it on top of ZK groups. Not sure.

@slyphon
Copy link
Contributor

slyphon commented Aug 27, 2012

I've been thinking about this for a while, and I would like to make the
following changes to the gems for release 2.0

  • remove the old deprecated election stuff
  • move the locker into its own gem as suggested. I think this should be a
    "zk-recipes" gem with Locker, Barrier, Semaphore, etc.
  • possibly have main zk gem depend on the recipes gem, as people are
    probably going to want those building blocks.

The next 3 weeks or so are going to be pretty intensive as I transition to
a new job, so I don't know how much active participation I'll be able to do.

On Sunday, August 26, 2012, Eric Lindvall wrote:

From http://zookeeper.apache.org/doc/trunk/recipes.html

Distributed systems use barriers to block processing of a set of nodes
until a condition is met at which time all the nodes are allowed to
proceed. Barriers are implemented in ZooKeeper by designating a barrier
node. The barrier is in place if the barrier node exists. Here's the pseudo
code:

  1. Client calls the ZooKeeper API's exists() function on the barrier
    node, with watch set to true.

  2. If exists() returns false, the barrier is gone and the client
    proceeds

  3. Else, if exists() returns true, the clients wait for a watch event
    from ZooKeeper for the barrier node.

  4. When the watch event is triggered, the client reissues the exists(
    ) call, again waiting until the barrier node is removed.

    I plan on implementing this at some point if no one else does first...

I haven't decided if it makes sense to be in this gem or in a recipes gem.
It seems reasonable it should be in the same place the locker is...


Reply to this email directly or view it on GitHubhttps://github.com//issues/42.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants