You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by vkulichenko <va...@gmail.com> on 2016/12/20 17:58:52 UTC

Re: Wait till the cache loading is complete before querying through ignite client

Hi,

Please properly subscribe to the mailing list so that the community can
receive email notifications for your messages. To subscribe, send empty
email to user-subscribe@ignite.apache.org and follow simple instructions in
the reply.


pmazumdar wrote
> I have a cache loader job that puts data into ignite cache and I have an
> ignite client which queries this server to get the count of data using sql
> query. Now if the client is run while data loading is in progress, it
> fires query on the data loaded till then which is obvious. But what I want
> client to do is to wait till the cache is completely loaded and then run
> the query. Is this possible through code or is there any way to stop
> client to fire query at the time of data loading? It takes around 2 mins
> to load cache in my case.

There is no such thing out of the box, but it sounds like you can use
IgniteCountDownLatch to synchronize data loading and query execution
processes. Data loading part will use countDown() to indicate that it's
finished, while query execution will use await() to make sure query is not
executed too early.

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Wait-till-the-cache-loading-is-complete-before-querying-through-ignite-client-tp9643p9651.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Wait till the cache loading is complete before querying through ignite client

Posted by vkulichenko <va...@gmail.com>.
Thanks for sharing!

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Wait-till-the-cache-loading-is-complete-before-querying-through-ignite-client-tp9643p11831.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Wait till the cache loading is complete before querying through ignite client

Posted by nragon <nu...@wedotechnologies.com>.
Hi,


I have a similiar use case, in mine i used IgniteCountDownLatch like
vkulichenko mentioned
Ignite ignite = IgniteClient.ignite();
      IgniteCountDownLatch latch =
ignite.countDownLatch(this.cacheConfig.getName() + "-loadlatch", 1, false,
true);
      if (!cacheExists(ignite)) {
        ignite.getOrCreateCache(this.cacheConfig);
        load(ignite);
        latch.countDown();
      }
      latch.await();
      this.cache = ignite.getOrCreateCache(this.cacheConfig);



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Wait-till-the-cache-loading-is-complete-before-querying-through-ignite-client-tp9643p11809.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Wait till the cache loading is complete before querying through ignite client

Posted by vkulichenko <va...@gmail.com>.
I meant the compute as well. With compute you can send your code to any node
and have full control on this.

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Wait-till-the-cache-loading-is-complete-before-querying-through-ignite-client-tp9643p9662.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Wait till the cache loading is complete before querying through ignite client

Posted by vkulichenko <va...@gmail.com>.
With LOCAL cache you always have to run the query locally. I.e., you have to
send a closure to the server node you want to query and call the cache API
there.

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Wait-till-the-cache-loading-is-complete-before-querying-through-ignite-client-tp9643p9659.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.