Closed connectwithnara closed 12 years ago
I can't reproduce this. Here's the modified test (to use Curator's testing cluster):
https://gist.github.com/3701773
Here's the utility class used to find the leader:
Per your email to me - this was a side effect of retries. So, I'm closing this.
I have two tests running same logic using ZK API and CF API. CF API doesn't quite recover if there is a failure in the ZK cluster.
I have attached the test program. To see the problem, you could try the following:
Now try the same with testFailoverUsingCF. You will notice, unless the CF is closed and a new instance created, it doesn't recover from the situation.
import com.netflix.curator.framework.CuratorFramework; import com.netflix.curator.framework.CuratorFrameworkFactory; import com.netflix.curator.framework.api.BackgroundCallback; import com.netflix.curator.framework.api.CuratorEvent; import com.netflix.curator.retry.ExponentialBackoffRetry; import org.apache.zookeeper.AsyncCallback; import org.apache.zookeeper.WatchedEvent; import org.apache.zookeeper.Watcher; import org.apache.zookeeper.ZooKeeper; import org.apache.zookeeper.data.Stat; import org.junit.Test;
import java.util.Date;
public class FailoverTests {
// logger.info("Update result {}", event.getResultCode()); } }) .forPath("/testNode");
// if (!connectionRestarted) { // connectionRestarted = true; // // cf.close(); // cf = CuratorFrameworkFactory.newClient( // "host1:2181,host2:2181,host3:2181", // new ExponentialBackoffRetry(5000, 5)); // cf.start(); // }
}