You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ignite.apache.org by Ognen Duzlevski <og...@gmail.com> on 2015/04/24 14:58:49 UTC

Persistence of cache

Hello,

Can someone point me to docs describing what happens to a named cache in
the following situations?

1. Two separate programs access the same cache (one for reading, one for
writing). The writer dies. Does the grid still keep the cache intact?

2. One program creates a cache in a multiple machine grid, writes something
to it and unexpectedly dies. Does the cache automatically "go away" if no
programs are accessing it anymore?

What is the simplest way to persist the cache on disk for future use? I
wrote a separate program to use the ContinuousQuery thing but I feel the
cache engine itself should provide the functionality maybe.

Thanks!

Re: Persistence of cache

Posted by Ognen Duzlevski <og...@gmail.com>.
On Fri, Apr 24, 2015 at 8:42 AM, Dmitriy Setrakyan <ds...@apache.org>
wrote:

> I am not sure on your use case. Are you just looking for a way to
> periodically snapshot the cache?
>

Yes.


> Cache implements Iterable. Cache.iterator() method will iterate through all
> the entries in a named cache. You can use it to get all the keys.
>

Ah, that's much easier. Thanks.

Ognen

Re: Persistence of cache

Posted by Dmitriy Setrakyan <ds...@apache.org>.
On Fri, Apr 24, 2015 at 8:27 AM, Ognen Duzlevski <og...@gmail.com>
wrote:

> Dmitriy,
>
> Thanks.
>
> What is the best way to investigate what is in the cache? I have been
> collecting data and putting in cache (unattended, as part of a test) for
> days and I noticed yesterday the below output. Magically, my cache is now
> empty.
>
> Is there an easy way to just dump the contents of a cache into a text file
> without all the jdbc mumbo-jumbo? I wrote a small program to use
> ContinuousQuery() but that apparently needs to wait for an update to a
> cache.
>

I am not sure on your use case. Are you just looking for a way to
periodically snapshot the cache?


>
> Also, is there a reason why there is no API that allows me to get a list of
> all keys known to a named cache and be able to query the contents of the
> cache based on the set of keys? Seems much easier that the *Query() stuff.
>

Cache implements Iterable. Cache.iterator() method will iterate through all
the entries in a named cache. You can use it to get all the keys.


