Reputation: 11
Using below code block I am able to create a infinispan test factory using Junit5 fraemwork.
{
TestResourceTracker.setThreadTestName("InfinispanServer");
ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
EmbeddedCacheManager ecm = TestCacheManagerFactory.createCacheManager(
new GlobalConfigurationBuilder().nonClusteredDefault().defaultCacheName("default"),
configurationBuilder);
HotRodServerConfigurationBuilder serverBuilder = new HotRodServerConfigurationBuilder();
serverBuilder.adminOperationsHandler(new EmbeddedServerAdminOperationHandler());
hotRodServer = HotRodTestingUtil.startHotRodServer(ecm, host, port, serverBuilder);
}
When I access infinispan using the host and port for unit testing getting below exception, what could be the problem:
Caused by: org.infinispan.client.hotrod.exceptions.HotRodClientException: org.infinispan.commons.CacheConfigurationException: ISPN000501: Cannot persist cache configuration as global state is disabled
-- This piece of code works well with Infinispan 9.4.15 version. Getting exception in Infinispan 11.0.4 version.
Upvotes: 1
Views: 1093
Reputation: 1334
By default, caches created via Hot Rod client are persisted.
To disable this behaviour use remoteCacheManager.administration().withFlags(CacheContainerAdmin.AdminFlag.VOLATILE).getOrCreateCache(...);
For testing, the above should be enough. But, if you need, you can enable the global state by adding globalState().enable()
to GlobalConfigurationBuilder
:
new GlobalConfigurationBuilder().nonClusteredDefault().defaultCacheName("default").globalState().enable()
Upvotes: 1