Makes sense, thank you. Trevor
From: Jordan Zimmerman [email protected] Reply: [email protected] [email protected] Date: March 18, 2014 at 12:42:22 PM To: [email protected] [email protected] Subject: Re: PathChildrenCache: blocking rebuild that *does* generate events BTW - I think that that comment is misleading… I don’t remember why I wrote such an ominous message. What if I want to block until cache is fully consistent, yet still fire all corresponding events? StartMode.POST_INITIALIZED_EVENT is nearly what I want, except I want to block until it’s done. You’d need to write your own blocking code ala: final CountDownLatch latch = new CountDownLatch(1); PathChildrenCacheListener myListener = new PathChildrenCacheListener(){ public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception { if ( event.getType() == INITIALIZED ) { latch.countDown(); } } }; PathChildrenCache cache = … cache.getListenable().addListener(myListener); cache.start(StartMode.POST_INITIALIZED_EVENT); latch.await(…) From: Trevor Hartman [email protected] Reply: [email protected] [email protected] Date: March 18, 2014 at 1:28:29 PM To: [email protected] [email protected] Subject: PathChildrenCache: blocking rebuild that *does* generate events In PathChildrenCache source, I see rebuild’s docs say: * NOTE: this is a BLOCKING method. Completely rebuild the internal cache by querying * for all needed data WITHOUT generating any events to send to listeners. What if I want to block until cache is fully consistent, yet still fire all corresponding events? StartMode.POST_INITIALIZED_EVENT is nearly what I want, except I want to block until it’s done. Thanks, Trevor
