curator-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bae, Jae Hyeon" <metac...@gmail.com>
Subject When is notLeader of LeaderLatchListener is called?
Date Tue, 12 Nov 2013 08:23:24 GMT
Hello

When I was testing with LeaderLatch recipe, I created two LeaderLatches and
closed the first one which was the original leader. I expected notBecome
method of listener which was added to the first one, but it was not because
close() method is removing LeaderLatchListener.

For example,

LeaderLatchListener listener1 = new LeaderLatchListener(...);
LeaderLatch latch1 = new LeaderLatch(...);
latch1.addListener(listener1);
latch1.start();
...

LeaderLatchListener listener2 = new LeaderLatchListener(...);
LeaderLatch latch2 = new LeaderLatch(...);
latch2.addListener(listener1);
latch2.start();
...
latch1.close();
// here I expected listener1.notBecome() method would be called but it was
not.

When is notLeader method is called?

Thank you
Best, Jae

Mime
View raw message