use of org.apache.geode.cache.client.ServerOperationException in project geode by apache.
the class PutAllCSDUnitTest method doBug51725.
/**
* One failure found in bug 51725, both for putAll and removeAll: non-singlehop with redundency=1.
* Do some singlehop putAll to see if retry succeeded after PRE This is a singlehop putAll test.
*/
public void doBug51725(boolean enableSingleHop) throws CacheException, InterruptedException {
final String title = "doBug51725:";
int client1Size;
int client2Size;
int server1Size;
int server2Size;
final Host host = Host.getHost(0);
final VM server1 = host.getVM(0);
final VM server2 = host.getVM(1);
final VM client1 = host.getVM(2);
final VM client2 = host.getVM(3);
final String regionName = getUniqueName();
final String serverHost = NetworkUtils.getServerHostName(server1.getHost());
final int serverPort1 = createBridgeServer(server1, regionName, 0, true, 0, "ds1");
final int serverPort2 = createBridgeServer(server2, regionName, 0, true, 0, "ds1");
createClient(client1, regionName, serverHost, new int[] { serverPort1 }, -1, 59000, false, false, enableSingleHop);
createClient(client2, regionName, serverHost, new int[] { serverPort1 }, -1, 59000, false, false, enableSingleHop);
server1.invoke(addExceptionTag1(expectedExceptions));
server2.invoke(addExceptionTag1(expectedExceptions));
client1.invoke(addExceptionTag1(expectedExceptions));
client2.invoke(addExceptionTag1(expectedExceptions));
client2.invoke(new CacheSerializableRunnable(title + "client2 add listener") {
@Override
public void run2() throws CacheException {
Region region = getRootRegion().getSubregion(regionName);
region.getAttributesMutator().addCacheListener(new MyListener(false));
region.registerInterest("ALL_KEYS");
LogWriterUtils.getLogWriter().info("client2 registerInterest ALL_KEYS at " + region.getFullPath());
}
});
client1.invoke(new CacheSerializableRunnable(title + "put 3 keys then removeAll") {
@Override
public void run2() throws CacheException {
Region region = getRootRegion().getSubregion(regionName);
region.getAttributesMutator().addCacheListener(new MyListener(false));
// do putAll to create all buckets
doPutAll(regionName, "key-", numberOfEntries);
assertEquals(numberOfEntries, region.size());
}
});
closeCache(server2);
client1.invoke(new CacheSerializableRunnable(title + "putAll from client again") {
@Override
public void run2() throws CacheException {
LocalRegion region = (LocalRegion) getRootRegion().getSubregion(regionName);
region.getAttributesMutator().addCacheListener(new MyListener(false));
try {
doPutAll(regionName, title, numberOfEntries);
fail("Expect ServerOperationException caused by PutAllParitialResultException");
} catch (ServerOperationException soe) {
assertTrue(soe.getMessage().contains(LocalizedStrings.Region_PutAll_Applied_PartialKeys_At_Server_0.toLocalizedString(region.getFullPath())));
assertTrue(soe.getCause() instanceof RuntimeException);
}
assertEquals(numberOfEntries * 3 / 2, region.size());
VersionTag tag;
int cnt = 0;
for (int i = 0; i < numberOfEntries; i++) {
tag = region.getVersionTag(title + i);
if (tag != null && 1 == tag.getEntryVersion()) {
cnt++;
}
}
assertEquals(numberOfEntries / 2, cnt);
try {
doRemoveAll(regionName, title, numberOfEntries);
} catch (ServerOperationException soe) {
assertTrue(soe.getMessage().contains(LocalizedStrings.Region_RemoveAll_Applied_PartialKeys_At_Server_0.toLocalizedString(region.getFullPath())));
assertTrue(soe.getCause() instanceof RuntimeException);
}
Region.Entry re;
// putAll only created 50 entries, removeAll removed them. So 100 entries are all NULL
for (int i = 0; i < numberOfEntries; i++) {
re = region.getEntry(title + i);
assertNull(re);
}
}
});
client2.invoke(new CacheSerializableRunnable(title + "verify entries from client2") {
@Override
public void run2() throws CacheException {
Wait.pause(5000);
Region region = getRootRegion().getSubregion(regionName);
Region.Entry re;
for (int i = 0; i < numberOfEntries; i++) {
re = region.getEntry(title + i);
assertNull(re);
}
}
});
// Stop server
stopBridgeServers(getCache());
}
use of org.apache.geode.cache.client.ServerOperationException 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