curator-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Littlejohn <joelittlej...@gmail.com>
Subject Cleanly closing down a LeaderLatch
Date Mon, 06 Jun 2016 13:45:37 GMT
Hi

When I stop an app that is using a LeaderLatch, I'd like to close the latch
itself and also close the underlying CuratorFramework. What's the best way
to do this?

When I close the latch and immediately close the CuratorFramework, I see
exceptions like:

java.lang.IllegalStateException: Client is not started
at com.google.common.base.Preconditions.checkState(Preconditions.java:176)
at
org.apache.curator.CuratorZookeeperClient.getZooKeeper(CuratorZookeeperClient.java:113)

and

java.lang.IllegalStateException: instance must be started before calling
this method at
com.google.common.base.Preconditions.checkState(Preconditions.java:176) at
org.apache.curator.framework.imps.CuratorFrameworkImpl.create(CuratorFrameworkImpl.java:349)

Which I believe is caused by some background updates that are scheduled
when the latch closes. Is there any way to close the CuratorFramework only
after all background tasks are complete? Ideally I'd like to avoid having
to use Thread.sleep(1000) :)

Maybe there's something else I should do to wait for all latch updates to
complete before considering the latch 'closed'?

Cheers

Mime
View raw message