7 Replies Latest reply on Aug 29, 2014 11:59 AM by drathnow

    Cache entries are not being delete from FileCacheStore

    drathnow

      I have a configured a cache with at FileCacheStore as follows:

       

              Configuration cache = new ConfigurationBuilder()

                  .loaders()

                      .passivation(true)

                      .shared(true)

                      .preload(true)

                      .addFileCacheStore()

                          .purgeSynchronously(false)

                          .fetchPersistentState(true)

                          .ignoreModifications(false)

                          .purgeOnStartup(false)

                          .location("./cacheStore")

                          .async()

                              .enabled(true)

                              .flushLockTimeout(15000)

                              .threadPoolSize(4)

                  .indexing()

                      .enable()

                      .addProperty("default.directory_provider", "ram")

                  .build();

       

      I can populate my cache and entries are persisted to my cache store so that when I restart my app, all persisted entries are loaded into memory. However, when I delete entries (i.e. cache.remove("...")) the entries are removed from the memory cache but they are not removed from the FileCacheStore.  When I restart my application, they are reloaded into the cache.

       

      Is there sometime I've missed in the configuration or is there some other way to delete entries from the cache and have them removed from the FileCacheStore?

       

      Thanks

        • 1. Re: Cache entries are not being delete from FileCacheStore
          rvansa

          When you call remove(), the entry should be removed both from memory and from cache store (unless you use special flags).

           

          Anyway, FileCacheStore is outdated, according to your configuration it seems you're using old version of Infinispan. I'd recommend to switch to Infinspan 6.0.2 or  7-Beta and use SingleFileCacheStore instead.

          • 2. Re: Re: Cache entries are not being delete from FileCacheStore
            drathnow

            Radim,


            Thanks for the response.  I'm using Infinispan with JBoss EAP 6.2, which comes prepackaged with most parts of Infinispan 5.2.7.  However, I needed  need Infinispan-query so I had to pull in that jar file.  Is it possible to use a newer version of Infinispan without breaking the rest of EAP?

             

            In terms of removing and entry: If they are supposed to be delete from persistent store when you call "remote", then perhaps you can tell me what I'm doing wrong.  Here is a simple test program that I created.  I have 4 persisted entries in a file.  When I run this program repeatedly, I always get the same result.  The program shows shows 4 entries in the cache when it is loaded and 3 when I remove one.  The entry on disk is never deleted.  If there are flags that effect this, can you tell me what they are?

             

            public static void main(String[] args) {

                    Logger.getRootLogger().addAppender(new ConsoleAppender(new PatternLayout("%m%n")));

                    try {

                        Configuration requestCacheConfig = new ConfigurationBuilder()

                        .loaders()

                            .passivation(true)

                            .shared(true)

                            .preload(true)

                            .addFileCacheStore()

                                .purgeSynchronously(false)

                                .fetchPersistentState(true)

                                .ignoreModifications(false)

                                .purgeOnStartup(false)

                                .location("./cacheStore")

                                .async()

                                    .enabled(true)

                                    .flushLockTimeout(15000)

                                    .threadPoolSize(4)

                        .indexing()

                            .enable()

                            .addProperty("default.directory_provider", "ram")

                        .build();

                        DefaultCacheManager manager = new DefaultCacheManager();

                        manager.defineConfiguration("OutgoingRequesCache", requestCacheConfig);

                        manager.start();

                        Cache<String, OutgoingRequest> cache = manager.getCache("OutgoingRequesCache);

                        System.out.println("==============> Current cache size at startup: " + cache.size());

                        ControlRequest request = (ControlRequest)cache.get("157e9e11-1ca7-4734-a7f6-0fea0ccd0855");

                        if (request != null)

                            cache.remove("157e9e11-1ca7-4734-a7f6-0fea0ccd0855");

                        else

                            System.out.println("Request not found!");

                        System.out.println("==============> Cache after delete: " + cache.size());

                    } catch (Exception e) {

                        e.printStackTrace();

                    }

                }

             

            This is the output from the above program:

             

            Logging Provider: org.jboss.logging.Log4jLoggerProvider

            ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.

            Loading lifecycle SPI class: org.infinispan.query.impl.LifecycleManager@144c5230

            Loading lifecycle SPI class: org.infinispan.lucene.LifecycleCallbacks@f18ae23

            Loading module command extension SPI class: org.infinispan.query.QueryModuleCommandExtensions@1ff32372

            Started cache manager ISPN on null

            ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.

            Object name org.infinispan:type=CacheManager,name="DefaultCacheManager",component=CacheManager already registered

            Started cache manager ISPN on null

            ISPN000128: Infinispan version: Infinispan 'Delirium' 5.2.7.Final

            Using JBoss Marshalling

            Using JBoss Marshalling

            ISPN014003: Registering Query interceptor

            HSEARCH000034: Hibernate Search 4.2.0.Final

            HCANN000001: Hibernate Commons Annotations {4.0.1.Final}

            HSEARCH000075: Configuration setting hibernate.search.lucene_version was not specified, using LUCENE_CURRENT.

            Using default similarity implementation: org.apache.lucene.search.DefaultSimilarity

            ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.

            Async cache loader starting org.infinispan.loaders.decorators.AsyncStore@3f4300e

            Using DEFAULT file sync mode

            Interceptor chain size: 9

            Interceptor chain is:

              >> org.infinispan.interceptors.InvocationContextInterceptor

              >> org.infinispan.interceptors.IsMarshallableInterceptor

              >> org.infinispan.interceptors.NotificationInterceptor

              >> org.infinispan.interceptors.locking.NonTransactionalLockingInterceptor

              >> org.infinispan.query.backend.QueryInterceptor

              >> org.infinispan.interceptors.EntryWrappingInterceptor

              >> org.infinispan.interceptors.ActivationInterceptor

              >> org.infinispan.interceptors.PassivationInterceptor

              >> org.infinispan.interceptors.CallInterceptor

            Object name org.infinispan:type=Cache,name="OutgoingRequesCache(local)",manager="DefaultCacheManager",component=Cache already registered

            ISPN000031: MBeans were successfully registered to the platform MBean server.

            Preloading transient state from cache loader org.infinispan.loaders.decorators.AsyncStore@3f4300e

            HSEARCH000075: Configuration setting hibernate.search.lucene_version was not specified, using LUCENE_CURRENT.

            Using default similarity implementation: org.apache.lucene.search.DefaultSimilarity

            Starting workspace for index ControlRequestIndex using an exclusive index strategy

            Field selection in projections is set to false for entity zedi.pacbridge.app.controls.ControlRequest.

            Preloaded 4 keys in 359 milliseconds

            Started cache OutgoingRequesCache on null

            ==============> Current cache size at startup: 4

            ==============> Cache after delete: 3

            • 3. Re: Re: Cache entries are not being delete from FileCacheStore
              nadirx

              Using the infinispan which is part of EAP is not supported: it is only used as an implementation detail for EAP's clustering. You can use whichever version of Infinispan you want on top of EAP by using our modules: http://infinispan.org/docs/7.0.x/user_guide/user_guide.html#_infinispan_modules_for_jboss_as_7_x which also come with all of the query modules.

              If you want support for Infinispan, you can purchase a JBoss Data Grid subscription

              • 4. Re: Cache entries are not being delete from FileCacheStore
                wdfink

                In addition to Tristan, there is a quickstart eap-cluster-appModules which shows how to use the latest JDG version inside of EAP.

                 

                In any case you need to have a EAP and a JDG subscription to be supported with that environment.

                • 5. Re: Re: Re: Cache entries are not being delete from FileCacheStore
                  drathnow

                  Hi Tristan,

                   

                  Thanks again for the reply, however, I'm a little confused.

                   

                  First off, can you clarify that, if I package my own version of the Infinispan jarfiles inside my ear, can I use Infinispan without a JDG subscription?  I am specifically interested in using infinispan-query.

                   

                  If I don't need a subscription, what's trick to packaging my own jarfiles?  The section of the User Guide you referenced is a little confusing because it refers to Infinispan version 5.2.0.  I would like to use 6.0.2. What I tried doing was downloading the infinispan-as-modules-6.0.2.Final.zip file and extracting these files under my <JBOSS_HOME>/modules/system/layers/base/org, adding the necessary dependencies to my pom.xml (6.0.5.Final) and MANIFEST.MF (6.0).  However, when I try to deploy my application, I'm getting the exception:

                   

                  org.infinispan.commons.CacheConfigurationException: ISPN000278: Indexing can only be enabled if infinispan-query.jar is available on your classpath, and this jar has not been detected.

                   

                  Which is not surprising because infinispan-query is not include in the above zip file.  Which leads me back to my first question.

                   

                  Thanks

                  • 6. Re: Re: Re: Cache entries are not being delete from FileCacheStore
                    nadirx
                    First off, can you clarify that, if I package my own version of the Infinispan jarfiles inside my ear, can I use Infinispan without a JDG subscription?  I am specifically interested in using infinispan-query.

                     

                    Yes you can.

                     

                     

                    If I don't need a subscription, what's trick to packaging my own jarfiles?  The section of the User Guide you referenced is a little confusing because it refers to Infinispan version 5.2.0.  I would like to use 6.0.2. What I tried doing was downloading the infinispan-as-modules-6.0.2.Final.zip file and extracting these files under my <JBOSS_HOME>/modules/system/layers/base/org, adding the necessary dependencies to my pom.xml (6.0.5.Final) and MANIFEST.MF (6.0).  However, when I try to deploy my application, I'm getting the exception:

                     

                    org.infinispan.commons.CacheConfigurationException: ISPN000278: Indexing can only be enabled if infinispan-query.jar is available on your classpath, and this jar has not been detected.

                     

                    Which is not surprising because infinispan-query is not include in the above zip file.  Which leads me back to my first question.

                    The 6.0.x modules are broken wrt to the query stuff. We have fixed all of the issues in the 7.0 branch, so try the Infinispan 7.0.0.Beta1 modules please.

                     

                    Tristan

                    • 7. Re: Re: Re: Re: Cache entries are not being delete from FileCacheStore
                      drathnow

                      Trisan,

                       

                      That's fixed it!  I downloaded the jboss-as modules for 7.0.0.Beta and expanded them into my JBoss modules directory, change my dependencies to 7.0.0.Beta1, and change my dependencies in my MANIFEST.MF to include

                       

                           org.infinispan:ispn-7.0 services,

                           org.infinispan.query:ispn-7.0 services

                       

                      Everything seems to be working as expected!

                       

                      Thanks for all your help!