Search in sources :

Example 1 with RMIException

use of org.apache.geode.test.dunit.RMIException in project geode by apache.

the class PersistentPartitionedRegionDUnitTest method testRevokedMemberRedundancy0.

/**
   * Test to make sure that we recreate a bucket if a member is revoked
   */
@Test
public void testRevokedMemberRedundancy0() {
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    VM vm1 = host.getVM(1);
    VM vm2 = host.getVM(2);
    createPR(vm0, 0);
    createPR(vm1, 0);
    createData(vm0, 0, NUM_BUCKETS, "a");
    Set<Integer> vm0Buckets = getBucketList(vm0);
    Set<Integer> vm1Buckets = getBucketList(vm1);
    int aVM0Bucket = vm0Buckets.iterator().next();
    int aVM1Bucket = vm1Buckets.iterator().next();
    closeCache(vm1);
    // This should work, because this bucket is still available.
    checkData(vm0, aVM0Bucket, aVM0Bucket + 1, "a");
    IgnoredException expect = IgnoredException.addIgnoredException("PartitionOfflineException", vm0);
    try {
        checkData(vm0, aVM1Bucket, aVM1Bucket + 1, "a");
        fail("Should not have been able to read from missing buckets!");
    } catch (RMIException e) {
        if (!(e.getCause() instanceof PartitionOfflineException)) {
            throw e;
        }
    }
    try {
        createData(vm0, aVM1Bucket, aVM1Bucket + 1, "b");
        fail("Should not have been able to write to missing buckets!");
    } catch (RMIException e) {
        // We expect to see a partition offline exception here.
        if (!(e.getCause() instanceof PartitionOfflineException)) {
            throw e;
        }
    }
    expect.remove();
    // This should work, because these are new buckets
    createData(vm0, NUM_BUCKETS, 113, "a");
    revokeKnownMissingMembers(vm2, 1);
    createPR(vm2, 0);
    // We should be able to use that missing bucket now
    checkData(vm2, aVM1Bucket, aVM1Bucket + 1, null);
    createData(vm2, aVM1Bucket, aVM1Bucket + 1, "a");
    checkData(vm2, aVM1Bucket, aVM1Bucket + 1, "a");
    IgnoredException ex = IgnoredException.addIgnoredException(RevokedPersistentDataException.class.getName(), vm1);
    try {
        createPR(vm1, 0);
        fail("Should have recieved a RevokedPersistentDataException");
    } catch (RMIException e) {
        // We revoked this member.
        if (!(e.getCause() instanceof RevokedPersistentDataException)) {
            throw e;
        }
    }
    ex.remove();
}
Also used : RevokedPersistentDataException(org.apache.geode.cache.persistence.RevokedPersistentDataException) RMIException(org.apache.geode.test.dunit.RMIException) PartitionOfflineException(org.apache.geode.cache.persistence.PartitionOfflineException) VM(org.apache.geode.test.dunit.VM) IgnoredException(org.apache.geode.test.dunit.IgnoredException) Host(org.apache.geode.test.dunit.Host) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test)

Example 2 with RMIException

use of org.apache.geode.test.dunit.RMIException in project geode by apache.

the class Bug41733DUnitTest method testCrashDuringBucketCreation.

/**
   * Test the we can handle a member departing while we are in the process of creating the bucket on
   * the remote node.
   */
@Test
public void testCrashDuringBucketCreation() throws Throwable {
    Host host = Host.getHost(0);
    final VM vm0 = host.getVM(0);
    VM vm1 = host.getVM(1);
    vm1.invoke(new SerializableRunnable("Install observer") {

        public void run() {
            DistributionMessageObserver.setInstance(new DistributionMessageObserver() {

                @Override
                public void beforeProcessMessage(DistributionManager dm, DistributionMessage message) {
                    if (message instanceof ManageBucketMessage) {
                        vm0.invoke(() -> disconnectFromDS());
                    }
                }
            });
        }
    });
    createPR(vm0, 0);
    // Create a couple of buckets in VM0. This will make sure
    // the next bucket we create will be created in VM 1.
    putData(vm0, 0, 2, "a");
    createPR(vm1, 0);
    // Trigger a bucket creation in VM1, which should cause vm0 to close it's cache.
    try {
        putData(vm0, 3, 4, "a");
        fail("should have received a cache closed exception");
    } catch (RMIException e) {
        if (!(e.getCause() instanceof DistributedSystemDisconnectedException)) {
            throw e;
        }
    }
    assertEquals(Collections.singleton(3), getBucketList(vm1));
    // This shouldn't hang, because the bucket creation should finish,.
    putData(vm1, 3, 4, "a");
}
Also used : ManageBucketMessage(org.apache.geode.internal.cache.partitioned.ManageBucketMessage) RMIException(org.apache.geode.test.dunit.RMIException) DistributionMessage(org.apache.geode.distributed.internal.DistributionMessage) VM(org.apache.geode.test.dunit.VM) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) Host(org.apache.geode.test.dunit.Host) DistributionMessageObserver(org.apache.geode.distributed.internal.DistributionMessageObserver) DistributionManager(org.apache.geode.distributed.internal.DistributionManager) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 3 with RMIException

