use of org.apache.geode.cache.CacheWriter in project geode by apache.
the class RemoveGlobalDUnitTest method testRemoveGlobalSingleVM.
// test methods
@Test
public void testRemoveGlobalSingleVM() throws Throwable {
SerializableRunnable createRegionWithWriter = new CacheSerializableRunnable("create region with cache writer") {
public void run2() throws CacheException {
cache.setLockTimeout(5);
CacheWriter cacheWriter = new CacheWriterCallBack();
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.GLOBAL);
factory.setCacheWriter(cacheWriter);
region = cache.createRegion("map", factory.create());
}
};
vm0.invoke(createRegionWithWriter);
AsyncInvocation async = vm0.invokeAsync(new CacheSerializableRunnable("put object") {
public void run2() throws CacheException {
for (int i = 1; i < 5; i++) {
region.put(new Integer(i), java.lang.Integer.toString(i));
}
region.remove(new Integer(2));
}
});
vm0.invoke(new CacheSerializableRunnable("verify locking") {
public void run2() throws CacheException {
synchronized (RemoveGlobalDUnitTest.class) {
if (!lockedForRemove) {
try {
RemoveGlobalDUnitTest.class.wait();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
try {
// getLogWriter().fine("000000000000000");
region.put(new Integer(2), "newEntry");
fail("Should have thrown TimeoutException");
} catch (TimeoutException tme) {
// pass
}
}
});
ThreadUtils.join(async, 30 * 1000);
if (async.exceptionOccurred())
throw async.getException();
}
use of org.apache.geode.cache.CacheWriter in project geode by apache.
the class RemoveAllDAckDUnitTest method createCacheForVM1.
public static void createCacheForVM1() throws Exception {
CacheWriter aWriter = new BeforeDestroyCallback();
ds = (new RemoveAllDAckDUnitTest()).getSystem(props);
cache = CacheFactory.create(ds);
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setCacheWriter(aWriter);
RegionAttributes attr = factory.create();
region = cache.createRegion("map", attr);
}
use of org.apache.geode.cache.CacheWriter in project geode by apache.
the class DistAckMapMethodsDUnitTest method createRegionToTestRemove.
public static void createRegionToTestRemove() {
try {
AttributesFactory factory2 = new AttributesFactory();
factory2.setScope(Scope.DISTRIBUTED_ACK);
CacheWriter cacheWriter = new RemoveCacheWriter();
CacheListener cacheListener = new RemoveCacheListener();
factory2.setCacheWriter(cacheWriter);
factory2.setCacheListener(cacheListener);
RegionAttributes attr2 = factory2.create();
remRegion = cache.createRegion("remove", attr2);
} catch (Exception ex) {
ex.printStackTrace();
}
}
use of org.apache.geode.cache.CacheWriter in project geode by apache.
the class PutAllCallBkSingleVMDUnitTest method createCache.
public static synchronized void createCache() {
try {
CacheListener aListener = new AfterCreateCallback();
CacheWriter aWriter = new BeforeCreateCallback();
ds = (new PutAllCallBkSingleVMDUnitTest()).getSystem(props);
cache = CacheFactory.create(ds);
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setCacheWriter(aWriter);
factory.setCacheListener(aListener);
RegionAttributes attr = factory.create();
region = cache.createRegion("map", attr);
} catch (Exception ex) {
ex.printStackTrace();
}
}
use of org.apache.geode.cache.CacheWriter in project geode by apache.
the class PutAllDAckDUnitTest method createCacheForVM1.
public static void createCacheForVM1() throws Exception {
CacheWriter aWriter = new BeforeCreateCallback();
ds = (new PutAllDAckDUnitTest()).getSystem(props);
cache = CacheFactory.create(ds);
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setCacheWriter(aWriter);
RegionAttributes attr = factory.create();
region = cache.createRegion("map", attr);
}
Aggregations