org.inria.myriads.snoozenode.groupmanager.leadelection.api.impl
Class ZooKeeperLeaderElection

java.lang.Object
  extended by org.inria.myriads.snoozenode.groupmanager.leadelection.api.impl.ZooKeeperLeaderElection
All Implemented Interfaces:
Runnable, org.apache.zookeeper.Watcher, LeaderElection

public final class ZooKeeperLeaderElection
extends Object
implements LeaderElection, org.apache.zookeeper.Watcher, Runnable

Leader election implementation based on the Apache ZooKeeper coordination service. Inspired by the great tutorials at: http://zookeeper.apache.org/doc/r3.3.1/recipes.html#sc_leaderElection http://dengyin2000.iteye.com/blog/858939

Author:
Eugen Feller

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.zookeeper.Watcher
org.apache.zookeeper.Watcher.Event
 
Constructor Summary
ZooKeeperLeaderElection(ZooKeeperSettings zooKeeperParameters, org.inria.myriads.snoozecommon.communication.groupmanager.GroupManagerDescription groupManagerDescription, LeaderElectionListener listener)
          Leader election based on ZooKeeper.
 
Method Summary
 void process(org.apache.zookeeper.WatchedEvent event)
          Processes the watcher event.
 void run()
          Run method.
 void start()
          Starts the leader election.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZooKeeperLeaderElection

public ZooKeeperLeaderElection(ZooKeeperSettings zooKeeperParameters,
                               org.inria.myriads.snoozecommon.communication.groupmanager.GroupManagerDescription groupManagerDescription,
                               LeaderElectionListener listener)
                        throws Exception
Leader election based on ZooKeeper.

Parameters:
zooKeeperParameters - The zookeeper parameters
groupManagerDescription - The group manager description
listener - The leader election listener
Throws:
Exception
Method Detail

run

public void run()
Run method.

Specified by:
run in interface Runnable

process

public void process(org.apache.zookeeper.WatchedEvent event)
Processes the watcher event.

Specified by:
process in interface org.apache.zookeeper.Watcher
Parameters:
event - The watched event

start

public void start()
Starts the leader election.

Specified by:
start in interface LeaderElection


Copyright © 2012. All Rights Reserved.