6 Replies Latest reply on Sep 8, 2014 4:41 AM by epewall

    Infinispan key/value data types and persistence

    epewall

      Hi all!

       

      I'm trying to create a Infinispan cache with keys of non primitive type.

      As key I would like to use the type org.apache.commons.lang3.Range, and as value a String. This seems to work fine, except when it comes to persisting the cache to file.

      If I restart the Jboss AS the Ranges are gone. So it's not beeing written to file as everything else is.

       

      Is it not possible to use a slightly more complex type as key?

       

      Thanks!

       

      Peter

        • 1. Re: Infinispan key/value data types and persistence
          wdfink

          You can use any Object but it must be serializable.

          Do you see any error messages?

          How your configuration look like?

          Do you use library or client-server mode?

          • 2. Re: Infinispan key/value data types and persistence
            nadirx
            • 3. Re: Infinispan key/value data types and persistence
              epewall

              Thanks guys!  I can see no error messages, everything looks fine. Data is just not persisted.

              I'm running a single instance of Jboss AS with an infinispan cache setup for clustering, one more node will be used later. I don't know if I'm running library or client-server .. :-/ ?

              I tried with the Externalizable, however it still refuses to persist the data. I went with the basic "implements Externalizer<SomeClass>". Couldn't really get how to implement the getTypeClasses in the Advanced way of doing it ...

               

              Anyway, thanks! I'll continue to play with the Externalizable/Serializable. Any/all ideas are most welcome!

              • 4. Re: Infinispan key/value data types and persistence
                nadirx

                You're running embedded. Client/server is when HotRod is involved.

                 

                 

                Can we see the cache configuration please ?

                • 5. Re: Infinispan key/value data types and persistence
                  epewall

                  Configuration loc = new ConfigurationBuilder()

                              .jmxStatistics()

                                  .enable()

                              .clustering()

                                  .cacheMode(CacheMode.REPL_SYNC)

                  //                .cacheMode(CacheMode.DIST_SYNC)

                  //                .hash().numOwners(2)

                                  .loaders()

                                      .passivation(false)

                                      .shared(true)

                                      .preload(true)

                                      .addFileCacheStore()

                                          .fetchPersistentState(true)

                                          .ignoreModifications(false)

                                          .purgeOnStartup(false)

                                          .location(getPersistentCacheLocation())

                                          .async()

                                              .enabled(true)

                                              .threadPoolSize(5)

                                  .build();

                  • 6. Re: Infinispan key/value data types and persistence
                    epewall

                    Just adding ...

                     

                    this works:

                    someCache.put(String, Range) - persisted.

                    this does not:

                    someCache.put(Range, String) - not persisted.

                     

                    Both variants behave nicely when it comes to retrieval of data though.