Search in sources :

Example 1 with ConflictingPersistentDataException

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

the class PersistentPartitionedRegionDUnitTest method testDiskConflictWithCoLocation.

@Test
public void testDiskConflictWithCoLocation() throws Exception {
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    VM vm1 = host.getVM(1);
    // createPR(vm0, 1);
    createCoLocatedPR(vm0, 1, false);
    // create some buckets
    createData(vm0, 0, 2, "a");
    createData(vm0, 0, 2, "a", PR_CHILD_REGION_NAME);
    closePR(vm0, PR_CHILD_REGION_NAME);
    closePR(vm0);
    // createPR(vm1, 1);
    createCoLocatedPR(vm1, 1, false);
    // create an overlapping bucket
    createData(vm1, 2, 4, "a");
    createData(vm1, 2, 4, "a", PR_CHILD_REGION_NAME);
    IgnoredException[] expectVm0 = { IgnoredException.addIgnoredException("ConflictingPersistentDataException", vm0), IgnoredException.addIgnoredException("CacheClosedException", vm0) };
    try {
        createCoLocatedPR(vm0, 1, true);
        // Cache should have closed due to ConflictingPersistentDataException
        vm0.invoke(() -> {
            Awaitility.await().atMost(MAX_WAIT, TimeUnit.MILLISECONDS).until(() -> basicGetCache().isClosed());
            basicGetCache().getCancelCriterion();
        });
    } catch (Exception ex) {
        boolean expectedException = false;
        if (ex.getCause() instanceof CacheClosedException) {
            CacheClosedException cce = (CacheClosedException) ex.getCause();
            if (cce.getCause() instanceof ConflictingPersistentDataException) {
                expectedException = true;
            }
        }
        if (!expectedException) {
            throw ex;
        }
    } finally {
        for (IgnoredException ie : expectVm0) {
            ie.remove();
        }
    }
    closePR(vm1, PR_CHILD_REGION_NAME);
    closePR(vm1);
}
Also used : VM(org.apache.geode.test.dunit.VM) IgnoredException(org.apache.geode.test.dunit.IgnoredException) ConflictingPersistentDataException(org.apache.geode.cache.persistence.ConflictingPersistentDataException) Host(org.apache.geode.test.dunit.Host) CacheClosedException(org.apache.geode.cache.CacheClosedException) RevokeFailedException(org.apache.geode.cache.persistence.RevokeFailedException) RevokedPersistentDataException(org.apache.geode.cache.persistence.RevokedPersistentDataException) ConflictingPersistentDataException(org.apache.geode.cache.persistence.ConflictingPersistentDataException) DiskAccessException(org.apache.geode.cache.DiskAccessException) ConcurrentModificationException(java.util.ConcurrentModificationException) IgnoredException(org.apache.geode.test.dunit.IgnoredException) PartitionedRegionStorageException(org.apache.geode.cache.PartitionedRegionStorageException) RMIException(org.apache.geode.test.dunit.RMIException) CacheClosedException(org.apache.geode.cache.CacheClosedException) PartitionOfflineException(org.apache.geode.cache.persistence.PartitionOfflineException) ServerOperationException(org.apache.geode.cache.client.ServerOperationException) IOException(java.io.IOException) ReplyException(org.apache.geode.distributed.internal.ReplyException) QueryException(org.apache.geode.cache.query.QueryException) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test)

Example 2 with ConflictingPersistentDataException

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

the class PersistentRecoveryOrderDUnitTest method testSplitBrain.

@Test
public void testSplitBrain() throws Exception {
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    VM vm1 = host.getVM(1);
    createPersistentRegion(vm0);
    putAnEntry(vm0);
    closeRegion(vm0);
    createPersistentRegion(vm1);
    updateTheEntry(vm1);
    closeRegion(vm1);
    // VM0 doesn't know that VM1 ever existed
    // so it will start up.
    createPersistentRegion(vm0);
    IgnoredException e = IgnoredException.addIgnoredException(ConflictingPersistentDataException.class.getSimpleName(), vm1);
    try {
        // VM1 should not start up, because we should detect that vm1
        // was never in the same distributed system as vm0
        createPersistentRegion(vm1);
        fail("Should have thrown an exception, vm1 is from a 'different' distributed system");
    } catch (RuntimeException ok) {
        if (!(ok.getCause() instanceof ConflictingPersistentDataException)) {
            throw ok;
        }
    } finally {
        e.remove();
    }
}
Also used : VM(org.apache.geode.test.dunit.VM) IgnoredException(org.apache.geode.test.dunit.IgnoredException) ConflictingPersistentDataException(org.apache.geode.cache.persistence.ConflictingPersistentDataException) 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 3 with ConflictingPersistentDataException

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

