Beispiel #1
0
 public LeaderElection JoinElection()
 {
     log.Info(String.Format("join election,data={0}", node.Data));
     election = new LeaderElection(zookeeper, node.Path, new LeaderWatcher(this), Encoding.UTF8.GetBytes(node.Data));
     election.Start();
     return(election);
 }
Beispiel #2
0
        public void StartElectionTest()
        {
            var @event = new AutoResetEvent(false);
            var del    = new Action <object, EventArgs>((sender, args) => @event.Set());

            _watcher.LeadershipTaken += del;

            _election.Start();

            var completed = @event.WaitOne(10 * 1000);

            Assert.IsTrue(completed);
        }