Does only one copy of an object exist throught out the nodes of Infinispan in Invalidation modes
usydrajani Feb 1, 2012 3:50 PMHi
I am running cache in Invalidation mode. What I am doing is I am putting an object in cache node1. When I am putting the same object in cache node 2 then the first copy I put in cache node1 is invalidating and I am getting null when I do cahe1.get(1);
package org.infinispan.sampleModuleMeena;
import org.apache.log4j.PropertyConfigurator;
import org.infinispan.Cache;
import org.infinispan.config.Configuration;
import org.infinispan.config.GlobalConfiguration;
import org.infinispan.manager.DefaultCacheManager;
import org.infinispan.manager.EmbeddedCacheManager;
import org.infinispan.sampleModuleMeena.api.SampleModuleDecorator;
public class SampleUsageTestFeb2 {
public static void main(String[] args) {
PropertyConfigurator.configure("log4j.properties");
Configuration cfg = new Configuration();
cfg.setCacheMode(Configuration.CacheMode.INVALIDATION_SYNC);
EmbeddedCacheManager manager1 = new DefaultCacheManager(GlobalConfiguration.getClusteredDefault(), cfg );
EmbeddedCacheManager manager2 = new DefaultCacheManager(GlobalConfiguration.getClusteredDefault() , cfg);
Cache<Integer, Integer> cache1 = manager1.getCache("entity");
Cache<Integer, Integer> cache2 = manager2.getCache("entity");
SampleModuleDecorator<Integer, Integer> moduleApi1 = new SampleModuleDecorator<Integer, Integer>(cache1);
SampleModuleDecorator<Integer, Integer> moduleApi2 = new SampleModuleDecorator<Integer, Integer>(cache2);
cache1.put(1, 11);
System.out.println(cache1.containsKey(1) + " cache1.containsKey(1) This is after we did put some object in cache1");
cache2.put(1, 11);
System.out.println(cache2.containsKey(1) + " cache2.containsKey(1) This is after we did put some object in cache2");
System.out.println(cache1.containsKey(1) + " cache1.containsKey(1) This is after we did put some object in cache2");
}
}
The am getting following output .
Cache [pc-4e63-0-25169] replicating InvalidateCommand{keys=[1]}
true cache1.containsKey(1) This is after we did put some object in cache1
Cache [pc-4e63-0-5368] replicating InvalidateCommand{keys=[1]}
true cache2.containsKey(1) This is after we did put some object in cache2
false cache1.containsKey(1) This is after we did put some object in cache2
My question is how can I put same object in two cache nodes? without invalidating the other. The other question is which infinispan-configs.xml file my this program is using as I am not using JBoss, so this infinispan is running without application server and I have not put any Infinispan-config.xml in the class path.
Thanks
Meena