Search in sources :

Example 6 with RevokedPersistentDataException

use of org.apache.geode.cache.persistence.RevokedPersistentDataException 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)

Example 7 with RevokedPersistentDataException

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

the class PersistentPartitionedRegionDUnitTest method testRevokedMemberRedundancy1.

/**
   * Test to make sure that we recreate a bucket if a member is revoked
   * 
   * @throws Throwable
   */
@Test
public void testRevokedMemberRedundancy1() throws Throwable {
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    VM vm1 = host.getVM(1);
    VM vm2 = host.getVM(2);
    createPR(vm0, 1);
    createPR(vm1, 1);
    createData(vm0, 0, NUM_BUCKETS, "a");
    Set<Integer> vm0Buckets = getBucketList(vm0);
    Set<Integer> vm1Buckets = getBucketList(vm1);
    assertEquals(vm0Buckets, vm1Buckets);
    closeCache(vm1);
    // This should work, because this bucket is still available.
    checkData(vm0, 0, NUM_BUCKETS, "a");
    createData(vm0, 0, NUM_BUCKETS, "b");
    revokeKnownMissingMembers(vm2, 1);
    // This should make a copy of all of the buckets,
    // because we have revoked VM1.
    createPR(vm2, 1);
    Set<Integer> vm2Buckets = getBucketList(vm2);
    assertEquals(vm1Buckets, vm2Buckets);
    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;
        }
    }
    // Test that we can bounce vm0 and vm1, and still get a RevokedPersistentDataException
    // when vm1 tries to recover
    closeCache(vm0);
    closeCache(vm2);
    AsyncInvocation async0 = createPRAsync(vm0, 1);
    AsyncInvocation async2 = createPRAsync(vm2, 1);
    async0.getResult();
    async2.getResult();
    try {
        createPR(vm1, 1);
        fail("Should have recieved a RevokedPersistentDataException");
    } catch (RMIException e) {
        // We revoked this member.
        if (!(e.getCause() instanceof RevokedPersistentDataException)) {
            throw e;
        }
    }
    ex.remove();
    // The data shouldn't be affected.
    checkData(vm2, 0, NUM_BUCKETS, "b");
}
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 8 with RevokedPersistentDataException

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

the class PersistentRecoveryOrderDUnitTest method testRevokeAMember.

/**
   * Tests to make sure that we stop waiting for a member that we revoke.
   * 
   * @throws Exception
   */
