1 Reply Latest reply on Jun 26, 2012 3:52 PM by galder.zamarreno

    How to start all caches defined in config file at start-up

    dvlinh

      Hello everyone,

       

      I am using Infinispan 5.1.5.FINAL in cluster with embedded mode. I would like to get the names of all caches defined in the config file and start them at start-up.

      So I tried method EmbeddedCacheManager.getCacheNames() like this:

       

      Set<String> cacheNames = embeddedCacheManager.getCacheNames();
      embeddedCacheManager.startCaches(cacheNames.toArray(new String[cacheNames.size()]));
      

       

      It works fine for the first node, but if after that, I create programmatically a cache then destroy it later by EmbeddedCacheManager.removeCache(). Then, I start the second node, the method getCacheNames() now returns also the cache which is removed, so it restarts

       

      I have looked into the code of DefaultCacheManager. I found that getCacheNames() use configurationOverrides to get cache names. But removeCache() don't remove the cache from configurationOverrides. That why getCacheNames return also the removed cache.

       

      So I don't know how to do now. Would you have any idea ?