use of org.apache.geode.test.dunit.RMIException 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();
}
Also used : RevokedPersistentDataException(org.apache.geode.cache.persistence.RevokedPersistentDataException) RMIException(org.apache.geode.test.dunit.RMIException) VM(org.apache.geode.test.dunit.VM) IgnoredException(org.apache.geode.test.dunit.IgnoredException) Host(org.apache.geode.test.dunit.Host) AsyncInvocation(org.apache.geode.test.dunit.AsyncInvocation) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test)

Example 4 with RMIException

use of org.apache.geode.test.dunit.RMIException in project geode by apache.

the class PersistentPartitionedRegionDUnitTest method testChangedToalBucketNumberSinglePR.

/**
   * Test total-buckets-num getting bigger, which cause exception. but changed to smaller should be
   * ok.
   */
@Test
public void testChangedToalBucketNumberSinglePR() {
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    createPR(vm0, 0, 0, 5);
    createData(vm0, 0, 5, "a");
    closeCache(vm0);
    IgnoredException expect = IgnoredException.addIgnoredException("IllegalStateException", vm0);
    expect = IgnoredException.addIgnoredException("DiskAccessException", vm0);
    try {
        createPR(vm0, 0, 0, 2);
        fail("Expect to get java.lang.IllegalStateException, but it did not");
    } catch (RMIException exp) {
        assertTrue(exp.getCause() instanceof IllegalStateException);
        IllegalStateException ise = (IllegalStateException) exp.getCause();
        Object[] prms = new Object[] { "/" + PR_REGION_NAME, 2, 5 };
        assertTrue(ise.getMessage().contains(LocalizedStrings.PartitionedRegion_FOR_REGION_0_TotalBucketNum_1_SHOULD_NOT_BE_CHANGED_Previous_Configured_2.toString(prms)));
    }
    closeCache(vm0);
    try {
        createPR(vm0, 0, 0, 10);
        fail("Expect to get java.lang.IllegalStateException, but it did not");
    } catch (RMIException exp) {
        assertTrue(exp.getCause() instanceof IllegalStateException);
        IllegalStateException ise = (IllegalStateException) exp.getCause();
        Object[] prms = new Object[] { "/" + PR_REGION_NAME, 10, 5 };
        assertTrue(ise.getMessage().contains(LocalizedStrings.PartitionedRegion_FOR_REGION_0_TotalBucketNum_1_SHOULD_NOT_BE_CHANGED_Previous_Configured_2.toString(prms)));
    }
    expect.remove();
}
Also used : RMIException(org.apache.geode.test.dunit.RMIException) VM(org.apache.geode.test.dunit.VM) IgnoredException(org.apache.geode.test.dunit.IgnoredException) Host(org.apache.geode.test.dunit.Host) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test)

Example 5 with RMIException

use of org.apache.geode.test.dunit.RMIException in project geode by apache.

the class PartitionedRegionMetaDataCleanupDUnitTest method testCrash.

@Test
public void testCrash() throws InterruptedException {
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    VM vm1 = host.getVM(1);
    createPR(vm0, "region1", 5);
    createPR(vm1, "region2", 10);
    // This should fail
    IgnoredException ex = IgnoredException.addIgnoredException("IllegalStateException", vm1);
    try {
        createPR(vm1, "region1", 10);
        fail("Should have received an exception");
    } catch (RMIException e) {
    // ok
    } finally {
        ex.remove();
    }
    ex = IgnoredException.addIgnoredException("DistributedSystemDisconnectedException", vm0);
    try {
        fakeCrash(vm0);
    } finally {
        ex.remove();
    }
    waitForCreate(vm0, "region1", 15);
}
Also used : RMIException(org.apache.geode.test.dunit.RMIException) VM(org.apache.geode.test.dunit.VM) IgnoredException(org.apache.geode.test.dunit.IgnoredException) Host(org.apache.geode.test.dunit.Host) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Aggregations

RMIException (org.apache.geode.test.dunit.RMIException)23 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)20 Test (org.junit.Test)20 VM (org.apache.geode.test.dunit.VM)17 Host (org.apache.geode.test.dunit.Host)16 IgnoredException (org.apache.geode.test.dunit.IgnoredException)14 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)10 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)9 IOException (java.io.IOException)6 PartitionOfflineException (org.apache.geode.cache.persistence.PartitionOfflineException)6 Cache (org.apache.geode.cache.Cache)5 AsyncInvocation (org.apache.geode.test.dunit.AsyncInvocation)5 RevokedPersistentDataException (org.apache.geode.cache.persistence.RevokedPersistentDataException)4 AttributesFactory (org.apache.geode.cache.AttributesFactory)3 CacheClosedException (org.apache.geode.cache.CacheClosedException)3 DiskStore (org.apache.geode.cache.DiskStore)3 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)3 PartitionedRegionStorageException (org.apache.geode.cache.PartitionedRegionStorageException)3 DistributionManager (org.apache.geode.distributed.internal.DistributionManager)3 DistributionMessage (org.apache.geode.distributed.internal.DistributionMessage)3