You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@curator.apache.org by "Jordan Zimmerman (JIRA)" <ji...@apache.org> on 2013/09/10 23:54:51 UTC
[jira] [Created] (CURATOR-54) No reliable way to cancel leadership
in LeaderSelector when connection fails due to edge cases
Jordan Zimmerman created CURATOR-54:
---------------------------------------
Summary: No reliable way to cancel leadership in LeaderSelector when connection fails due to edge cases
Key: CURATOR-54
URL: https://issues.apache.org/jira/browse/CURATOR-54
Project: Apache Curator
Issue Type: Bug
Components: Recipes
Affects Versions: 2.2.0-incubating
Reporter: Jordan Zimmerman
Assignee: Jordan Zimmerman
Fix For: 2.3.0-incubating
>From a post to user@
"Hi,
I'm fairly new with Zookeeper and Curator. I want to achieve a simple leader election process.
But, I ran into trouble implementing the interruption behavior. I could not find a reliable way to stop the leader (withdraw from leadership).
I think even the schoolbook example that Curator brings is flawed.
In leader.ExampleClient:
@Override
public void stateChanged(CuratorFramework client, ConnectionState newState)
{
// you MUST handle connection state changes. This WILL happen in production code.
if ( (newState == ConnectionState.LOST) || (newState == ConnectionState.SUSPENDED) )
{
if ( ourThread != null )
{
ourThread.interrupt();
}
}
}
So in case of lost leadership, the ourThread thread is interrupted. However, ourThread is set in the 2nd line of the takeLeadership() method. Until then, it is null.
What happens if the connection is lost immediately after it is established, and ourThread stays null? Won't it be the case that the thread will go on, thinking that it is the leader, despite it being supposed to withdraw?
Thanks,
Arie"
--
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