use of org.apache.geode.cache.CacheWriterException in project geode by apache.
the class ClientInterestNotifyDUnitTest method registerInterest.
/**
* register interest with the server on ALL_KEYS
*
*/
public static void registerInterest() {
try {
Cache cacheClient = GemFireCacheImpl.getInstance();
Region region1 = cacheClient.getRegion(Region.SEPARATOR + REGION_NAME1);
Region region2 = cacheClient.getRegion(Region.SEPARATOR + REGION_NAME2);
// We intentionally do not register interest in region 3 to check no events recvd.
Region region3 = cacheClient.getRegion(Region.SEPARATOR + REGION_NAME3);
assertTrue(region1 != null);
assertTrue(region2 != null);
assertTrue(region3 != null);
region1.registerInterest("ALL_KEYS", InterestResultPolicy.KEYS_VALUES, false, true);
region2.registerInterest("ALL_KEYS", InterestResultPolicy.KEYS_VALUES, false, false);
// We intentionally do not register interest in region 3 to check no events recvd.
// region3.registerInterestBlah();
} catch (CacheWriterException e) {
fail("test failed due to " + e);
}
}
use of org.apache.geode.cache.CacheWriterException in project geode by apache.
the class ClientServerMiscDUnitTest method registerInterestForInvalidatesInBothTheRegions.
public static void registerInterestForInvalidatesInBothTheRegions() {
try {
Cache cache = new ClientServerMiscDUnitTest().getCache();
Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME1);
assertNotNull(r1);
Region r2 = cache.getRegion(Region.SEPARATOR + REGION_NAME2);
assertNotNull(r2);
r1.registerInterest("ALL_KEYS", false, false);
r2.registerInterest("ALL_KEYS", false, false);
} catch (CacheWriterException e) {
e.printStackTrace();
Assert.fail("Test failed due to CacheWriterException during registerInterestnBothRegions", e);
}
}
use of org.apache.geode.cache.CacheWriterException in project geode by apache.
the class ConflationDUnitTest method unregisterInterest.
/**
* register interest with the server on ALL_KEYS
*
*/
public static void unregisterInterest() {
try {
Region region1 = cache.getRegion(Region.SEPARATOR + REGION_NAME1);
Region region2 = cache.getRegion(Region.SEPARATOR + REGION_NAME2);
region1.unregisterInterest("ALL_KEYS");
region2.unregisterInterest("ALL_KEYS");
} catch (CacheWriterException e) {
fail("test failed due to " + e);
}
}
use of org.apache.geode.cache.CacheWriterException in project geode by apache.
the class RemoteTransactionDUnitTest method testOriginRemoteIsTrueForRemoteReplicatedRegions.
@Test
public void testOriginRemoteIsTrueForRemoteReplicatedRegions() {
Host host = Host.getHost(0);
VM accessor = host.getVM(0);
VM datastore = host.getVM(1);
initAccessorAndDataStore(accessor, datastore, 0);
class OriginRemoteRRWriter extends CacheWriterAdapter {
int fireC = 0;
int fireD = 0;
int fireU = 0;
public void beforeCreate(EntryEvent event) throws CacheWriterException {
if (!event.isOriginRemote()) {
throw new CacheWriterException("SUP?? This CREATE is supposed to be isOriginRemote");
}
fireC++;
}
public void beforeDestroy(EntryEvent event) throws CacheWriterException {
getGemfireCache().getLoggerI18n().fine("SWAP:writer:createEvent:" + event);
if (!event.isOriginRemote()) {
throw new CacheWriterException("SUP?? This DESTROY is supposed to be isOriginRemote");
}
fireD++;
}
public void beforeUpdate(EntryEvent event) throws CacheWriterException {
if (!event.isOriginRemote()) {
throw new CacheWriterException("SUP?? This UPDATE is supposed to be isOriginRemote");
}
fireU++;
}
}
datastore.invoke(new SerializableCallable() {
public Object call() throws Exception {
Region refRegion = getCache().getRegion(D_REFERENCE);
refRegion.getAttributesMutator().setCacheWriter(new OriginRemoteRRWriter());
return null;
}
});
accessor.invoke(new DoOpsInTX(OP.PUT));
accessor.invoke(new SerializableCallable() {
public Object call() throws Exception {
TXManagerImpl mgr = getGemfireCache().getTxManager();
TXStateProxy tx = mgr.internalSuspend();
assertNotNull(tx);
mgr.internalResume(tx);
mgr.commit();
return null;
}
});
accessor.invoke(new DoOpsInTX(OP.DESTROY));
accessor.invoke(new SerializableCallable() {
public Object call() throws Exception {
TXManagerImpl mgr = getGemfireCache().getTxManager();
TXStateProxy tx = mgr.internalSuspend();
assertNotNull(tx);
mgr.internalResume(tx);
mgr.commit();
return null;
}
});
accessor.invoke(new DoOpsInTX(OP.PUT));
accessor.invoke(new SerializableCallable() {
public Object call() throws Exception {
TXManagerImpl mgr = getGemfireCache().getTxManager();
TXStateProxy tx = mgr.internalSuspend();
assertNotNull(tx);
mgr.internalResume(tx);
mgr.commit();
return null;
}
});
datastore.invoke(new SerializableCallable() {
public Object call() throws Exception {
Region refRegion = getCache().getRegion(D_REFERENCE);
OriginRemoteRRWriter w = (OriginRemoteRRWriter) refRegion.getAttributes().getCacheWriter();
assertEquals(1, w.fireC);
assertEquals(1, w.fireD);
assertEquals(1, w.fireU);
return null;
}
});
}
use of org.apache.geode.cache.CacheWriterException in project geode by apache.
the class PutAllCSDUnitTest method testClientDestroyOfUncreatedEntry.
/**
* Checks to see if a client does a destroy that throws an exception from CacheWriter
* beforeDestroy that the size of the region is still correct. See bug 51583.
*/
@Test
public void testClientDestroyOfUncreatedEntry() throws CacheException, InterruptedException {
final String title = "testClientDestroyOfUncreatedEntry:";
final Host host = Host.getHost(0);
final VM server1 = host.getVM(0);
final VM client1 = host.getVM(1);
final String regionName = getUniqueName();
final String serverHost = NetworkUtils.getServerHostName(server1.getHost());
// set <true, false> means <PR=true, notifyBySubscription=false> to test local-invalidates
final int serverPort1 = createBridgeServer(server1, regionName, 0, false, 0, null);
createClient(client1, regionName, serverHost, new int[] { serverPort1 }, -1, -1, false, true, true);
server1.invoke(addExceptionTag1(expectedExceptions));
client1.invoke(addExceptionTag1(expectedExceptions));
server1.invoke(new CacheSerializableRunnable(title + "server1 add cacheWriter") {
@Override
public void run2() throws CacheException {
Region region = getRootRegion().getSubregion(regionName);
// Install cacheWriter that causes the very first destroy to fail
region.getAttributesMutator().setCacheWriter(new MyWriter(0));
}
});
assertEquals(0, getRegionSize(server1, regionName));
client1.invoke(new CacheSerializableRunnable(title + "client1 destroy") {
@Override
public void run2() throws CacheException {
Region region = getRootRegion().getSubregion(regionName);
try {
region.destroy("bogusKey");
fail("Expect ServerOperationException caused by CacheWriterException");
} catch (ServerOperationException expected) {
assertTrue(expected.getCause() instanceof CacheWriterException);
}
}
});
assertEquals(0, getRegionSize(server1, regionName));
server1.invoke(removeExceptionTag1(expectedExceptions));
client1.invoke(removeExceptionTag1(expectedExceptions));
stopBridgeServers(getCache());
}
Aggregations