use of org.apache.geode.test.dunit.AsyncInvocation in project geode by apache.
the class ConcurrentParallelGatewaySenderOperation_2_DUnitTest method testParallelGatewaySender_SingleNode_UserPR_Close_SimultaneousPut_RecreateRegion.
@Test
public void testParallelGatewaySender_SingleNode_UserPR_Close_SimultaneousPut_RecreateRegion() throws Exception {
Integer[] locatorPorts = createLNAndNYLocators();
Integer lnPort = locatorPorts[0];
Integer nyPort = locatorPorts[1];
try {
String regionName = getTestMethodName() + "_PR";
createCacheInVMs(lnPort, vm4);
vm4.invoke(() -> AbstractGatewaySender.MAXIMUM_SHUTDOWN_WAIT_TIME = -1);
vm4.invoke(() -> createPartitionedRegion(getTestMethodName() + "_PR", "ln", 1, 10, isOffHeap()));
vm4.invoke(() -> createConcurrentSender("ln", 2, true, 100, 10, false, false, null, false, 5, OrderPolicy.KEY));
vm4.invoke(() -> startSender("ln"));
vm4.invoke(() -> pauseSender("ln"));
createCacheInVMs(nyPort, vm2);
vm2.invoke(() -> createPartitionedRegion(regionName, null, 1, 10, isOffHeap()));
vm2.invoke(() -> createReceiver());
vm4.invoke(() -> doPuts(regionName, 10));
vm4.invoke(() -> validateRegionSize(regionName, 10));
vm2.invoke(() -> validateRegionSize(regionName, 0));
AsyncInvocation putAsync = vm4.invokeAsync(() -> WANTestBase.doPutsFrom(getTestMethodName() + "_PR", 10, 2000));
AsyncInvocation localDestroyAsync = vm4.invokeAsync(() -> ConcurrentParallelGatewaySenderOperation_2_DUnitTest.closeRegion(getTestMethodName() + "_PR"));
try {
putAsync.join();
localDestroyAsync.join();
} catch (InterruptedException e) {
e.printStackTrace();
fail("Interrupted the async invocation.");
}
vm2.invoke(() -> validateRegionSize(regionName, 0));
vm4.invoke(() -> createPartitionedRegion(regionName, "ln", 1, 10, isOffHeap()));
vm4.invoke(() -> doPutsFrom(regionName, 10, 20));
vm2.invoke(() -> Awaitility.await().atMost(30, TimeUnit.SECONDS).until(() -> validateRegionSize(regionName, 0)));
vm4.invoke(() -> validateRegionSize(regionName, 10));
} finally {
vm4.invoke(() -> AbstractGatewaySender.MAXIMUM_SHUTDOWN_WAIT_TIME = 0);
}
}
use of org.apache.geode.test.dunit.AsyncInvocation in project geode by apache.
the class ConcurrentParallelGatewaySenderOperation_2_DUnitTest method testParallelGatewaySenders_MultipleNode_UserPR_localDestroy_Recreate.
@Test
public void testParallelGatewaySenders_MultipleNode_UserPR_localDestroy_Recreate() throws Exception {
Integer[] locatorPorts = createLNAndNYLocators();
Integer lnPort = locatorPorts[0];
Integer nyPort = locatorPorts[1];
Integer tkPort = (Integer) vm2.invoke(() -> createFirstRemoteLocator(3, lnPort));
createCacheInVMs(nyPort, vm6);
vm6.invoke(() -> createReceiver());
createCacheInVMs(tkPort, vm7);
vm7.invoke(() -> createReceiver());
try {
createAndStartTwoSenders(vm4, lnPort, 4);
createAndStartTwoSenders(vm5, lnPort, 4);
String regionName = getTestMethodName() + "_PR";
vm6.invoke(() -> WANTestBase.createPartitionedRegion(regionName, null, 1, 100, isOffHeap()));
vm7.invoke(() -> WANTestBase.createPartitionedRegion(regionName, null, 1, 100, isOffHeap()));
AsyncInvocation inv1 = vm4.invokeAsync(() -> WANTestBase.doPuts(regionName, 10));
Wait.pause(1000);
vm5.invoke(() -> WANTestBase.localDestroyRegion(regionName));
try {
inv1.join();
} catch (InterruptedException ex) {
ex.printStackTrace();
fail("Interrupted the async invocation.");
}
validateRegionSizes(regionName, 10, vm4, vm6, vm7);
vm5.invoke(() -> WANTestBase.createPartitionedRegion(regionName, "ln1,ln2", 1, 100, isOffHeap()));
vm4.invoke(() -> WANTestBase.doPutsFrom(regionName, 10, 20));
validateRegionSizes(regionName, 20, vm4, vm6, vm7);
} finally {
vm4.invoke(() -> clear_INFINITE_MAXIMUM_SHUTDOWN_WAIT_TIME());
vm5.invoke(() -> clear_INFINITE_MAXIMUM_SHUTDOWN_WAIT_TIME());
}
}
use of org.apache.geode.test.dunit.AsyncInvocation in project geode by apache.
the class ConcurrentParallelGatewaySenderOperation_2_DUnitTest method testParallelGatewaySender_MultipleNode_UserPR_localDestroy_Recreate.
@Test
public void testParallelGatewaySender_MultipleNode_UserPR_localDestroy_Recreate() throws Exception {
Integer[] locatorPorts = createLNAndNYLocators();
Integer lnPort = locatorPorts[0];
Integer nyPort = locatorPorts[1];
createCacheInVMs(nyPort, vm2);
vm2.invoke(() -> createReceiver());
try {
createAndStartSender(vm4, lnPort, 5, true, false);
createAndStartSender(vm5, lnPort, 5, true, false);
String regionName = getTestMethodName() + "_PR";
vm2.invoke(() -> createPartitionedRegion(regionName, null, 1, 10, isOffHeap()));
AsyncInvocation inv1 = vm4.invokeAsync(() -> WANTestBase.doPuts(regionName, 10));
Wait.pause(1000);
vm5.invoke(() -> localDestroyRegion(regionName));
try {
inv1.join();
} catch (InterruptedException ex) {
ex.printStackTrace();
fail("Interrupted the async invocation.");
}
validateRegionSizes(regionName, 10, vm4, vm2);
vm5.invoke(() -> createPartitionedRegion(regionName, "ln", 1, 10, isOffHeap()));
vm4.invoke(() -> doPutsFrom(regionName, 10, 20));
validateRegionSizes(regionName, 20, vm4, vm2);
} finally {
vm4.invoke(() -> clear_INFINITE_MAXIMUM_SHUTDOWN_WAIT_TIME());
vm5.invoke(() -> clear_INFINITE_MAXIMUM_SHUTDOWN_WAIT_TIME());
}
}
use of org.apache.geode.test.dunit.AsyncInvocation in project geode by apache.
the class ConcurrentParallelGatewaySenderOperation_2_DUnitTest method testParallelGatewaySender_ColocatedPartitionedRegions_localDestroy.
@Test
public void testParallelGatewaySender_ColocatedPartitionedRegions_localDestroy() throws Exception {
Integer[] locatorPorts = createLNAndNYLocators();
Integer lnPort = locatorPorts[0];
Integer nyPort = locatorPorts[1];
createCacheInVMs(nyPort, vm2);
vm2.invoke(() -> createReceiver());
try {
createAndStartSenderWithCustomerOrderShipmentRegion(vm4, lnPort, 5, true);
createAndStartSenderWithCustomerOrderShipmentRegion(vm5, lnPort, 5, true);
LogWriterUtils.getLogWriter().info("Created PRs on local site");
vm2.invoke(() -> createCustomerOrderShipmentPartitionedRegion(null, 1, 100, isOffHeap()));
AsyncInvocation inv1 = vm4.invokeAsync(() -> WANTestBase.putcolocatedPartitionedRegion(10));
Wait.pause(1000);
try {
vm5.invoke(() -> localDestroyRegion(customerRegionName));
} catch (Exception ex) {
assertTrue(ex.getCause() instanceof UnsupportedOperationException);
}
try {
inv1.join();
} catch (Exception e) {
Assert.fail("Unexpected exception", e);
}
validateRegionSizes(customerRegionName, 10, vm4, vm5, vm2);
} finally {
vm4.invoke(() -> clear_INFINITE_MAXIMUM_SHUTDOWN_WAIT_TIME());
vm5.invoke(() -> clear_INFINITE_MAXIMUM_SHUTDOWN_WAIT_TIME());
}
}
use of org.apache.geode.test.dunit.AsyncInvocation in project geode by apache.
the class ConcurrentWANPropagation_1_DUnitTest method testReplicatedSerialPropagationWithRemoteRegionDestroy.
/**
* 1 region and sender configured on local site and 1 region and a receiver configured on remote
* site. Puts to the local region are in progress. Remote region is destroyed in the middle.
*
* @throws Exception
*/
@Test
public void testReplicatedSerialPropagationWithRemoteRegionDestroy() throws Exception {
Integer lnPort = (Integer) vm0.invoke(() -> WANTestBase.createFirstLocatorWithDSId(1));
Integer nyPort = (Integer) vm1.invoke(() -> WANTestBase.createFirstRemoteLocator(2, lnPort));
// these are part of remote site
createCacheInVMs(nyPort, vm2, vm3);
// create one RR (RR_1) on remote site
vm2.invoke(() -> WANTestBase.createReplicatedRegion(getTestMethodName() + "_RR_1", null, isOffHeap()));
vm3.invoke(() -> WANTestBase.createReplicatedRegion(getTestMethodName() + "_RR_1", null, isOffHeap()));
createReceiverInVMs(vm2, vm3);
vm2.invoke(() -> addListenerToSleepAfterCreateEvent(1000, getTestMethodName() + "_RR_1"));
vm3.invoke(() -> addListenerToSleepAfterCreateEvent(1000, getTestMethodName() + "_RR_1"));
// these are part of local site
createCacheInVMs(lnPort, vm4, vm5, vm6, vm7);
// create one RR (RR_1) on local site
vm4.invoke(() -> WANTestBase.createReplicatedRegion(getTestMethodName() + "_RR_1", "ln", isOffHeap()));
vm5.invoke(() -> WANTestBase.createReplicatedRegion(getTestMethodName() + "_RR_1", "ln", isOffHeap()));
vm6.invoke(() -> WANTestBase.createReplicatedRegion(getTestMethodName() + "_RR_1", "ln", isOffHeap()));
vm7.invoke(() -> WANTestBase.createReplicatedRegion(getTestMethodName() + "_RR_1", "ln", isOffHeap()));
// senders are created on local site
vm4.invoke(() -> WANTestBase.createConcurrentSender("ln", 2, false, 100, 10, false, false, null, true, 5, OrderPolicy.KEY));
vm5.invoke(() -> WANTestBase.createConcurrentSender("ln", 2, false, 100, 10, false, false, null, true, 5, OrderPolicy.KEY));
// start the senders on local site
startSenderInVMs("ln", vm4, vm5);
IgnoredException.addIgnoredException(BatchException70.class.getName());
IgnoredException.addIgnoredException(ServerOperationException.class.getName());
// start puts in RR_1 in another thread
AsyncInvocation inv1 = vm4.invokeAsync(() -> WANTestBase.doPuts(getTestMethodName() + "_RR_1", 100));
// destroy RR_1 in remote site
vm2.invoke(() -> WANTestBase.destroyRegion(getTestMethodName() + "_RR_1"));
try {
inv1.join();
} catch (InterruptedException e) {
e.printStackTrace();
fail();
}
// verify that all is well in local site. All the events should be present in local region
vm4.invoke(() -> WANTestBase.validateRegionSize(getTestMethodName() + "_RR_1", 100));
// Wait for the queue to drain. The queue will drain because when the region is destroyed,
// the failed batches will be logged and discarded
vm4.invoke(() -> WANTestBase.waitForConcurrentSerialSenderQueueToDrain("ln"));
}
Aggregations