[ 
https://issues.apache.org/jira/browse/CURATOR-49?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13723457#comment-13723457
 ] 

Ding Jinqiang commented on CURATOR-49:
--------------------------------------

Well...We may have other clients to manage the zookeeper server, such as 
roshan. 
So when I want the current leader to abandon its leadership and another one to 
take over the leader's job(May be the server that holds the previous leader has 
other heavy tasks), my first idea is to manually delete the current leader 
node, and hope the corresponding client can receive a notification that you 
lose the leadership, cancel the job and join the election again.

Or I should obey the rule not to operate the nodes created by curator and find 
other ways to do such things?

My current solution is to check the leadership in takeLeadership() every a few 
seconds, which I thought is not so elegant. 

Thanks for answer my question:)

                
> LeaderSelector has no response when delete the leader node by other clients
> ---------------------------------------------------------------------------
>
>                 Key: CURATOR-49
>                 URL: https://issues.apache.org/jira/browse/CURATOR-49
>             Project: Apache Curator
>          Issue Type: Bug
>          Components: Recipes
>    Affects Versions: 2.1.0-incubating
>         Environment: curator-recipes 2.1.0-incubating and  zookeeper 3.4.5
>            Reporter: Ding Jinqiang
>
> If I setup a normal LeaderSelection with two participants, and as expected 
> one of them becomes the leader. But when I delete the leader node manually by 
> other clients, the other leaderSelector becomes the leader normally. But the 
> leaderSelector, which is the previous leader, does not receive any 
> notification in the LeaderSelectorListener. 
> Well, my question is, is this normal, or I just missed something? 
> Sample code may like this:
>               RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 1);
>               client = 
> CuratorFrameworkFactory.newClient(Config.getInstance().getServerConnectString(),
>                               retryPolicy);
>               client.start();
>               LeaderSelectorListener listener = new LeaderSelectorListener() {
>                       @Override
>                       public void takeLeadership(CuratorFramework client) 
> throws Exception {
>                               logger.info("takeLeadership, thread 
> id:"+Thread.currentThread().getId());
>                               Thread.sleep(Long.MAX_VALUE);
>                       }
>                       @Override
>                       public void stateChanged(CuratorFramework client, 
> ConnectionState newState) {
>                               logger.info("Zookeeper connection stateChanged, 
> new state is " + newState);
>                       }
>               };
>               selector = new LeaderSelector(client, 
> Config.getInstance().getEclectPath());
>               selector.autoRequeue();
>               selector.start();
>  

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to