use of org.apache.geode.test.dunit.AsyncInvocation in project geode by apache.
the class PersistentPartitionedRegionDUnitTest method testNestedPRRegions.
@Test
public void testNestedPRRegions() 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;
createNestedPR(vm0);
createNestedPR(vm1);
createNestedPR(vm2);
createData(vm0, 0, numBuckets, "a", "parent1/" + PR_REGION_NAME);
createData(vm0, 0, numBuckets, "b", "parent2/" + PR_REGION_NAME);
checkData(vm2, 0, numBuckets, "a", "parent1/" + PR_REGION_NAME);
checkData(vm2, 0, numBuckets, "b", "parent2/" + PR_REGION_NAME);
Set<Integer> vm1_0Buckets = getBucketList(vm0, "parent1/" + PR_REGION_NAME);
Set<Integer> vm1_1Buckets = getBucketList(vm1, "parent1/" + PR_REGION_NAME);
Set<Integer> vm1_2Buckets = getBucketList(vm2, "parent1/" + PR_REGION_NAME);
Set<Integer> vm2_0Buckets = getBucketList(vm0, "parent2/" + PR_REGION_NAME);
Set<Integer> vm2_1Buckets = getBucketList(vm1, "parent2/" + PR_REGION_NAME);
Set<Integer> vm2_2Buckets = getBucketList(vm2, "parent2/" + PR_REGION_NAME);
closeCache(vm0);
closeCache(vm1);
closeCache(vm2);
AsyncInvocation async0 = createNestedPRAsync(vm0);
// [dsmith] Make sure that vm0 is waiting for vm1 and vm2 to recover
// If VM(0) recovers early, that is a problem, because vm1
// has newer data
Thread.sleep(50);
assertTrue(async0.isAlive());
AsyncInvocation async1 = createNestedPRAsync(vm1);
AsyncInvocation async2 = createNestedPRAsync(vm2);
async0.getResult();
async1.getResult();
async2.getResult();
assertEquals(vm1_0Buckets, getBucketList(vm0, "parent1/" + PR_REGION_NAME));
assertEquals(vm1_1Buckets, getBucketList(vm1, "parent1/" + PR_REGION_NAME));
assertEquals(vm1_2Buckets, getBucketList(vm2, "parent1/" + PR_REGION_NAME));
assertEquals(vm2_0Buckets, getBucketList(vm0, "parent2/" + PR_REGION_NAME));
assertEquals(vm2_1Buckets, getBucketList(vm1, "parent2/" + PR_REGION_NAME));
assertEquals(vm2_2Buckets, getBucketList(vm2, "parent2/" + PR_REGION_NAME));
checkData(vm0, 0, numBuckets, "a", "parent1/" + PR_REGION_NAME);
checkData(vm0, 0, numBuckets, "b", "parent2/" + PR_REGION_NAME);
createData(vm1, numBuckets, 113, "c", "parent1/" + PR_REGION_NAME);
createData(vm1, numBuckets, 113, "d", "parent2/" + PR_REGION_NAME);
checkData(vm2, numBuckets, 113, "c", "parent1/" + PR_REGION_NAME);
checkData(vm2, numBuckets, 113, "d", "parent2/" + PR_REGION_NAME);
}
use of org.apache.geode.test.dunit.AsyncInvocation in project geode by apache.
the class PersistentPartitionedRegionDUnitTest method testAllowRegionUseBeforeRedundancyRecovery.
/**
* A test to make sure that we allow the PR to be used after at least one copy of every bucket is
* recovered, but before the secondaries are initialized.
*
* @throws Throwable
*/
@Test
public void testAllowRegionUseBeforeRedundancyRecovery() throws Throwable {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
VM vm1 = host.getVM(1);
VM vm2 = host.getVM(2);
final int redundancy = 1;
int numBuckets = 20;
createPR(vm0, redundancy);
createPR(vm1, redundancy);
createPR(vm2, redundancy);
createData(vm0, 0, numBuckets, "a");
Set<Integer> vm0Buckets = getBucketList(vm0);
Set<Integer> vm1Buckets = getBucketList(vm1);
Set<Integer> vm2Buckets = getBucketList(vm2);
closeCache(vm0);
closeCache(vm1);
closeCache(vm2);
SerializableRunnable slowGII = new SerializableRunnable("Slow down GII") {
@SuppressWarnings("synthetic-access")
public void run() {
InternalResourceManager.setResourceObserver(new RecoveryObserver());
DistributionMessageObserver.setInstance(new BlockGIIMessageObserver());
}
};
SerializableRunnable resetSlowGII = new SerializableRunnable("Unset the slow GII") {
public void run() {
BlockGIIMessageObserver messageObserver = (BlockGIIMessageObserver) DistributionMessageObserver.setInstance(null);
RecoveryObserver recoveryObserver = (RecoveryObserver) InternalResourceManager.getResourceObserver();
messageObserver.cdl.countDown();
try {
recoveryObserver.recoveryDone.await();
} catch (InterruptedException e) {
Assert.fail("Interrupted", e);
}
InternalResourceManager.setResourceObserver(null);
}
};
try {
vm0.invoke(slowGII);
vm1.invoke(slowGII);
vm2.invoke(slowGII);
SerializableRunnable createPR = new SerializableRunnable("create PR") {
public void run() {
Cache cache = getCache();
RegionAttributes attr = getPersistentPRAttributes(redundancy, -1, cache, 113, true);
cache.createRegion(PR_REGION_NAME, attr);
}
};
AsyncInvocation a1 = vm0.invokeAsync(createPR);
AsyncInvocation a2 = vm1.invokeAsync(createPR);
AsyncInvocation a3 = vm2.invokeAsync(createPR);
a1.getResult(MAX_WAIT);
a2.getResult(MAX_WAIT);
a3.getResult(MAX_WAIT);
// Make sure all of the primary are available.
checkData(vm0, 0, numBuckets, "a");
createData(vm0, 113, 113 + numBuckets, "b");
// But none of the secondaries
Set<Integer> vm0InitialBuckets = getBucketList(vm0);
Set<Integer> vm1InitialBuckets = getBucketList(vm1);
Set<Integer> vm2InitialBuckets = getBucketList(vm2);
assertEquals("vm0=" + vm0InitialBuckets + ",vm1=" + vm1InitialBuckets + "vm2=" + vm2InitialBuckets, numBuckets, vm0InitialBuckets.size() + vm1InitialBuckets.size() + vm2InitialBuckets.size());
} finally {
// Reset the slow GII flag, and wait for the redundant buckets
// to be recovered.
AsyncInvocation reset0 = vm0.invokeAsync(resetSlowGII);
AsyncInvocation reset1 = vm1.invokeAsync(resetSlowGII);
AsyncInvocation reset2 = vm2.invokeAsync(resetSlowGII);
reset0.getResult(MAX_WAIT);
reset1.getResult(MAX_WAIT);
reset2.getResult(MAX_WAIT);
}
// Now we better have all of the buckets
assertEquals(vm0Buckets, getBucketList(vm0));
assertEquals(vm1Buckets, getBucketList(vm1));
assertEquals(vm2Buckets, getBucketList(vm2));
// Make sure the members see the data recovered from disk
// in those secondary buckets
checkData(vm0, 0, numBuckets, "a");
checkData(vm1, 0, numBuckets, "a");
// Make sure the members see the new updates
// in those secondary buckets
checkData(vm0, 113, 113 + numBuckets, "b");
checkData(vm1, 113, 113 + numBuckets, "b");
}
use of org.apache.geode.test.dunit.AsyncInvocation in project geode by apache.
the class PersistentPartitionedRegionDUnitTest method testBug41340.
/**
* This test this case we replace buckets where are offline on A by creating them on C We then
* shutdown C and restart A, which recovers those buckets
*/
@Test
public void testBug41340() throws Throwable {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
VM vm1 = host.getVM(1);
final VM vm2 = host.getVM(2);
createPR(vm0, 1, 0);
createPR(vm1, 1, 0);
createData(vm0, 0, NUM_BUCKETS, "a");
// This should do nothing because we have satisfied redundancy.
createPR(vm2, 1, 0);
assertEquals(Collections.emptySet(), getBucketList(vm2));
Set<Integer> vm0Buckets = getBucketList(vm0);
final Set<Integer> lostBuckets = getBucketList(vm1);
closeCache(vm1);
// VM2 should pick up the slack
waitForBucketRecovery(vm2, lostBuckets);
createData(vm0, 0, NUM_BUCKETS, "b");
// VM1 should recover, but it shouldn't host the bucket anymore
createPR(vm1, 1, 0);
// The data shouldn't be affected.
checkData(vm1, 0, NUM_BUCKETS, "b");
closeCache(vm2);
// The buckets should move back to vm1.
waitForBucketRecovery(vm1, lostBuckets);
assertEquals(vm0Buckets, getBucketList(vm0));
assertEquals(vm0Buckets, getBucketList(vm1));
// The data shouldn't be affected.
checkData(vm1, 0, NUM_BUCKETS, "b");
// restart everything, and make sure it comes back correctly.
closeCache(vm0);
closeCache(vm1);
AsyncInvocation async1 = createPRAsync(vm1, 1);
AsyncInvocation async0 = createPRAsync(vm0, 1);
async0.getResult(MAX_WAIT);
async1.getResult(MAX_WAIT);
// The data shouldn't be affected.
checkData(vm1, 0, NUM_BUCKETS, "b");
assertEquals(vm0Buckets, getBucketList(vm0));
assertEquals(vm0Buckets, getBucketList(vm1));
}
use of org.apache.geode.test.dunit.AsyncInvocation in project geode by apache.
the class PersistentPartitionedRegionDUnitTest method testCleanStop.
// GEODE-1582: race in async region creation causing GII when not
@Category(FlakyTest.class)
// expected
@Test
public void testCleanStop() throws Throwable {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
VM vm1 = host.getVM(1);
createPR(vm0, 1);
createPR(vm1, 1);
createData(vm0, 0, 1, "a");
fakeCleanShutdown(vm1, 0);
fakeCleanShutdown(vm0, 0);
AsyncInvocation async1 = createPRAsync(vm0, 1);
// [dsmith] Make sure that vm0 is waiting for vm1 to recover
// If VM(0) recovers early, that is a problem, because
// we can now longer do a clean restart
AsyncInvocation async2 = createPRAsync(vm1, 1);
async1.getResult(MAX_WAIT);
async2.getResult(MAX_WAIT);
checkData(vm0, 0, 1, "a");
checkData(vm1, 0, 1, "a");
checkRecoveredFromDisk(vm0, 0, true);
checkRecoveredFromDisk(vm1, 0, true);
closePR(vm0);
closePR(vm1);
async1 = createPRAsync(vm0, 1);
async2 = createPRAsync(vm1, 1);
async1.getResult(MAX_WAIT);
async2.getResult(MAX_WAIT);
checkData(vm0, 0, 1, "a");
checkData(vm1, 0, 1, "a");
checkRecoveredFromDisk(vm0, 0, false);
checkRecoveredFromDisk(vm1, 0, true);
}
use of org.apache.geode.test.dunit.AsyncInvocation in project geode by apache.
the class PersistentPartitionedRegionDUnitTest method testRevokeAfterStartup.
@Test
public void testRevokeAfterStartup() 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;
createPR(vm0, 1);
createPR(vm1, 1);
createData(vm0, 0, numBuckets, "a");
Set<Integer> vm0Buckets = getBucketList(vm0);
Set<Integer> vm1Buckets = getBucketList(vm1);
assertEquals(vm0Buckets, vm1Buckets);
closeCache(vm0);
createData(vm1, 0, numBuckets, "b");
closeCache(vm1);
AsyncInvocation a1 = createPRAsync(vm0, 1);
// [dsmith] Make sure that vm0 is waiting for vm1 to recover
// If VM(0) recovers early, that is a problem, because vm1
// has newer data
Thread.sleep(500);
assertTrue(a1.isAlive());
revokeKnownMissingMembers(vm2, 1);
a1.getResult(MAX_WAIT);
assertEquals(vm0Buckets, getBucketList(vm0));
checkData(vm0, 0, numBuckets, "a");
createData(vm0, numBuckets, 113, "b");
checkData(vm0, numBuckets, 113, "b");
IgnoredException ex = IgnoredException.addIgnoredException(RevokedPersistentDataException.class.getName(), vm1);
try {
createPR(vm1, 1);
fail("Should have recieved a SplitDistributedSystemException");
} catch (RMIException e) {
// We revoked this member.
if (!(e.getCause() instanceof RevokedPersistentDataException)) {
throw e;
}
}
ex.remove();
}
Aggregations