Search in sources :

Example 1 with RevokeFailedException

use of org.apache.geode.cache.persistence.RevokeFailedException in project geode by apache.

the class PersistentPartitionedRegionDUnitTest method testRevokeBeforeStartup.

// GEODE-974: async actions, time sensitive, 65 second timeouts
@Category(FlakyTest.class)
@Test
public void testRevokeBeforeStartup() throws Throwable {
    IgnoredException.addIgnoredException("RevokeFailedException");
    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);
    // This should fail with a revocation failed message
    try {
        revokeAllMembers(vm2);
        fail("The revoke should have failed, because members are running");
    } catch (RMIException e) {
        if (!(e.getCause() instanceof ReplyException && e.getCause().getCause() instanceof RevokeFailedException)) {
            throw e;
        }
    }
    closeCache(vm0);
    createData(vm1, 0, numBuckets, "b");
    File vm1Directory = getDiskDirectory(vm1);
    closeCache(vm1);
    vm0.invoke(new SerializableRunnable("get cache") {

        public void run() {
            getCache();
        }
    });
    revokeMember(vm2, vm1Directory);
    AsyncInvocation a1 = createPRAsync(vm0, 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) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) Host(org.apache.geode.test.dunit.Host) AsyncInvocation(org.apache.geode.test.dunit.AsyncInvocation) ReplyException(org.apache.geode.distributed.internal.ReplyException) VM(org.apache.geode.test.dunit.VM) IgnoredException(org.apache.geode.test.dunit.IgnoredException) File(java.io.File) RevokeFailedException(org.apache.geode.cache.persistence.RevokeFailedException) Category(org.junit.experimental.categories.Category) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test)

Aggregations

File (java.io.File)1 RevokeFailedException (org.apache.geode.cache.persistence.RevokeFailedException)1 RevokedPersistentDataException (org.apache.geode.cache.persistence.RevokedPersistentDataException)1 ReplyException (org.apache.geode.distributed.internal.ReplyException)1 AsyncInvocation (org.apache.geode.test.dunit.AsyncInvocation)1 Host (org.apache.geode.test.dunit.Host)1 IgnoredException (org.apache.geode.test.dunit.IgnoredException)1 RMIException (org.apache.geode.test.dunit.RMIException)1 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)1 VM (org.apache.geode.test.dunit.VM)1 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)1 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)1 Test (org.junit.Test)1 Category (org.junit.experimental.categories.Category)1