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);
}
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();
}
}
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;
}
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);
}
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);
}
Aggregations