the class PersistenceAdvisorImpl method checkMyStateOnMembers.

public boolean checkMyStateOnMembers(Set<InternalDistributedMember> replicates) throws ReplyException {
    PersistentStateQueryResults remoteStates = getMyStateOnMembers(replicates);
    boolean equal = false;
    if (observer != null) {
        observer.observe(regionPath);
    }
    for (Map.Entry<InternalDistributedMember, PersistentMemberState> entry : remoteStates.stateOnPeers.entrySet()) {
        InternalDistributedMember member = entry.getKey();
        PersistentMemberID remoteId = remoteStates.persistentIds.get(member);
        final PersistentMemberID myId = getPersistentID();
        PersistentMemberState stateOnPeer = entry.getValue();
        if (PersistentMemberState.REVOKED.equals(stateOnPeer)) {
            throw new RevokedPersistentDataException(LocalizedStrings.PersistentMemberManager_Member_0_is_already_revoked.toLocalizedString(myId));
        }
        if (myId != null && stateOnPeer == null) {
            String message = LocalizedStrings.CreatePersistentRegionProcessor_SPLIT_DISTRIBUTED_SYSTEM.toLocalizedString(regionPath, member, remoteId, myId);
            throw new ConflictingPersistentDataException(message);
        }
        if (myId != null && stateOnPeer == PersistentMemberState.EQUAL) {
            equal = true;
        }
        // comes back online.
        if (remoteId != null) {
            PersistentMemberState remoteState = getPersistedStateOfMember(remoteId);
            if (remoteState == PersistentMemberState.OFFLINE) {
                String message = LocalizedStrings.CreatePersistentRegionProcessor_INITIALIZING_FROM_OLD_DATA.toLocalizedString(regionPath, member, remoteId, myId);
                throw new ConflictingPersistentDataException(message);
            }
        }
    }
    return equal;
}
Also used : RevokedPersistentDataException(org.apache.geode.cache.persistence.RevokedPersistentDataException) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) ConflictingPersistentDataException(org.apache.geode.cache.persistence.ConflictingPersistentDataException)

Example 4 with ConflictingPersistentDataException

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

the class PersistentPartitionedRegionDUnitTest method testCleanupAfterConflict.

@Test
public void testCleanupAfterConflict() throws Exception {
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    VM vm1 = host.getVM(1);
    createPR(vm0, 0);
    // create some buckets
    createData(vm0, 0, 2, "a");
    closePR(vm0);
    createPR(vm1, 0);
    // create an overlapping bucket
    createData(vm1, 1, 2, "a");
    IgnoredException[] expectVm0 = { IgnoredException.addIgnoredException("ConflictingPersistentDataException", vm0), IgnoredException.addIgnoredException("CacheClosedException", vm0) };
    try {
        // This results in ConflictingPersistentDataException. As part of
        // GEODE-2918, the cache is closed, when ConflictingPersistentDataException
        // is encountered.
        createPR(vm0, 0);
        fail("should have seen a conflicting data exception");
    } catch (Exception ex) {
        boolean expectedException = false;
        if (ex.getCause() instanceof CacheClosedException) {
            CacheClosedException cce = (CacheClosedException) ex.getCause();
            if (cce.getCause() instanceof ConflictingPersistentDataException) {
                expectedException = true;
            }
        }
        if (!expectedException) {
            throw ex;
        }
    } finally {
        for (IgnoredException ie : expectVm0) {
            ie.remove();
        }
    }
    IgnoredException expectVm1 = IgnoredException.addIgnoredException("PartitionOfflineException", vm1);
    try {
        createData(vm1, 0, 1, "a");
    } catch (Exception e) {
        // restart.
        if (!(e.getCause() instanceof PartitionOfflineException)) {
            throw e;
        }
    } finally {
        expectVm1.remove();
    }
    closePR(vm1);
    // This should succeed, vm0 should not have persisted any view
    // information from vm1
    createPR(vm0, 0);
    checkData(vm0, 0, 2, "a");
    checkData(vm0, 2, 3, null);
}
Also used : PartitionOfflineException(org.apache.geode.cache.persistence.PartitionOfflineException) VM(org.apache.geode.test.dunit.VM) IgnoredException(org.apache.geode.test.dunit.IgnoredException) ConflictingPersistentDataException(org.apache.geode.cache.persistence.ConflictingPersistentDataException) Host(org.apache.geode.test.dunit.Host) CacheClosedException(org.apache.geode.cache.CacheClosedException) RevokeFailedException(org.apache.geode.cache.persistence.RevokeFailedException) RevokedPersistentDataException(org.apache.geode.cache.persistence.RevokedPersistentDataException) ConflictingPersistentDataException(org.apache.geode.cache.persistence.ConflictingPersistentDataException) DiskAccessException(org.apache.geode.cache.DiskAccessException) ConcurrentModificationException(java.util.ConcurrentModificationException) IgnoredException(org.apache.geode.test.dunit.IgnoredException) PartitionedRegionStorageException(org.apache.geode.cache.PartitionedRegionStorageException) RMIException(org.apache.geode.test.dunit.RMIException) CacheClosedException(org.apache.geode.cache.CacheClosedException) PartitionOfflineException(org.apache.geode.cache.persistence.PartitionOfflineException) ServerOperationException(org.apache.geode.cache.client.ServerOperationException) IOException(java.io.IOException) ReplyException(org.apache.geode.distributed.internal.ReplyException) QueryException(org.apache.geode.cache.query.QueryException) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test)

Example 5 with ConflictingPersistentDataException

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

the class PersistentPartitionedRegionDUnitTest method testDiskConflictWithRedundancy.

@Test
public void testDiskConflictWithRedundancy() throws Exception {
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    VM vm1 = host.getVM(1);
    createPR(vm0, 1);
    // create some buckets
    createData(vm0, 0, 2, "a");
    closePR(vm0);
    createPR(vm1, 1);
    // create an overlapping bucket
    createData(vm1, 1, 2, "a");
    IgnoredException[] expectVm0 = { IgnoredException.addIgnoredException("ConflictingPersistentDataException", vm0), IgnoredException.addIgnoredException("CacheClosedException", vm0) };
    try {
        createPR(vm0, 1);
        fail("should have seen a conflicting data exception");
    } catch (Exception ex) {
        boolean expectedException = false;
        if (ex.getCause() instanceof CacheClosedException) {
            CacheClosedException cce = (CacheClosedException) ex.getCause();
            if (cce.getCause() instanceof ConflictingPersistentDataException) {
                expectedException = true;
            }
        }
        if (!expectedException) {
            throw ex;
        }
    } finally {
        for (IgnoredException ie : expectVm0) {
            ie.remove();
        }
    }
    closePR(vm1);
}
Also used : VM(org.apache.geode.test.dunit.VM) IgnoredException(org.apache.geode.test.dunit.IgnoredException) ConflictingPersistentDataException(org.apache.geode.cache.persistence.ConflictingPersistentDataException) Host(org.apache.geode.test.dunit.Host) CacheClosedException(org.apache.geode.cache.CacheClosedException) RevokeFailedException(org.apache.geode.cache.persistence.RevokeFailedException) RevokedPersistentDataException(org.apache.geode.cache.persistence.RevokedPersistentDataException) ConflictingPersistentDataException(org.apache.geode.cache.persistence.ConflictingPersistentDataException) DiskAccessException(org.apache.geode.cache.DiskAccessException) ConcurrentModificationException(java.util.ConcurrentModificationException) IgnoredException(org.apache.geode.test.dunit.IgnoredException) PartitionedRegionStorageException(org.apache.geode.cache.PartitionedRegionStorageException) RMIException(org.apache.geode.test.dunit.RMIException) CacheClosedException(org.apache.geode.cache.CacheClosedException) PartitionOfflineException(org.apache.geode.cache.persistence.PartitionOfflineException) ServerOperationException(org.apache.geode.cache.client.ServerOperationException) IOException(java.io.IOException) ReplyException(org.apache.geode.distributed.internal.ReplyException) QueryException(org.apache.geode.cache.query.QueryException) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test)

Aggregations

ConflictingPersistentDataException (org.apache.geode.cache.persistence.ConflictingPersistentDataException)8 Host (org.apache.geode.test.dunit.Host)5 IgnoredException (org.apache.geode.test.dunit.IgnoredException)5 VM (org.apache.geode.test.dunit.VM)5 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)5 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)5 Test (org.junit.Test)5 IOException (java.io.IOException)4 RevokedPersistentDataException (org.apache.geode.cache.persistence.RevokedPersistentDataException)4 ConcurrentModificationException (java.util.ConcurrentModificationException)3 CacheClosedException (org.apache.geode.cache.CacheClosedException)3 DiskAccessException (org.apache.geode.cache.DiskAccessException)3 PartitionedRegionStorageException (org.apache.geode.cache.PartitionedRegionStorageException)3 ServerOperationException (org.apache.geode.cache.client.ServerOperationException)3 PartitionOfflineException (org.apache.geode.cache.persistence.PartitionOfflineException)3 RevokeFailedException (org.apache.geode.cache.persistence.RevokeFailedException)3 QueryException (org.apache.geode.cache.query.QueryException)3 ReplyException (org.apache.geode.distributed.internal.ReplyException)3 RMIException (org.apache.geode.test.dunit.RMIException)3 CountDownLatch (java.util.concurrent.CountDownLatch)1