Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-3152

LoadersConfigurationBuilder does not clear existing stores on read()

    XMLWordPrintable

Details

    Description

      Hello,

      I am upgrading infinispan configuration and I have following problem:

      In old configuration, we use:

      Configuration config;
      JdbmCacheStoreConfig storeConfig = new JdbmCacheStoreConfig();
      storeConfig.setLocation(location);
      storeConfig.setCacheLoaderClassName("org.infinispan.loaders.jdbm.JdbmCacheStore");
      storeConfig.setFetchPersistentState(true);
      storeConfig.setIgnoreModifications(false);
      storeConfig.setPurgeOnStartup(false);
      config = lc.addCacheLoader(storeConfig).build();

      manager = new DefaultCacheManager(new GlobalConfiguration(), config);

      Configuration c = manager.getDefaultConfiguration();
      c.setEvictionMaxEntries(maxEntries);
      c.setExpirationLifespan(lifespan);
      manager.defineConfiguration(name, c);

      And this works fine. Now I am updating to new configuration:

      ConfigurationBuilder configuration = new ConfigurationBuilder();
      configuration.invocationBatching().enable();
      JdbmCacheStoreConfigurationBuilder builder = new JdbmCacheStoreConfigurationBuilder(configuration.loaders());
      builder.location(location).fetchPersistentState(true);
      configuration.loaders().addStore(builder);
      manager = new DefaultCacheManager(new GlobalConfigurationBuilder().build(), configuration.build());

      And I want to change some properties from previous default configuration for named cache:

      ConfigurationBuilder builder = new ConfigurationBuilder();
      builder.read(manager.getDefaultCacheConfiguration());
      builder.eviction().maxEntries(maxEntries));
      builder.expiration().lifespan(lifespan);
      manager.defineConfiguration(name, builder.build());
      Cache<String, Object> cache = manager.getCache(name);
      cache.start();

      But I got following exception:

      org.infinispan.CacheException: Unable to invoke method public void org.infinispan.loaders.CacheLoaderManagerImpl.start() on object of type CacheLoaderManagerImpl

      at org.infinispan.util.ReflectionUtil.invokeAccessibly(ReflectionUtil.java:205)

      at org.infinispan.factories.AbstractComponentRegistry$PrioritizedMethod.invoke(AbstractComponentRegistry.java:883)

      at org.infinispan.factories.AbstractComponentRegistry.invokeStartMethods(AbstractComponentRegistry.java:654)

      at org.infinispan.factories.AbstractComponentRegistry.internalStart(AbstractComponentRegistry.java:643)

      at org.infinispan.factories.AbstractComponentRegistry.start(AbstractComponentRegistry.java:546)

      at org.infinispan.factories.ComponentRegistry.start(ComponentRegistry.java:199)

      at org.infinispan.CacheImpl.start(CacheImpl.java:559)

      at org.infinispan.manager.DefaultCacheManager.wireAndStartCache(DefaultCacheManager.java:686)

      at org.infinispan.manager.DefaultCacheManager.createCache(DefaultCacheManager.java:649)

      at org.infinispan.manager.DefaultCacheManager.getCache(DefaultCacheManager.java:545)

      at eu.ysoft.cache.ifspn.replicator.IfspnReplicationBuffer.start(IfspnReplicationBuffer.java:117)

      at eu.ysoft.cache.replicator.ReplicatorImpl.start(ReplicatorImpl.java:373)

      at eu.ysoft.cache.replicator.ReplicatorImpl.start(ReplicatorImpl.java:233)

      at eu.ysoft.cache.ifspn.replicator.helpers.IfspnReplicationClient.start(IfspnReplicationClient.java:46)

      at eu.ysoft.cache.ifspn.replicator.functional.IfspnTestSimpleReplications.init(IfspnTestSimpleReplications.java:54)

      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

      at java.lang.reflect.Method.invoke(Method.java:597)

      at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)

      at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:525)

      at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:202)

      at org.testng.internal.Invoker.invokeMethod(Invoker.java:613)

      at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:842)

      at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1166)

      at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)

      at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)

      at org.testng.TestRunner.runWorkers(TestRunner.java:1178)

      at org.testng.TestRunner.privateRun(TestRunner.java:757)

      at org.testng.TestRunner.run(TestRunner.java:608)

      at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)

      at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)

      at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)

      at org.testng.SuiteRunner.run(SuiteRunner.java:240)

      at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)

      at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)

      at org.testng.TestNG.runSuitesSequentially(TestNG.java:1158)

      at org.testng.TestNG.runSuitesLocally(TestNG.java:1083)

      at org.testng.TestNG.run(TestNG.java:999)

      at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)

      at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:203)

      at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:174)

      at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:111)

      Caused by: org.infinispan.CacheException: Unable to start cache loaders

      at org.infinispan.loaders.CacheLoaderManagerImpl.start(CacheLoaderManagerImpl.java:160)

      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

      at java.lang.reflect.Method.invoke(Method.java:597)

      at org.infinispan.util.ReflectionUtil.invokeAccessibly(ReflectionUtil.java:203)

      ... 42 more

      Caused by: java.lang.Exception: Invalid cache loader configuration!! Only ONE cache loader may have fetchPersistentState set to true. Cache will not start!

      at org.infinispan.loaders.CacheLoaderManagerImpl.createCacheLoader(CacheLoaderManagerImpl.java:324)

      at org.infinispan.loaders.CacheLoaderManagerImpl.start(CacheLoaderManagerImpl.java:146)

      ... 47 more

      I need some help how to solve this issue, when we were using the old deprecated configuration, this configuration scenarion works.

      Thanks
      Marta

      Attachments

        Activity

          People

            ttarrant@redhat.com Tristan Tarrant
            maruta.s Marta Sedlakova (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: