curator-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benson Qiu <qiu.ben...@gmail.com>
Subject How does CuratorFramework handle connection losses?
Date Wed, 22 Mar 2017 17:30:56 GMT
Hi,

Several questions:

1. The CuratorFramework documentation
<http://curator.apache.org/curator-framework/> says that "should share one
CuratorFramework per ZooKeeper cluster in your application". I create an
instance and call CuratorFramework#start() on application startup and reuse
the same instance throughout the lifetime of my application, but I never
call CuratorFramework#close(). Is this bad practice? What happens if my
application periodically killed and restarted?

2. If I acquire an InterProcessMutex and my application is killed before I
call InterProcessMutex#release(), what happens? Based on my experiments
with TestingServer, it seems that after DEFAULT_SESSION_TIMEOUT_MS
<https://github.com/apache/curator/blob/022de3921a120c6f86cc6e21442327cc04b66cd2/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java#L51>,
other applications are able to acquire the InterProcessMutex with the same
lock path. So there might be temporary starvation, but no deadlock. Is my
understanding correct?

3. I did a quick experiment where I pulled out my ethernet cable (lost
connection to the remote ZK cluster), waited several minutes, and then
inserted my ethernet cable in again. I observed from
ConnectionStateListener that the state will change to SUSPENDED, then LOST,
and when the ethernet cable is inserted again, RECONNECTED. How long does
it take for each state change to happen? Even if I lose connection for a
long period of time, can I trust that CuratorFramework will always handle
reconnecting?

Any help, even if it's on a subset of these questions, would be really
appreciated!

Thanks,
Benson

Mime
View raw message