@Test
public void testRevokeAMember() throws Exception {
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    VM vm1 = host.getVM(1);
    VM vm2 = host.getVM(2);
    LogWriterUtils.getLogWriter().info("Creating region in VM0");
    createPersistentRegion(vm0);
    LogWriterUtils.getLogWriter().info("Creating region in VM1");
    createPersistentRegion(vm1);
    putAnEntry(vm0);
    vm0.invoke(new SerializableRunnable("Check for waiting regions") {

        public void run() {
            GemFireCacheImpl cache = (GemFireCacheImpl) getCache();
            PersistentMemberManager mm = cache.getPersistentMemberManager();
            Map<String, Set<PersistentMemberID>> waitingRegions = mm.getWaitingRegions();
            assertEquals(0, waitingRegions.size());
        }
    });
    LogWriterUtils.getLogWriter().info("closing region in vm0");
    closeRegion(vm0);
    updateTheEntry(vm1);
    LogWriterUtils.getLogWriter().info("closing region in vm1");
    closeCache(vm1);
    // This ought to wait for VM1 to come back
    LogWriterUtils.getLogWriter().info("Creating region in VM0");
    AsyncInvocation future = createPersistentRegionAsync(vm0);
    waitForBlockedInitialization(vm0);
    assertTrue(future.isAlive());
    vm2.invoke(new SerializableRunnable("Revoke the member") {

        public void run() {
            GemFireCacheImpl cache = (GemFireCacheImpl) getCache();
            DistributedSystemConfig config;
            AdminDistributedSystem adminDS = null;
            try {
                config = AdminDistributedSystemFactory.defineDistributedSystem(getSystem(), "");
                adminDS = AdminDistributedSystemFactory.getDistributedSystem(config);
                adminDS.connect();
                Set<PersistentID> missingIds = adminDS.getMissingPersistentMembers();
                LogWriterUtils.getLogWriter().info("waiting members=" + missingIds);
                assertEquals(1, missingIds.size());
                PersistentID missingMember = missingIds.iterator().next();
                adminDS.revokePersistentMember(missingMember.getUUID());
            } catch (AdminException e) {
                throw new RuntimeException(e);
            } finally {
                if (adminDS != null) {
                    adminDS.disconnect();
                }
            }
        }
    });
    future.join(MAX_WAIT);
    if (future.isAlive()) {
        fail("Region not created within" + MAX_WAIT);
    }
    if (future.exceptionOccurred()) {
        throw new Exception(future.getException());
    }
    checkForRecoveryStat(vm0, true);
    // Check to make sure we recovered the old
    // value of the entry.
    SerializableRunnable checkForEntry = new SerializableRunnable("check for the entry") {

        public void run() {
            Cache cache = getCache();
            Region region = cache.getRegion(REGION_NAME);
            assertEquals("B", region.get("A"));
        }
    };
    vm0.invoke(checkForEntry);
    // Now, we should not be able to create a region
    // in vm1, because the this member was revoked
    LogWriterUtils.getLogWriter().info("Creating region in VM1");
    IgnoredException e = IgnoredException.addIgnoredException(RevokedPersistentDataException.class.getSimpleName(), vm1);
    try {
        createPersistentRegion(vm1);
        fail("We should have received a split distributed system exception");
    } catch (RuntimeException expected) {
        if (!(expected.getCause() instanceof RevokedPersistentDataException)) {
            throw expected;
        }
    } finally {
        e.remove();
    }
    closeCache(vm1);
    // Restart vm0
    closeCache(vm0);
    createPersistentRegion(vm0);
// Make sure we still get a RevokedPersistentDataException
// TODO - RVV - This won't work until we actually persist the revoked
// members. I want to refactor to use disk store id before we do that.
// getLogWriter().info("Creating region in VM1");
// e = addExpectedException(RevokedPersistentDataException.class.getSimpleName(), vm1);
// try {
// createPersistentRegion(vm1);
// fail("We should have received a split distributed system exception");
// } catch(RuntimeException expected) {
// if(!(expected.getCause() instanceof RevokedPersistentDataException)) {
// throw expected;
// }
// //Do nothing
// } finally {
// e.remove();
// }
}
Also used : AdminException(org.apache.geode.admin.AdminException) RevokedPersistentDataException(org.apache.geode.cache.persistence.RevokedPersistentDataException) Set(java.util.Set) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) Host(org.apache.geode.test.dunit.Host) AsyncInvocation(org.apache.geode.test.dunit.AsyncInvocation) AdminDistributedSystem(org.apache.geode.admin.AdminDistributedSystem) RevokedPersistentDataException(org.apache.geode.cache.persistence.RevokedPersistentDataException) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) DistributedSystemDisconnectedException(org.apache.geode.distributed.DistributedSystemDisconnectedException) AdminException(org.apache.geode.admin.AdminException) ConflictingPersistentDataException(org.apache.geode.cache.persistence.ConflictingPersistentDataException) IgnoredException(org.apache.geode.test.dunit.IgnoredException) LockServiceDestroyedException(org.apache.geode.distributed.LockServiceDestroyedException) CacheClosedException(org.apache.geode.cache.CacheClosedException) PersistentReplicatesOfflineException(org.apache.geode.cache.persistence.PersistentReplicatesOfflineException) IOException(java.io.IOException) DistributedSystemConfig(org.apache.geode.admin.DistributedSystemConfig) VM(org.apache.geode.test.dunit.VM) GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl) LocalRegion(org.apache.geode.internal.cache.LocalRegion) DistributedRegion(org.apache.geode.internal.cache.DistributedRegion) DiskRegion(org.apache.geode.internal.cache.DiskRegion) Region(org.apache.geode.cache.Region) IgnoredException(org.apache.geode.test.dunit.IgnoredException) Map(java.util.Map) HashMap(java.util.HashMap) PersistentID(org.apache.geode.cache.persistence.PersistentID) Cache(org.apache.geode.cache.Cache) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test)

Aggregations

RevokedPersistentDataException (org.apache.geode.cache.persistence.RevokedPersistentDataException)8 Host (org.apache.geode.test.dunit.Host)6 IgnoredException (org.apache.geode.test.dunit.IgnoredException)6 VM (org.apache.geode.test.dunit.VM)6 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)6 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)6 Test (org.junit.Test)6 AsyncInvocation (org.apache.geode.test.dunit.AsyncInvocation)4 RMIException (org.apache.geode.test.dunit.RMIException)4 ConflictingPersistentDataException (org.apache.geode.cache.persistence.ConflictingPersistentDataException)3 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)3 File (java.io.File)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 AdminDistributedSystem (org.apache.geode.admin.AdminDistributedSystem)2 AdminException (org.apache.geode.admin.AdminException)2 DistributedSystemConfig (org.apache.geode.admin.DistributedSystemConfig)2 Cache (org.apache.geode.cache.Cache)2 CacheClosedException (org.apache.geode.cache.CacheClosedException)2