4 Replies Latest reply on Jan 21, 2011 3:59 AM by Galder Zamarreño

    try migration JBoss cache to infinispan

    michael troehler Newbie



      i am actually trying a migration Jboss cache to infinispan and i have some questions.




      On JBoss Cache i had :


      private TreeCache     cache = null;

      void     init()
           cache = new TreeCache();


      and on infinispan i had :



      private    EmbeddedCacheManager manager = null;
      private    Cache        caches = null;
      private TreeCache cache = null;

      void       init()
           caches = manager.getCache();
           TreeCacheFactory tcFactory = new TreeCacheFactory();
           this.cache = tcFactory.createTreeCache(caches);    


      I saw now TreeCache is a class abstract and we have to instance TreeCache() with TreeCacheFactory().


      Is it egual ?




      Before on jboss cache i use Option to remove LocalCache like that



      private TreeCache cache = null;

      public Object removeLocal(String s1,String s2,Object o1) throws Exception{
            Option option = new Option();
            return cache.remove(Fqn.fromString(s1+s2),o1,option);


      but i looked in infinispan i did see any option class in infinispan.config


      Do you know a class that does the same job that Option();




      And about TreeCache createService() and DestroyService()


      The method start() and stop() is it egual with createService() and DestroyService in infinispan ?



      Thanks a lot for your futur response,


      Merry Christmas and Happy New Year !



        • 1. Re: try migration JBoss cache to infinispan
          Galder Zamarreño Master

          Re 1) You should use TreeCacheFactory to create tree cache instances, see http://community.jboss.org/docs/DOC-16081


          Re 2) The equivalent is org.infinispan.context.Flag but note that it might not be working fully Ok due to https://issues.jboss.org/browse/ISPN-841


          Re 3) Yes

          • 3. try migration JBoss cache to infinispan
            michael troehler Newbie



            i have question with your new treecache impl.


            i instanced my treecache like that:


                Cache cache = new DefaultCacheManager("config.xml").getCache();

            //    cache.start();       

                cache.addListener(new SampleListner());


                TreeCache treecache = new TreeCacheFactory().createTreeCache(cache);



            but i can not do

            - treecache.addListener i have to write cache.addListener(new xxx)



            - cache.getCacheManager().getMembers(); => i have to write

                CacheManager cm = null;

                try {

                    cm = new DefaultCacheManager("config.xml");

                } catch (IOException e1) {

                    // TODO Auto-generated catch block




                Cache cache = cm.getCache();


                System.out.println("COORDINATOR :" + cm.getCoordinator().toString());

                System.out.println("MEMBERS :" + cm.getMembers());

                System.out.println("CLUSTERNAME :" + cm.getClusterName());

                System.out.println("VERSION :" + cache.getVersion());


            I would like to  know why you change this things ? because in jboss  cache with a treecache i can do everything (addListener, getmembers, getcoordinator etc..).


            after long time reading infinispan docs i saw cache.getCacheManager() but i do not have access to getmembers, getclustername.



            So finally my question is : why i have to use CacheManager to access getCoordinator  ? (on jboss cache i can use with treecache class).


            thanks for your responses



            • 4. try migration JBoss cache to infinispan
              Galder Zamarreño Master

              TreeCache is just a facet of a cache in Infinispan and hence we limited to the functionality it provides. However, making TreeCache contain the methods you miss shouldn't be that difficult. Simply extend TreeCache to call it, JBossTreeCache and add the missing methods so that they delegate to Cache or CacheManager. The rest of methods could simply delegate to the underlying tree cache. It really is not that difficult