use of org.apache.geode.test.dunit.AsyncInvocation in project geode by apache.
the class ParallelWANPersistenceEnabledGatewaySenderDUnitTest method testPersistentPR_Restart.
@Test
public void testPersistentPR_Restart() {
// create locator on local site
Integer lnPort = (Integer) vm0.invoke(() -> WANTestBase.createFirstLocatorWithDSId(1));
// create cache in local site
createCacheInVMs(lnPort, vm4, vm5, vm6, vm7);
// create PR on local site
vm4.invoke(() -> WANTestBase.createPersistentPartitionedRegion(getTestMethodName(), "ln", 1, 100, isOffHeap()));
vm5.invoke(() -> WANTestBase.createPersistentPartitionedRegion(getTestMethodName(), "ln", 1, 100, isOffHeap()));
vm6.invoke(() -> WANTestBase.createPersistentPartitionedRegion(getTestMethodName(), "ln", 1, 100, isOffHeap()));
vm7.invoke(() -> WANTestBase.createPersistentPartitionedRegion(getTestMethodName(), "ln", 1, 100, isOffHeap()));
// start puts in region on local site
vm4.invoke(() -> WANTestBase.doPutsWithKeyAsString(getTestMethodName(), 1000));
LogWriterUtils.getLogWriter().info("Completed puts in the region");
// --------------------close and rebuild local site
// -------------------------------------------------
// kill the senders
vm4.invoke(killSenderRunnable());
vm5.invoke(killSenderRunnable());
vm6.invoke(killSenderRunnable());
vm7.invoke(killSenderRunnable());
LogWriterUtils.getLogWriter().info("Killed all the senders.");
// restart the vm
createCacheInVMs(lnPort, vm4, vm5, vm6, vm7);
LogWriterUtils.getLogWriter().info("Created back the cache");
// // create PR on local site
// vm4.invoke(WANTestBase.class, "createPersistentPartitionedRegion",
// new Object[] { testName, "ln", 1, 100, isOffHeap() });
// vm5.invoke(WANTestBase.class, "createPersistentPartitionedRegion",
// new Object[] { testName, "ln", 1, 100, isOffHeap() });
// vm6.invoke(WANTestBase.class, "createPersistentPartitionedRegion",
// new Object[] { testName, "ln", 1, 100, isOffHeap() });
// vm7.invoke(WANTestBase.class, "createPersistentPartitionedRegion",
// new Object[] { testName, "ln", 1, 100, isOffHeap() });
// create PR on local site
AsyncInvocation inv1 = vm4.invokeAsync(() -> WANTestBase.createPersistentPartitionedRegion(getTestMethodName(), "ln", 1, 100, isOffHeap()));
AsyncInvocation inv2 = vm5.invokeAsync(() -> WANTestBase.createPersistentPartitionedRegion(getTestMethodName(), "ln", 1, 100, isOffHeap()));
AsyncInvocation inv3 = vm6.invokeAsync(() -> WANTestBase.createPersistentPartitionedRegion(getTestMethodName(), "ln", 1, 100, isOffHeap()));
AsyncInvocation inv4 = vm7.invokeAsync(() -> WANTestBase.createPersistentPartitionedRegion(getTestMethodName(), "ln", 1, 100, isOffHeap()));
try {
inv1.join();
inv2.join();
inv3.join();
inv4.join();
} catch (InterruptedException e) {
e.printStackTrace();
fail();
}
LogWriterUtils.getLogWriter().info("Created back the partitioned regions");
vm4.invoke(() -> WANTestBase.validateRegionSize(getTestMethodName(), 1000));
vm5.invoke(() -> WANTestBase.validateRegionSize(getTestMethodName(), 1000));
vm6.invoke(() -> WANTestBase.validateRegionSize(getTestMethodName(), 1000));
vm7.invoke(() -> WANTestBase.validateRegionSize(getTestMethodName(), 1000));
}
use of org.apache.geode.test.dunit.AsyncInvocation in project geode by apache.
the class ParallelWANPersistenceEnabledGatewaySenderDUnitTest method testPersistentPRWithPersistentGatewaySender_Restart_Bug44275.
/**
* Test case for bug# 44275. Enable persistence for PR and GatewaySender. Do puts into region with
* key as a String. Close the local site and rebuild the region and sender from disk store. Check
* if the remote site receives all the events.
*/
@Test
public void testPersistentPRWithPersistentGatewaySender_Restart_Bug44275() {
// create locator on local site
Integer lnPort = (Integer) vm0.invoke(() -> WANTestBase.createFirstLocatorWithDSId(1));
// create locator on remote site
Integer nyPort = (Integer) vm1.invoke(() -> WANTestBase.createFirstRemoteLocator(2, lnPort));
// create receiver on remote site
createCacheInVMs(nyPort, vm2, vm3);
createReceiverInVMs(vm2, vm3);
// create cache in local site
createCacheInVMs(lnPort, vm4, vm5, vm6, vm7);
// create senders with disk store
String diskStore1 = (String) vm4.invoke(() -> WANTestBase.createSenderWithDiskStore("ln", 2, true, 100, 10, false, true, null, null, true));
String diskStore2 = (String) vm5.invoke(() -> WANTestBase.createSenderWithDiskStore("ln", 2, true, 100, 10, false, true, null, null, true));
String diskStore3 = (String) vm6.invoke(() -> WANTestBase.createSenderWithDiskStore("ln", 2, true, 100, 10, false, true, null, null, true));
String diskStore4 = (String) vm7.invoke(() -> WANTestBase.createSenderWithDiskStore("ln", 2, true, 100, 10, false, true, null, null, true));
LogWriterUtils.getLogWriter().info("The DS are: " + diskStore1 + "," + diskStore2 + "," + diskStore3 + "," + diskStore4);
// create PR on remote site
vm2.invoke(() -> WANTestBase.createPersistentPartitionedRegion(getTestMethodName(), null, 1, 100, isOffHeap()));
vm3.invoke(() -> WANTestBase.createPersistentPartitionedRegion(getTestMethodName(), null, 1, 100, isOffHeap()));
// create PR on local site
vm4.invoke(() -> WANTestBase.createPersistentPartitionedRegion(getTestMethodName(), "ln", 1, 100, isOffHeap()));
vm5.invoke(() -> WANTestBase.createPersistentPartitionedRegion(getTestMethodName(), "ln", 1, 100, isOffHeap()));
vm6.invoke(() -> WANTestBase.createPersistentPartitionedRegion(getTestMethodName(), "ln", 1, 100, isOffHeap()));
vm7.invoke(() -> WANTestBase.createPersistentPartitionedRegion(getTestMethodName(), "ln", 1, 100, isOffHeap()));
// start the senders on local site
startSenderInVMs("ln", vm4, vm5, vm6, vm7);
// wait for senders to become running
vm4.invoke(waitForSenderRunnable());
vm5.invoke(waitForSenderRunnable());
vm6.invoke(waitForSenderRunnable());
vm7.invoke(waitForSenderRunnable());
// pause the senders
vm4.invoke(pauseSenderRunnable());
vm5.invoke(pauseSenderRunnable());
vm6.invoke(pauseSenderRunnable());
vm7.invoke(pauseSenderRunnable());
// start puts in region on local site
vm4.invoke(() -> WANTestBase.doPutsWithKeyAsString(getTestMethodName(), 1000));
LogWriterUtils.getLogWriter().info("Completed puts in the region");
// --------------------close and rebuild local site
// -------------------------------------------------
// kill the senders
vm4.invoke(killSenderRunnable());
vm5.invoke(killSenderRunnable());
vm6.invoke(killSenderRunnable());
vm7.invoke(killSenderRunnable());
LogWriterUtils.getLogWriter().info("Killed all the senders.");
// restart the vm
createCacheInVMs(lnPort, vm4, vm5, vm6, vm7);
LogWriterUtils.getLogWriter().info("Created back the cache");
// create senders with disk store
vm4.invoke(() -> WANTestBase.createSenderWithDiskStore("ln", 2, true, 100, 10, false, true, null, diskStore1, true));
vm5.invoke(() -> WANTestBase.createSenderWithDiskStore("ln", 2, true, 100, 10, false, true, null, diskStore2, true));
vm6.invoke(() -> WANTestBase.createSenderWithDiskStore("ln", 2, true, 100, 10, false, true, null, diskStore3, true));
vm7.invoke(() -> WANTestBase.createSenderWithDiskStore("ln", 2, true, 100, 10, false, true, null, diskStore4, true));
LogWriterUtils.getLogWriter().info("Created the senders back from the disk store.");
// create PR on local site
AsyncInvocation inv1 = vm4.invokeAsync(() -> WANTestBase.createPersistentPartitionedRegion(getTestMethodName(), "ln", 1, 100, isOffHeap()));
AsyncInvocation inv2 = vm5.invokeAsync(() -> WANTestBase.createPersistentPartitionedRegion(getTestMethodName(), "ln", 1, 100, isOffHeap()));
AsyncInvocation inv3 = vm6.invokeAsync(() -> WANTestBase.createPersistentPartitionedRegion(getTestMethodName(), "ln", 1, 100, isOffHeap()));
AsyncInvocation inv4 = vm7.invokeAsync(() -> WANTestBase.createPersistentPartitionedRegion(getTestMethodName(), "ln", 1, 100, isOffHeap()));
try {
inv1.join();
inv2.join();
inv3.join();
inv4.join();
} catch (InterruptedException e) {
e.printStackTrace();
fail();
}
LogWriterUtils.getLogWriter().info("Created back the partitioned regions");
// start the senders in async mode. This will ensure that the
// node of shadow PR that went down last will come up first
startSenderInVMsAsync("ln", vm4, vm5, vm6, vm7);
LogWriterUtils.getLogWriter().info("Waiting for senders running.");
// wait for senders running
vm4.invoke(waitForSenderRunnable());
vm5.invoke(waitForSenderRunnable());
vm6.invoke(waitForSenderRunnable());
vm7.invoke(waitForSenderRunnable());
LogWriterUtils.getLogWriter().info("All the senders are now running...");
// ----------------------------------------------------------------------------------------------------
vm2.invoke(() -> WANTestBase.validateRegionSize(getTestMethodName(), 1000));
vm3.invoke(() -> WANTestBase.validateRegionSize(getTestMethodName(), 1000));
}
use of org.apache.geode.test.dunit.AsyncInvocation in project geode by apache.
the class ParallelWANPropagationConcurrentOpsDUnitTest method testParallelPropagationWithSingleBucketPR.
/**
* Normal propagation scenario test case for a PR with only one bucket. This has been added for
* bug# 44284.
*
* @throws Exception
*/
@Test
public void testParallelPropagationWithSingleBucketPR() throws Exception {
Integer lnPort = (Integer) vm0.invoke(() -> WANTestBase.createFirstLocatorWithDSId(1));
Integer nyPort = (Integer) vm1.invoke(() -> WANTestBase.createFirstRemoteLocator(2, lnPort));
createCacheInVMs(nyPort, vm2, vm3);
createReceiverInVMs(vm2, vm3);
createCacheInVMs(lnPort, vm4, vm5);
vm4.invoke(() -> WANTestBase.createSender("ln", 2, true, 100, 10, false, false, null, true));
vm5.invoke(() -> WANTestBase.createSender("ln", 2, true, 100, 10, false, false, null, true));
vm4.invoke(() -> WANTestBase.createPartitionedRegion(getTestMethodName() + "_PR", "ln", 1, 1, isOffHeap()));
vm5.invoke(() -> WANTestBase.createPartitionedRegion(getTestMethodName() + "_PR", "ln", 1, 1, isOffHeap()));
startSenderInVMs("ln", vm4, vm5);
vm2.invoke(() -> WANTestBase.createPartitionedRegion(getTestMethodName() + "_PR", null, 1, 1, isOffHeap()));
vm3.invoke(() -> WANTestBase.createPartitionedRegion(getTestMethodName() + "_PR", null, 1, 1, isOffHeap()));
// before doing any puts, let the senders be running in order to ensure that
// not a single event will be lost
vm4.invoke(() -> WANTestBase.waitForSenderRunningState("ln"));
vm5.invoke(() -> WANTestBase.waitForSenderRunningState("ln"));
// pause the senders
vm4.invoke(() -> WANTestBase.pauseSender("ln"));
vm5.invoke(() -> WANTestBase.pauseSender("ln"));
AsyncInvocation async1 = vm4.invokeAsync(() -> WANTestBase.doPuts(getTestMethodName() + "_PR", 700));
AsyncInvocation async2 = vm4.invokeAsync(() -> WANTestBase.doPuts(getTestMethodName() + "_PR", 1000));
AsyncInvocation async3 = vm4.invokeAsync(() -> WANTestBase.doPuts(getTestMethodName() + "_PR", 800));
AsyncInvocation async4 = vm4.invokeAsync(() -> WANTestBase.doPuts(getTestMethodName() + "_PR", 1000));
async1.join();
async2.join();
async3.join();
async4.join();
int queueSize = (Integer) vm4.invoke(() -> WANTestBase.getQueueContentSize("ln", true));
assertEquals("Actual queue size is not matching with the expected", 3500, queueSize);
// resume the senders now
vm4.invoke(() -> WANTestBase.resumeSender("ln"));
vm5.invoke(() -> WANTestBase.resumeSender("ln"));
vm2.invoke(() -> WANTestBase.validateRegionSize(getTestMethodName() + "_PR", 1000));
}
use of org.apache.geode.test.dunit.AsyncInvocation in project geode by apache.
the class ParallelGatewaySenderOperationsDUnitTest method testParallelPropagationSenderStartAfterStop.
/**
* Normal scenario in which a sender is stopped and then started again.
*/
@Test
public void testParallelPropagationSenderStartAfterStop() throws Exception {
IgnoredException.addIgnoredException("Broken pipe");
Integer[] locatorPorts = createLNAndNYLocators();
Integer lnPort = locatorPorts[0];
Integer nyPort = locatorPorts[1];
String regionName = getTestMethodName() + "_PR";
createCacheInVMs(nyPort, vm2, vm3);
createCacheInVMs(lnPort, vm4, vm5, vm6, vm7);
vm2.invoke(() -> createPartitionedRegion(regionName, "ln", 1, 100, isOffHeap()));
vm3.invoke(() -> createPartitionedRegion(regionName, "ln", 1, 100, isOffHeap()));
createReceiverInVMs(vm2, vm3);
vm4.invoke(() -> createPartitionedRegion(regionName, "ln", 1, 100, isOffHeap()));
vm5.invoke(() -> createPartitionedRegion(regionName, "ln", 1, 100, isOffHeap()));
vm6.invoke(() -> createPartitionedRegion(regionName, "ln", 1, 100, isOffHeap()));
vm7.invoke(() -> createPartitionedRegion(regionName, "ln", 1, 100, isOffHeap()));
vm4.invoke(() -> createSender("ln", 2, true, 100, 10, false, false, null, true));
vm5.invoke(() -> createSender("ln", 2, true, 100, 10, false, false, null, true));
vm6.invoke(() -> createSender("ln", 2, true, 100, 10, false, false, null, true));
vm7.invoke(() -> createSender("ln", 2, true, 100, 10, false, false, null, true));
startSenderInVMs("ln", vm4, vm5, vm6, vm7);
// make sure all the senders are running before doing any puts
vm4.invoke(() -> waitForSenderRunningState("ln"));
vm5.invoke(() -> waitForSenderRunningState("ln"));
vm6.invoke(() -> waitForSenderRunningState("ln"));
vm7.invoke(() -> waitForSenderRunningState("ln"));
// FIRST RUN: now, the senders are started. So, do some of the puts
vm4.invoke(() -> WANTestBase.doPuts(regionName, 200));
// now, stop all of the senders
vm4.invoke(() -> stopSender("ln"));
vm5.invoke(() -> stopSender("ln"));
vm6.invoke(() -> stopSender("ln"));
vm7.invoke(() -> stopSender("ln"));
// Region size on remote site should remain same and below the number of puts done in the FIRST
// RUN
vm2.invoke(() -> WANTestBase.validateRegionSizeRemainsSame(regionName, 200));
// SECOND RUN: do some of the puts after the senders are stopped
vm4.invoke(() -> WANTestBase.doPuts(regionName, 1000));
// Region size on remote site should remain same and below the number of puts done in the FIRST
// RUN
vm2.invoke(() -> WANTestBase.validateRegionSizeRemainsSame(regionName, 200));
// start the senders again
startSenderInVMs("ln", vm4, vm5, vm6, vm7);
vm4.invoke(() -> waitForSenderRunningState("ln"));
vm5.invoke(() -> waitForSenderRunningState("ln"));
vm6.invoke(() -> waitForSenderRunningState("ln"));
vm7.invoke(() -> waitForSenderRunningState("ln"));
// Region size on remote site should remain same and below the number of puts done in the FIRST
// RUN
vm2.invoke(() -> WANTestBase.validateRegionSizeRemainsSame(regionName, 200));
// SECOND RUN: do some more puts
AsyncInvocation async = vm4.invokeAsync(() -> WANTestBase.doPuts(regionName, 1000));
async.join();
// verify all the buckets on all the sender nodes are drained
validateParallelSenderQueueAllBucketsDrained();
// verify the events propagate to remote site
vm2.invoke(() -> WANTestBase.validateRegionSize(regionName, 1000));
vm4.invoke(() -> WANTestBase.validateQueueSizeStat("ln", 0));
vm5.invoke(() -> WANTestBase.validateQueueSizeStat("ln", 0));
vm6.invoke(() -> WANTestBase.validateQueueSizeStat("ln", 0));
vm7.invoke(() -> WANTestBase.validateQueueSizeStat("ln", 0));
}
use of org.apache.geode.test.dunit.AsyncInvocation in project geode by apache.
the class ParallelGatewaySenderOperationsDUnitTest method testStartPauseResumeParallelGatewaySender.
/**
* Normal scenario in which a combinations of start, pause, resume operations is tested
*/
@Test
public void testStartPauseResumeParallelGatewaySender() throws Exception {
Integer[] locatorPorts = createLNAndNYLocators();
Integer lnPort = locatorPorts[0];
Integer nyPort = locatorPorts[1];
createSendersReceiversAndPartitionedRegion(lnPort, nyPort, false, true);
vm4.invoke(() -> WANTestBase.doPuts(getTestMethodName() + "_PR", 1000));
LogWriterUtils.getLogWriter().info("Done 1000 puts on local site");
// Since puts are already done on userPR, it will have the buckets created.
// During sender start, it will wait until those buckets are created for shadowPR as well.
// Start the senders in async threads, so colocation of shadowPR will be complete and
// missing buckets will be created in PRHARedundancyProvider.createMissingBuckets().
startSenderInVMsAsync("ln", vm4, vm5, vm6, vm7);
waitForSendersRunning();
LogWriterUtils.getLogWriter().info("Started senders on local site");
vm4.invoke(() -> WANTestBase.doPuts(getTestMethodName() + "_PR", 5000));
LogWriterUtils.getLogWriter().info("Done 5000 puts on local site");
vm4.invoke(() -> WANTestBase.pauseSender("ln"));
vm5.invoke(() -> WANTestBase.pauseSender("ln"));
vm6.invoke(() -> WANTestBase.pauseSender("ln"));
vm7.invoke(() -> WANTestBase.pauseSender("ln"));
LogWriterUtils.getLogWriter().info("Paused senders on local site");
vm4.invoke(() -> WANTestBase.verifySenderPausedState("ln"));
vm5.invoke(() -> WANTestBase.verifySenderPausedState("ln"));
vm6.invoke(() -> WANTestBase.verifySenderPausedState("ln"));
vm7.invoke(() -> WANTestBase.verifySenderPausedState("ln"));
AsyncInvocation inv1 = vm4.invokeAsync(() -> WANTestBase.doPuts(getTestMethodName() + "_PR", 1000));
LogWriterUtils.getLogWriter().info("Started 1000 async puts on local site");
vm4.invoke(() -> WANTestBase.resumeSender("ln"));
vm5.invoke(() -> WANTestBase.resumeSender("ln"));
vm6.invoke(() -> WANTestBase.resumeSender("ln"));
vm7.invoke(() -> WANTestBase.resumeSender("ln"));
LogWriterUtils.getLogWriter().info("Resumed senders on local site");
vm4.invoke(() -> WANTestBase.verifySenderResumedState("ln"));
vm5.invoke(() -> WANTestBase.verifySenderResumedState("ln"));
vm6.invoke(() -> WANTestBase.verifySenderResumedState("ln"));
vm7.invoke(() -> WANTestBase.verifySenderResumedState("ln"));
try {
inv1.join();
} catch (InterruptedException e) {
fail("Interrupted the async invocation.", e);
}
// verify all buckets drained on all sender nodes.
validateParallelSenderQueueAllBucketsDrained();
validateRegionSizes(getTestMethodName() + "_PR", 5000, vm2, vm3);
}
Aggregations