-
1. Problem creating Named Cache programatically
yangju Apr 22, 2011 3:03 PM (in response to patilka)I am having similar issue. I am using infinispan that comes with jboss AS6Final. It is 4.2.0Final.
I have two nodes to form a cluster. The CacheContainer calls getCache("nonexistCache"); this would cause the cachecontainer to create the cache called "nonexistCache". I then add cache entries to both nodes (through a simple UI). However, the entried added from node1 shows up in node 2, but entries added through node 2 did not show up in node1. I even restart node1, but it does not see entries added from node 2.
If I preconfigure the named cache such as getCache("existingCache"), then entries show up in both nodes no matter they are entered through node1 or 2.
My infinispan config:
<infinispan-config name="epen_application" jndi-name="java:CacheManager/my">
<infinispan xmlns="urn:infinispan:config:4.2">
<global>
<transport clusterName="${jboss.partition.name:DefaultPartition}-my"
distributedSyncTimeout="17500">
<properties>
<property name="stack" value="${jboss.default.jgroups.stack:udp}" />
</properties>
</transport>
<globalJmxStatistics enabled="true" />
<shutdown hookBehavior="DONT_REGISTER" />
</global>
<default>
<jmxStatistics enabled="true" />
<clustering mode="distribution">
<l1 enabled="true" lifespan="60000" />
<hash numOwners="1" rehashRpcTimeout="120000" />
<sync />
</clustering>
</default>
<namedCache name="existingCache">
<locking concurrencyLevel="5000" />
<clustering mode="distributed">
<sync />
</clustering>
</namedCache>
<namedCache name="Response">
<locking concurrencyLevel="5000" />
<clustering mode="distributed">
<sync />
</clustering>
</namedCache>
</infinispan>
</infinispan-config>
-
2. Problem creating Named Cache programatically
vblagojevic May 4, 2011 9:27 AM (in response to patilka)Kavita,
What does your programmatic configuration look like?
Regards,
Vladimir
-
3. Problem creating Named Cache programatically
yangju May 9, 2011 2:31 PM (in response to vblagojevic)Vladimir:
This is my default distributed cache looks like:
<global>
<transport clusterName="${jboss.partition.name:DefaultPartition}-epen"
distributedSyncTimeout="17500">
<properties>
<property name="stack" value="${jboss.default.jgroups.stack:udp}" />
</properties>
</transport>
<globalJmxStatistics enabled="true" />
<shutdown hookBehavior="DONT_REGISTER" />
</global>
<default>
<jmxStatistics enabled="true" />
<invocationBatching enabled="true" />
<locking isolationLevel="READ_COMMITTED"
lockAcquisitionTimeout="20000" writeSkewCheck="false"
concurrencyLevel="5000" useLockStriping="false" />
<transaction
transactionManagerLookupClass="org.infinispan.transaction.lookup.GenericTransactionManagerLookup"
syncRollbackPhase="false" syncCommitPhase="false" useEagerLocking="true"
eagerLockSingleNode="true" />
<clustering mode="distribution">
<l1 enabled="false" lifespan="60000" />
<hash numOwners="1" rehashRpcTimeout="120000" />
<sync />
</clustering>
</default>
I create the cache programmatically like this:
public Cache<?, ?> findCacheByName(String cacheName) {
Cache<?, ?> cache = null;
if (!StringUtils.isEmpty(cacheName) && !cacheExists(cacheName)) {
Configuration c = cacheManager.getDefaultConfiguration().clone();
// c.setCacheMode(CacheMode.DIST_SYNC);
// c.setOtherAttributeToOverrideDefault
cacheManager.defineConfiguration(cacheName, c);
cache = cacheManager.getCache(cacheName);
} else {
cache = cacheManager.getCache(cacheName);
}
return cache;
}
The problme is that the cache that is created in node1 is not visible to node 2 in a distributed mode.
I am using jboss 6 and infinispan 4.2.
Please help.
Thanks.
Richard
-
4. Problem creating Named Cache programatically
patilka May 12, 2011 5:40 AM (in response to vblagojevic)Hi Vladimir,
Sorry for late reply.
My programatic configuration looks like below.
Configuration config=manager.getDefaultConfiguration().clone();
config.setCacheMode(CacheMode.REPL_SYNC);
config.setExpirationLifespan(500000);
config.setFetchInMemoryState(true);
config.setAlwaysProvideInMemoryState(true);
config.setStateRetrievalTimeout(20000);
config.setSyncReplTimeout(20000);
String newCacheName = "RUNTIMECACHE";
manager.defineConfiguration(newCacheName, config);
Cache<String, String> cache = manager.getCache(newCacheName);
Regards,
Kavita
-
5. Re: Problem creating Named Cache programatically
galder.zamarreno May 27, 2011 10:19 AM (in response to patilka)Not sure what this programmatic configuration is used for, but for your question on "nonexistCache", if the name does not match any of the named caches, it creates a cache that's a clone of the default one, and the default one has no <clustering> element configured, hence why data is not replicated/distributed.