Retrieve cache from another node
leiottawa Aug 23, 2011 3:59 PMHi,
There are two machines which are linked together via a local network. Infinispan was installed on each of the machines and the same configuration is used on the two machines. Machine 1 puts a cache to its server. My goal is to read the cache from machine 2 but my approach fails.
Both machines run the following code to get named cache.
EmbeddedCacheManager ecm = null; try { ecm = new DefaultCacheManager(...); } catch (IOException e) {} Cache<String, String> cache = ecm.getCache("myCache");
Although they pass the same cache name to ecm.getCache(...), two different cache instances are actually returned because two different EmbeddedCacheManager were created.
My question is how to achieve my goal. Is there a way of using the EmbeddedCacheManager created in machine 1 from machine 2?
The configuration used on the two machines is below.
<infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:infinispan:config:5.0 http://www.infinispan.org/schemas/infinispan-config-5.0.xsd" xmlns="urn:infinispan:config:5.0"> <global> <transport clusterName="hotMessageCluster" transportClass="org.infinispan.remoting.transport.jgroups.JGroupsTransport" machineId="m1" rackId="r1" nodeName="Node-A"> <properties> <property name="configurationFile" value="jgroups-udp.xml" /> </properties> </transport> <globalJmxStatistics enabled="true" allowDuplicateDomains="true"/><!-- allow multiple cache managers --> </global> <default> <transaction transactionManagerLookupClass="org.infinispan.transaction.lookup.GenericTransactionManagerLookup" syncRollbackPhase="false" syncCommitPhase="false" useEagerLocking="false" eagerLockSingleNode="false" cacheStopTimeout="30000" /> <expiration wakeUpInterval="-1"/> </default> <namedCache name="myCache"> <eviction maxEntries="1000" strategy="LRU"/> <expiration wakeUpInterval="60000" lifespan="-1" maxIdle="-1"/> <clustering mode="invalidation"> <async/> <hash numOwners="3" rehashWait="120000" rehashRpcTimeout="600000"/> <l1 enabled="true" lifespan="600000"/> </clustering> </namedCache> </infinispan>
The jgroups-udp.xml is copied from JGroups and is not touched.
Thank you for any suggestions and directions.