Hello,
I need to migrate second level cache from JbossCache(3.2.6.GA) to infinispan.
I have the following configuration.
hibernate-core 3.3.1.GA
jgroups 2.6.20.final
glassfish server 3
I followed all the steps as per https://docs.jboss.org/author/display/ISPN/Using+Infinispan+as+JPA-Hibernate+Second+Level+Cache+Provider
I first tried to use hibernate-infinispan(4.0.0), but got compilation issues with RegionFactory hence tried with lower version of
infinispan. I am now using hibernate-infinispan(3.6.8.Final) and infinispan-core(4.2.1.CR1). Following are my configuration files.
hibernate.cfg.xml
<property name="hibernate.cache.region.factory_class">org.hibernate.cache.infinispan.InfinispanRegionFactory</property>
<property name="hibernate.cache.infinispan.cfg">infinispan-configs.xml</property>
<property name="hibernate.cache.infinispan.entity.cfg">hibernate-cache</property>
infinispan-configs.xml
<?xml version="1.0" encoding="UTF-8"?>
<infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:infinispan:config:4.0">
<global>
<transport transportClass = "org.infinispan.remoting.transport.jgroups.JGroupsTransport"
clusterName="infinispan-hibernate-cluster" distributedSyncTimeout="50000">
<!-- Note that the JGroups transport uses sensible defaults if no configuration property is defined. -->
<properties>
<!-- TODO: Change to udp.xml once streaming transfer requirement has been removed. -->
<property name="configurationFile" value="jgroups-udp.xml"/>
</properties>
<!-- See the JGroupsTransport javadocs for more flags -->
</transport>
</global>
<default>
<!-- Used to register JMX statistics in any available MBean server -->
<jmxStatistics enabled="false"/>
<transaction
transactionManagerLookupClass="org.infinispan.transaction.lookup.GenericTransactionManagerLookup"
syncRollbackPhase="false"
syncCommitPhase="false"
useEagerLocking="false" eagerLockSingleNode="false"/>
<deadlockDetection enabled="true" spinDuration="1000"/>
</default>
<namedCache name="hibernate-cache">
<clustering mode="invalidation">
<async/>
</clustering>
<locking isolationLevel="READ_COMMITTED" concurrencyLevel="500000"
lockAcquisitionTimeout="15000" useLockStriping="false" />
<!-- Eviction configuration. WakeupInterval defines how often the eviction thread runs, in milliseconds.
0 means the eviction thread will never run. A separate executor is used for eviction in each cache. -->
<eviction wakeUpInterval="5000" maxEntries="10000" strategy="LRU"/>
<expiration maxIdle="1000000"/>
<lazyDeserialization enabled="true"/>
</namedCache>
<namedCache name="cache2">
<clustering mode="replication">
<stateRetrieval fetchInMemoryState="true" timeout="20000"/>
<sync replTimeout="30000"/>
</clustering>
<!-- Eviction configuration. WakeupInterval defines how often the eviction thread runs, in milliseconds.
0 means the eviction thread will never run. A separate executor is used for eviction in each cache. -->
<eviction wakeUpInterval="5000" maxEntries="10000" strategy="LRU"/>
<expiration maxIdle="1000000"/>
<lazyDeserialization enabled="true"/>
</namedCache>
</infinispan>
With this i tried to deploy my application I got jgroups exception, to solve this i changed the jgroups version to
2.8.0.GA as per http://community.jboss.org/thread/18822. With this jgroups version also i got the following exception
Caused by: org.infinispan.CacheException: org.jgroups.ChannelException: unable to setup the protocol stack: org.jgroups.util.Util.createConcurrentMap()Ljava/util/concurrent/ConcurrentMap;
at org.infinispan.remoting.transport.jgroups.JGroupsTransport.buildChannel(JGroupsTransport.java:253)
at org.infinispan.remoting.transport.jgroups.JGroupsTransport.initChannel(JGroupsTransport.java:203)
at org.infinispan.remoting.transport.jgroups.JGroupsTransport.initChannelAndRPCDispatcher(JGroupsTransport.java:219)
at org.infinispan.remoting.transport.jgroups.JGroupsTransport.start(JGroupsTransport.java:151)
Hence I changed the jgroups version from 2.8.0.GA to 2.11.0.GA as in the pom.xml file of infinispan-core the jgroups version was 2.11.0.GA
After all this changes when I try to deploy my application I got the following exception repeatedly
[#|2011-12-13T11:06:08.293+0000|WARNING|glassfish3.0.1|org.jgroups.protocols.UDP|_ThreadID=39;_ThreadName=Thread-1;|send buffer of socket java.net.DatagramSocket@1419c51 was set to 640KB, but the OS only allocated 131.07KB. This might lead to performance problems. Please set your max send buffer in the OS correctly (e.g. net.core.wmem_max on Linux)|#]
[#|2011-12-13T11:06:08.293+0000|WARNING|glassfish3.0.1|org.jgroups.protocols.UDP|_ThreadID=39;_ThreadName=Thread-1;|receive buffer of socket java.net.DatagramSocket@1419c51 was set to 20MB, but the OS only allocated 131.07KB. This might lead to performance problems. Please set your max receive buffer in the OS correctly (e.g. net.core.rmem_max on Linux)|#]
[#|2011-12-13T11:06:08.294+0000|WARNING|glassfish3.0.1|org.jgroups.protocols.UDP|_ThreadID=39;_ThreadName=Thread-1;|send buffer of socket java.net.MulticastSocket@7dc90f was set to 640KB, but the OS only allocated 131.07KB. This might lead to performance problems. Please set your max send buffer in the OS correctly (e.g. net.core.wmem_max on Linux)|#]
[#|2011-12-13T11:06:08.294+0000|WARNING|glassfish3.0.1|org.jgroups.protocols.UDP|_ThreadID=39;_ThreadName=Thread-1;|receive buffer of socket java.net.MulticastSocket@7dc90f was set to 25MB, but the OS only allocated 131.07KB. This might lead to performance problems. Please set your max receive buffer in the OS correctly (e.g. net.core.rmem_max on Linux)|#]
[#|2011-12-13T11:06:39.232+0000|WARNING|glassfish3.0.1|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=39;_ThreadName=http-thread-pool-8080-(1);|ApplicationDispatcher[] PWC1231: Servlet.service() for servlet jsp threw exception
org.infinispan.util.concurrent.TimeoutException: Replication timeout for myComp_235-42673
at org.infinispan.remoting.transport.AbstractTransport.parseResponseAndAddToResponseList(AbstractTransport.java:49)
at org.infinispan.remoting.transport.jgroups.JGroupsTransport.invokeRemotely(JGroupsTransport.java:414)
at org.infinispan.remoting.rpc.RpcManagerImpl.invokeRemotely(RpcManagerImpl.java:101)
at org.infinispan.remoting.rpc.RpcManagerImpl.invokeRemotely(RpcManagerImpl.java:125)
at org.infinispan.remoting.rpc.RpcManagerImpl.invokeRemotely(RpcManagerImpl.java:230)
at org.infinispan.remoting.rpc.RpcManagerImpl.invokeRemotely(RpcManagerImpl.java:217
To access the named cache (cache2) defined in infinispan-configs.xml i used the following code.
// class to get CacheManager instance
public class CacheInstanceManager extends DefaultCacheManager {
private static CacheInstanceManager cacheManager = null;
private static final String DEF_INFINISPAN_CONFIG_RESOURCE = "infinispan-configs.xml";
private CacheInstanceManager() throws IOException {
super(DEF_INFINISPAN_CONFIG_RESOURCE);
}
public static CacheInstanceManager getInstance() {
if (cacheManager == null) {
try {
cacheManager = new CacheInstanceManager();
} catch (IOException e) {
throw new SecurityException("Failed to initialize Cache manager");
}
}
return cacheManager;
}
}
and then cache is obtain as CacheInstanceManager.getInstance().getCache("cache2")
Please advise, if am missing something.