6 Replies Latest reply on Jan 7, 2015 3:46 AM by Radim Vansa

    hotrod implementation with treecache model

    Manuel Franqueira Newbie

      Hi guys,

      I'm new to Infinispan and I want to implement a hotrod connection to a server that runs Infinispan 7.

      I'm using RemoteCache to access the cache, but I want to do that using a tree model. My problem is that TreeCacheFactory.createTreeCache onlys accepts Cache but not RemoteCache.

      There's any way to use Hot Rod with TreeCache?

      Thanks a lot.

      Manuel

        • 1. Re: hotrod implementation with treecache model
          Tristan Tarrant Master

          Hi Manuel,

           

          the tree module is only a layer to provide some form of backwards compatibility for jbosscache applications. It is unmaintained and unsupported and we recommend applications to use the Cache interface instead. Because it requires some atomic operations which are not available remotely, it is impossible to provide a remote variant at the moment

           

          Tristan

          1 of 1 people found this helpful
          • 2. Re: hotrod implementation with treecache model
            Manuel Franqueira Newbie

            Thanks Tristan for your useful answer!

             

            I needed tree model because I needed to remove at same time two or more child of a node in a tree, for example, "a/b/1" and "a/b/2".

            Using RemoteCache there is a way to remove the subpath's of a key?

            For example, my cache has the following entries:

            a/b/1

            a/b/2

            Can I remove the two entries in same time? Like writing "a/b"...?

             

            Thanks again!

             

            Manuel

            • 3. Re: hotrod implementation with treecache model
              Radim Vansa Master

              No, there's no such API. Probably the best option would be to use Distributed Entry Retriever with proper filter (selecting keys a/b/*) and null-converter to find those entries and call cache.removeAsync() on these.

              1 of 1 people found this helpful
              • 4. Re: hotrod implementation with treecache model
                Manuel Franqueira Newbie

                Thanks Radim!

                 

                I'll check Distributed Entry Retriever right away!

                • 5. Re: hotrod implementation with treecache model
                  Manuel Franqueira Newbie

                  Hi Radim,

                   

                  Because I'm using Hotrod I have a RemoteCache class. The Distributed Entry Retriever filter needs to be applyed in a AdvancedCache. Can I convert a RemoteCache in a Cache or AdvancedCache?

                  How can I apply the filter to a remote cache?

                   

                  -----------------------------------------------------------------------------------

                  Here's my code, hope it helps to clarify my doubt. (I have an Infinispan server and my code is in an JBoss 7 instance in a different server)

                   

                  RemoteCacheManager remoteCacheManager = new RemoteCacheManager();

                  RemoteCache<String, Object> remoteCache = remoteCacheManager.getCache();

                  remoteCache.put("a/b/1", "test1");

                  remoteCache.put("a/b/2", "test2");

                   

                  At this point I have two entries and I want to remove anything below "a/b" at once.

                  How can I do this with a RemoteCache instance? What I read about Distributed Entry Retriever I need to have an AdvancedCache.

                  -----------------------------------------------------------------------------------

                   

                  Thanks a lot.

                  • 6. Re: hotrod implementation with treecache model
                    Radim Vansa Master

                    I've missed the fact that you're using HotRod. In that case, distributed entry retrievers are not available in current version. You can use remote querying, though - but this requires you to store the keys (or rather the position in the tree) in the value, as AFAIK querying can be done only on values.

                    Non-indexed querying uses distributed entry retrievers underhood anyway. If you expect often writes to the cache, I'd recommend not to use indexing.