Reputation: 576
I have a scenario where I am accessing Zookeeper through a Curator TreeCache. For my particular use case I am not worried about being out of sync from the ensemble by a few milliseconds (eventual consistency is enough). My problem is that when I first start the cache it takes some time to sync up with Zookeeper and during this time requests for data are failing.
Is there a way to wait for the Curator cache to sync with Zookeeper?
Upvotes: 1
Views: 1146
Reputation: 84
I haven't used TreeCache myself before, but I'd add a TreeCacheListener to the TreeCache instance and TreeCache will publish a TreeCacheEvent.Type.INITIALIZED event, when it has initialized itself. You can countdown a latch in the listener on the INITIALIZED event and you can await on the latch.
Upvotes: 4