4 Replies Latest reply on Jan 21, 2011 3:59 AM by galder.zamarreno

    try migration JBoss cache to infinispan

    micou

      Hello,

       

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

       

      1)

       

      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();
           //Tree
           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 ?

       

      2)

       

      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();
            option.setCacheModeLocal(true);
            cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
            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();

       

      3)

       

      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.zamarreno

          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

          • 2. try migration JBoss cache to infinispan
            micou

            good everything it is ok now

             

            bye

            • 3. try migration JBoss cache to infinispan
              micou

              hi,

               

              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);

                  treecache.start();

               

              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

                      e1.printStackTrace();

                  }

               

                  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

               

              Michael

              • 4. try migration JBoss cache to infinispan
                galder.zamarreno

                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