>
> Thanks,
> Ognen
>
> [ERROR] [04/23/2015 10:18:33.372]
> [SocialNetworkPollers-akka.actor.default-dispatcher-40]
> [akka://SocialNetworkPollers/user/$b/$I] Cache update timeout out (consider
> increasing networkTimeout configuration property).
> org.apache.ignite.cache.CacheAtomicUpdateTimeoutException: Cache update
> timeout out (consider increasing networkTimeout configuration property).
>         at
>
> org.apache.ignite.internal.processors.cache.GridCacheUtils.convertToCacheException(GridCacheUtils.java:1807)
>         at
>
> org.apache.ignite.internal.processors.cache.IgniteCacheProxy.cacheException(IgniteCacheProxy.java:1450)
>         at
>
> org.apache.ignite.internal.processors.cache.IgniteCacheProxy.put(IgniteCacheProxy.java:762)
>         at
>
> com.shoutlet.datascience.socialnetworkpollers.FBGenderProvider.toCache(FacebookData.scala:82)
>         at
>
> com.shoutlet.datascience.socialnetworkpollers.FBGenderProvider.addProfiles(FacebookData.scala:71)
>         at
>
> com.shoutlet.datascience.socialnetworkpollers.FBGenderProvider$$anonfun$receive$1.applyOrElse(FacebookData.scala:111)
>         at akka.actor.Actor$class.aroundReceive(Actor.scala:465)
>         at
>
> com.shoutlet.datascience.socialnetworkpollers.FBGenderProvider.aroundReceive(FacebookData.scala:42)
>         at akka.actor.ActorCell.receiveMessage(ActorCell.scala:516)
>         at akka.actor.ActorCell.invoke(ActorCell.scala:487)
>         at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:254)
>         at akka.dispatch.Mailbox.run(Mailbox.scala:221)
>         at akka.dispatch.Mailbox.exec(Mailbox.scala:231)
>         at
> scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
>         at
>
> scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.pollAndExecAll(ForkJoinPool.java:1253)
>         at
>
> scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1346)
>         at
> scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
>         at
>
> scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
> Caused by: class
>
> org.apache.ignite.internal.processors.cache.CacheAtomicUpdateTimeoutCheckedException:
> Cache update timeout out (consider increasing
> networkTimeout configuration property).
>         at
>
> org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicUpdateFuture.checkTimeout(GridNearAtomicUpdateFuture.java
> :279)
>         at
>
> org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache$22.onTimeout(GridDhtAtomicCache.java:2267)
>         at
>
> org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor$TimeoutWorker.body(GridTimeoutProcessor.java:133)
>         at
> org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:107)
>         at java.lang.Thread.run(Thread.java:745)
>
> On Fri, Apr 24, 2015 at 8:16 AM, Dmitriy Setrakyan <ds...@apache.org>
> wrote:
>
> > On Fri, Apr 24, 2015 at 7:58 AM, Ognen Duzlevski <
> > ognen.duzlevski@gmail.com>
> > wrote:
> >
> > > Hello,
> > >
> > > Can someone point me to docs describing what happens to a named cache
> in
> > > the following situations?
> > >
> > > 1. Two separate programs access the same cache (one for reading, one
> for
> > > writing). The writer dies. Does the grid still keep the cache intact?
> > >
> >
> > Yes, the cache should be intact. Don't see any reason why it wouldn't be.
> >
> >
> > >
> > > 2. One program creates a cache in a multiple machine grid, writes
> > something
> > > to it and unexpectedly dies. Does the cache automatically "go away" if
> no
> > > programs are accessing it anymore?
> > >
> >
> > No, the cache will remain. The lifecycle of a cache is defined by
> > "create()" or "close()" method. If you don't call the "close()" method
> on a
> > cache, it will not "go away".
> >
> >
> > > What is the simplest way to persist the cache on disk for future use? I
> > > wrote a separate program to use the ContinuousQuery thing but I feel
> the
> > > cache engine itself should provide the functionality maybe.
> > >
> >
> > I would utilize the "CacheStore" API for the write-through functionality.
> > For example, you can store data into any JDBC-compliant store using
> > "CacheJdbcBlobStore". There is also "CacheJdbcPojoStore", which should
> work
> > with concrete types, not blobs, but I am not sure how to use it (will
> start
> > another thread for it).
> >
> >
> > >
> > > Thanks!
> > >
> >
>

Re: Persistence of cache

Posted by Ognen Duzlevski <og...@gmail.com>.
Dmitriy,

Thanks.

What is the best way to investigate what is in the cache? I have been
collecting data and putting in cache (unattended, as part of a test) for
days and I noticed yesterday the below output. Magically, my cache is now
empty.

Is there an easy way to just dump the contents of a cache into a text file
without all the jdbc mumbo-jumbo? I wrote a small program to use
ContinuousQuery() but that apparently needs to wait for an update to a
cache.

Also, is there a reason why there is no API that allows me to get a list of
all keys known to a named cache and be able to query the contents of the
cache based on the set of keys? Seems much easier that the *Query() stuff.

Thanks,
Ognen

[ERROR] [04/23/2015 10:18:33.372]
[SocialNetworkPollers-akka.actor.default-dispatcher-40]
[akka://SocialNetworkPollers/user/$b/$I] Cache update timeout out (consider
increasing networkTimeout configuration property).
org.apache.ignite.cache.CacheAtomicUpdateTimeoutException: Cache update
timeout out (consider increasing networkTimeout configuration property).
        at
org.apache.ignite.internal.processors.cache.GridCacheUtils.convertToCacheException(GridCacheUtils.java:1807)
        at
org.apache.ignite.internal.processors.cache.IgniteCacheProxy.cacheException(IgniteCacheProxy.java:1450)
        at
org.apache.ignite.internal.processors.cache.IgniteCacheProxy.put(IgniteCacheProxy.java:762)
        at
com.shoutlet.datascience.socialnetworkpollers.FBGenderProvider.toCache(FacebookData.scala:82)
        at
com.shoutlet.datascience.socialnetworkpollers.FBGenderProvider.addProfiles(FacebookData.scala:71)
        at
