use of org.apache.geode.cache.CacheClosedException 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.CacheClosedException 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);
}
use of org.apache.geode.cache.CacheClosedException in project geode by apache.
the class PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest method executeFunction.
public static void executeFunction() throws ServerException, InterruptedException {
Region region = cache.getRegion(PartitionedRegionName);
assertNotNull(region);
final HashSet testKeysSet = new HashSet();
for (int i = (totalNumBuckets.intValue() * 10); i > 0; i--) {
testKeysSet.add("execKey-" + i);
}
DistributedSystem.setThreadsSocketPolicy(false);
Function function = new TestFunction(true, TEST_FUNCTION2);
FunctionService.registerFunction(function);
Execution dataSet = FunctionService.onRegion(region);
try {
ResultCollector rc1 = dataSet.withFilter(testKeysSet).setArguments(Boolean.TRUE).execute(function.getId());
HashMap resultMap = ((HashMap) rc1.getResult());
assertEquals(3, resultMap.size());
Iterator mapIterator = resultMap.entrySet().iterator();
Map.Entry entry = null;
DistributedMember key = null;
ArrayList resultListForMember = null;
while (mapIterator.hasNext()) {
entry = (Map.Entry) mapIterator.next();
key = (DistributedMember) entry.getKey();
resultListForMember = (ArrayList) entry.getValue();
for (Object result : resultListForMember) {
assertEquals(Boolean.TRUE, result);
}
}
} catch (Exception e) {
LogWriterUtils.getLogWriter().info("Got an exception : " + e.getMessage());
assertTrue(e instanceof EOFException || e instanceof SocketException || e instanceof SocketTimeoutException || e instanceof ServerException || e instanceof IOException || e instanceof CacheClosedException);
}
}
use of org.apache.geode.cache.CacheClosedException in project geode by apache.
the class LuceneQueryFunctionJUnitTest method whenServiceThrowsCacheClosedDuringQueryExecutionFunctionExceptionShouldBeThrown.
@Test(expected = InternalFunctionInvocationTargetException.class)
public void whenServiceThrowsCacheClosedDuringQueryExecutionFunctionExceptionShouldBeThrown() throws Exception {
when(mockContext.getDataSet()).thenReturn(mockRegion);
when(mockContext.getArguments()).thenReturn(searchArgs);
LuceneQueryFunction function = new LuceneQueryFunction();
when(mockService.getIndex(eq("indexName"), eq(regionPath))).thenThrow(new CacheClosedException());
function.execute(mockContext);
}
use of org.apache.geode.cache.CacheClosedException in project geode by apache.
the class LuceneQueryFunctionJUnitTest method whenCacheIsClosedDuringLuceneQueryExecutionInternalFunctionShouldBeThrownToTriggerFunctionServiceRetry.
@Test(expected = InternalFunctionInvocationTargetException.class)
public void whenCacheIsClosedDuringLuceneQueryExecutionInternalFunctionShouldBeThrownToTriggerFunctionServiceRetry() throws Exception {
when(mockContext.getDataSet()).thenReturn(mockRegion);
when(mockContext.getArguments()).thenReturn(searchArgs);
LuceneQueryFunction function = new LuceneQueryFunction();
when(mockRepoManager.getRepositories(eq(mockContext))).thenThrow(new CacheClosedException());
function.execute(mockContext);
}
Aggregations