use of org.apache.geode.test.dunit.AsyncInvocation in project geode by apache.
the class PartitionedRegionHAFailureAndRecoveryDUnitTest method createPartitionRegionAsynch.
/**
* This function creates multiple partition regions on specified nodes.
*/
private void createPartitionRegionAsynch(final String regionPrefix, final int startIndexForRegion, final int endIndexForRegion, final int localMaxMemory, final int redundancy, final int recoveryDelay) throws Exception {
final AsyncInvocation[] async = new AsyncInvocation[vmArr.length];
for (int count = 0; count < vmArr.length; count++) {
VM vm = vmArr[count];
async[count] = vm.invokeAsync(getCreateMultiplePRregion(regionPrefix, endIndexForRegion, redundancy, localMaxMemory, recoveryDelay));
}
for (int count2 = 0; count2 < async.length; count2++) {
ThreadUtils.join(async[count2], 30 * 1000);
}
for (int count2 = 0; count2 < async.length; count2++) {
if (async[count2].exceptionOccurred()) {
Assert.fail("exception during " + count2, async[count2].getException());
}
}
}
use of org.apache.geode.test.dunit.AsyncInvocation 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.test.dunit.AsyncInvocation in project geode by apache.
the class Bug51400DUnitTest method testDeadlock.
@Ignore("ticket51932")
@Test
public void testDeadlock() throws Throwable {
int maxQSize = 5;
// Set infinite ack interval so that the queue will not be drained.
int ackInterval = Integer.MAX_VALUE;
fail("Invoking bad method");
int port1 = 0;
// int port1 = (Integer) server0.invoke(() -> Bug51400DUnitTest.createServerCache( maxQSize));
client1.invoke(Bug51400DUnitTest.class, "createClientCache", new Object[] { NetworkUtils.getServerHostName(Host.getHost(0)), new Integer[] { port1 }, ackInterval });
// Do puts from server as well as from client on the same key.
AsyncInvocation ai1 = server0.invokeAsync(() -> Bug51400DUnitTest.updateKey(2 * maxQSize));
AsyncInvocation ai2 = client1.invokeAsync(() -> Bug51400DUnitTest.updateKey(2 * maxQSize));
ai1.getResult();
ai2.getResult();
// Verify that the queue has crossed its limit of maxQSize
server0.invoke(() -> Bug51400DUnitTest.verifyQueueSize(true, 2 * maxQSize));
}
use of org.apache.geode.test.dunit.AsyncInvocation in project geode by apache.
the class ShutdownAllDUnitTest method testCleanStop.
// shutdownAll, then restart to verify
@Test
public void testCleanStop() throws Throwable {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
VM vm1 = host.getVM(1);
VM vm2 = host.getVM(2);
createRegion(vm0, "region", "disk", true, 1);
createRegion(vm1, "region", "disk", true, 1);
createData(vm0, 0, 1, "a", "region");
shutDownAllMembers(vm2, 2);
AsyncInvocation a0 = createRegionAsync(vm0, "region", "disk", true, 1);
// [dsmith] Make sure that vm0 is waiting for vm1 to recover
// If VM(0) recovers early, that is a problem, because we
// are no longer doing a clean recovery.
Thread.sleep(500);
assertTrue(a0.isAlive());
AsyncInvocation a1 = createRegionAsync(vm1, "region", "disk", true, 1);
a0.getResult(MAX_WAIT);
a1.getResult(MAX_WAIT);
checkData(vm0, 0, 1, "a", "region");
checkData(vm1, 0, 1, "a", "region");
checkPRRecoveredFromDisk(vm0, "region", 0, true);
checkPRRecoveredFromDisk(vm1, "region", 0, true);
closeRegion(vm0, "region");
closeRegion(vm1, "region");
a0 = createRegionAsync(vm0, "region", "disk", true, 1);
a1 = createRegionAsync(vm1, "region", "disk", true, 1);
a0.getResult(MAX_WAIT);
a1.getResult(MAX_WAIT);
checkData(vm0, 0, 1, "a", "region");
checkData(vm1, 0, 1, "a", "region");
checkPRRecoveredFromDisk(vm0, "region", 0, false);
checkPRRecoveredFromDisk(vm1, "region", 0, true);
}
use of org.apache.geode.test.dunit.AsyncInvocation in project geode by apache.
the class ShutdownAllDUnitTest method testShutdownAllFromServer.
@Test
public void testShutdownAllFromServer() throws Throwable {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
VM vm1 = host.getVM(1);
VM vm2 = host.getVM(2);
int numBuckets = 50;
createRegion(vm0, "region", "disk", true, 1);
createRegion(vm1, "region", "disk", true, 1);
createRegion(vm2, "region", "disk", true, 1);
createData(vm0, 0, numBuckets, "a", "region");
shutDownAllMembers(vm2, 3);
assertTrue(InternalDistributedSystem.getExistingSystems().isEmpty());
// restart vm0, vm1, vm2
AsyncInvocation a0 = createRegionAsync(vm0, "region", "disk", true, 1);
AsyncInvocation a1 = createRegionAsync(vm1, "region", "disk", true, 1);
AsyncInvocation a2 = createRegionAsync(vm2, "region", "disk", true, 1);
a0.getResult(MAX_WAIT);
a1.getResult(MAX_WAIT);
a2.getResult(MAX_WAIT);
createData(vm0, 0, numBuckets, "a", "region");
createData(vm1, 0, numBuckets, "a", "region");
createData(vm2, 0, numBuckets, "a", "region");
createData(vm0, numBuckets, 113, "b", "region");
checkData(vm0, numBuckets, 113, "b", "region");
}
Aggregations