com.shoutlet.datascience.socialnetworkpollers.FBGenderProvider$$anonfun$receive$1.applyOrElse(FacebookData.scala:111)
        at akka.actor.Actor$class.aroundReceive(Actor.scala:465)
        at
com.shoutlet.datascience.socialnetworkpollers.FBGenderProvider.aroundReceive(FacebookData.scala:42)
        at akka.actor.ActorCell.receiveMessage(ActorCell.scala:516)
        at akka.actor.ActorCell.invoke(ActorCell.scala:487)
        at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:254)
        at akka.dispatch.Mailbox.run(Mailbox.scala:221)
        at akka.dispatch.Mailbox.exec(Mailbox.scala:231)
        at
scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
        at
scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.pollAndExecAll(ForkJoinPool.java:1253)
        at
scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1346)
        at
scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
        at
scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
Caused by: class
org.apache.ignite.internal.processors.cache.CacheAtomicUpdateTimeoutCheckedException:
Cache update timeout out (consider increasing
networkTimeout configuration property).
        at
org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicUpdateFuture.checkTimeout(GridNearAtomicUpdateFuture.java
:279)
        at
org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache$22.onTimeout(GridDhtAtomicCache.java:2267)
        at
org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor$TimeoutWorker.body(GridTimeoutProcessor.java:133)
        at
org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:107)
        at java.lang.Thread.run(Thread.java:745)

On Fri, Apr 24, 2015 at 8:16 AM, Dmitriy Setrakyan <ds...@apache.org>
wrote:

> On Fri, Apr 24, 2015 at 7:58 AM, Ognen Duzlevski <
> ognen.duzlevski@gmail.com>
> wrote:
>
> > Hello,
> >
> > Can someone point me to docs describing what happens to a named cache in
> > the following situations?
> >
> > 1. Two separate programs access the same cache (one for reading, one for
> > writing). The writer dies. Does the grid still keep the cache intact?
> >
>
> Yes, the cache should be intact. Don't see any reason why it wouldn't be.
>
>
> >
> > 2. One program creates a cache in a multiple machine grid, writes
> something
> > to it and unexpectedly dies. Does the cache automatically "go away" if no
> > programs are accessing it anymore?
> >
>
> No, the cache will remain. The lifecycle of a cache is defined by
> "create()" or "close()" method. If you don't call the "close()" method on a
> cache, it will not "go away".
>
>
> > What is the simplest way to persist the cache on disk for future use? I
> > wrote a separate program to use the ContinuousQuery thing but I feel the
> > cache engine itself should provide the functionality maybe.
> >
>
> I would utilize the "CacheStore" API for the write-through functionality.
> For example, you can store data into any JDBC-compliant store using
> "CacheJdbcBlobStore". There is also "CacheJdbcPojoStore", which should work
> with concrete types, not blobs, but I am not sure how to use it (will start
> another thread for it).
>
>
> >
> > Thanks!
> >
>

Re: Persistence of cache

Posted by Dmitriy Setrakyan <ds...@apache.org>.
On Fri, Apr 24, 2015 at 7:58 AM, Ognen Duzlevski <og...@gmail.com>
wrote:

> Hello,
>
> Can someone point me to docs describing what happens to a named cache in
> the following situations?
>
> 1. Two separate programs access the same cache (one for reading, one for
> writing). The writer dies. Does the grid still keep the cache intact?
>

Yes, the cache should be intact. Don't see any reason why it wouldn't be.


>
> 2. One program creates a cache in a multiple machine grid, writes something
> to it and unexpectedly dies. Does the cache automatically "go away" if no
> programs are accessing it anymore?
>

No, the cache will remain. The lifecycle of a cache is defined by
"create()" or "close()" method. If you don't call the "close()" method on a
cache, it will not "go away".


> What is the simplest way to persist the cache on disk for future use? I
> wrote a separate program to use the ContinuousQuery thing but I feel the
> cache engine itself should provide the functionality maybe.
>

I would utilize the "CacheStore" API for the write-through functionality.
For example, you can store data into any JDBC-compliant store using
"CacheJdbcBlobStore". There is also "CacheJdbcPojoStore", which should work
with concrete types, not blobs, but I am not sure how to use it (will start
another thread for it).


>
> Thanks!
>