[infinispan-issues] [JBoss JIRA] (ISPN-11642) Remote JCacheManager doesn't apply configuration from URI
Tristan Tarrant (Jira)
issues at jboss.org
Mon May 18 12:32:18 EDT 2020
[ https://issues.redhat.com/browse/ISPN-11642?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14103483#comment-14103483 ]
Tristan Tarrant commented on ISPN-11642:
----------------------------------------
[~nmittles] after my fix, this will work, but not using the procedure you describe.
The URI you must pass is that of a hotrod-client.properties file. This file now supports supplying a cache configuration/template using the following properties:
infinispan.client.hotrod.cache._cachename_.configuration=<xml>
or
infinispan.client.hotrod.cache._cachename_.template=template name (like org.infinispan.REPL_SYNC)
Note that this doesn't yet support cache names with "." in them (like you use in the example).
{code:java}
import java.io.File;
import java.net.URI;
import java.util.ArrayList;
import java.util.Properties;
import javax.cache.CacheManager;
import javax.cache.Caching;
import javax.cache.configuration.MutableConfiguration;
import javax.cache.expiry.EternalExpiryPolicy;
public class InfinispanRemoteTest {
public static void main(String[] args) throws Exception {
File hrProps = new File("./hotrod-jcache.properties");
URI uri = hrProps.toURI();
Properties vendorProperties = new Properties();
MutableConfiguration<String, ArrayList> config = new MutableConfiguration<String, ArrayList>()
.setTypes(String.class, ArrayList.class)
.setExpiryPolicyFactory(EternalExpiryPolicy.factoryOf()); cacheManager = Caching.getCachingProvider().getCacheManager(uri, Thread.currentThread().getContextClassLoader(), vendorProperties);
//TestJCache API
cacheManager.createCache("testJCacheAPI2", config);
}
}
{code}
hotrod.properties:
{code:java}
infinispan.client.hotrod.server_list=localhost:11222
infinispan.client.hotrod.marshaller=org.infinispan.commons.marshall.JavaSerializationMarshaller
infinispan.client.hotrod.java_serial_whitelist=.*
infinispan.client.hotrod.auth_username=username
infinispan.client.hotrod.auth_password=password
infinispan.client.hotrod.auth_realm=default
infinispan.client.hotrod.sasl_mechanism=DIGEST-MD5
infinispan.client.hotrod.auth_server_name=infinispan
infinispan.client.hotrod.cache.com.myproject.testJCacheAPI2
{code}
> Remote JCacheManager doesn't apply configuration from URI
> ---------------------------------------------------------
>
> Key: ISPN-11642
> URL: https://issues.redhat.com/browse/ISPN-11642
> Project: Infinispan
> Issue Type: Bug
> Components: Remote Protocols
> Affects Versions: 10.1.6.Final
> Reporter: Nathan Mittlestat
> Assignee: Tristan Tarrant
> Priority: Major
> Fix For: 10.1.7.Final, 11.0.0.Dev05
>
>
> Our project is using JCache API's backed by Infinspan. This is a client-server scenario where we are configuring the Hot Rod Java Client to connect to an Infinispan server.
> We are using _javax.cache.spi.CachingProvider.getCacheManager(URI, ClassLoader, Properties)_ to obtain a _CacheManager_. The URI passed points to an infinispan XML that specifies replicated-cache-configuration as part of the configuration. However the cache created from _CacheManager.createCache()_ ends up being a local cache. This proves to be a problem when connecting to a cluster of Infinispan servers, as when other connections attempt to utilize the cached data, they connect to a different Infinispn sever that doesn't have the cached data. We have verified the XML file pointed to by the URI is on the ClassLoader passed to the _CacheManager_, and still see the same results.
> When we attempt this same scenario using embedded mode instead of client server mode, the configuration in the URI is applied correctly. We have even been able to create a cluster of embedded Infinispan servers via JGroups and confirmed the caches are replicated and not local.
> We have also attempted this scenario using Infinispan's proprietary APIs:
> _RemoteCacheManager.administration().getOrCreateCache(String name, BasicConfiguration configuration)_
> The configuration object passed to _RemoteCacheManagerAdmin.getOrCreateCache()_ loads the same Infinispan XML configuration used in the failing remote JCache scenario (as a _XMlStringConfiguration_ object).
--
This message was sent by Atlassian Jira
(v7.13.8#713008)
More information about the infinispan-issues
mailing list