public static MemoryAllocatorImpl getAllocator() { MemoryAllocatorImpl result = singleton; if (result == null) { throw new CacheClosedException("Off Heap memory allocator does not exist."); } return result; }
@Override public Cache getCache() throws CacheClosedException { if (cache == null) { throw new CacheClosedException("FunctionContext does not have a valid Cache"); } return cache; }
@Override public boolean addAll(int index, Collection c) { throw new CacheClosedException("This pool has been closed"); } }
@Override public boolean add(Object element) { throw new CacheClosedException("This pool has been closed"); }
public static PdxSerializer getPdxSerializer() { PdxSerializer result = pdxSerializer.get(); if (result == null && !open && pdxSerializerWasSet) { throw new CacheClosedException("Could not PDX serialize because the cache was closed"); } return result; }
@Override public boolean authorizeOperation(String regionName, OperationContext context) { if (context instanceof ExecuteCQOperationContext) { cache.close(); // return false; throw new CacheClosedException("cache is closed"); } return true; } }
InternalCache getCache() { InternalCache result = cache; if (result == null) { throw new IllegalStateException("Missing cache instance."); } if (result.isClosed()) { throw new CacheClosedException(); } return result; }
@Override public void run() { throw new CacheClosedException(); } });
@Override public RuntimeException generateCancelledException(Throwable e) { if (isClosed()) { return new CacheClosedException("The disk store is closed", e); } else { return null; } }
@Before public void setUp() { cache = mock(InternalCache.class); region = mock(LocalRegion.class); cancelCriterion = mock(CancelCriterion.class); when(cache.getCancelCriterion()).thenReturn(cancelCriterion); doThrow(new CacheClosedException()).when(cancelCriterion).checkCancelInProgress(any()); }
@Override public RuntimeException generateCancelledException(Throwable e) { // This grossness is necessary because there are instances where the // region can exist without having a cache (XML creation) checkFailure(); Cache cache = LocalRegion.this.getCache(); if (cache == null) { return new CacheClosedException("No cache", e); } return cache.getCancelCriterion().generateCancelledException(e); }
@Test public void sendShouldHandleCancelExceptionFromWaitForReplies() throws Exception { ReplyException replyException = new ReplyException("expected exception", new CacheClosedException("expected exception")); doThrow(replyException).when(backupReplyProcessor).waitForReplies(); abortBackupStep.send(); }
@Test public void sendShouldHandleCancelExceptionFromWaitForReplies() throws Exception { ReplyException replyException = new ReplyException("expected exception", new CacheClosedException("expected exception")); doThrow(replyException).when(flushToDiskReplyProcessor).waitForReplies(); flushToDiskStep.send(); }
@Test public void sendShouldHandleCancelExceptionFromWaitForReplies() throws Exception { ReplyException replyException = new ReplyException("expected exception", new CacheClosedException("expected exception")); doThrow(replyException).when(finishBackupReplyProcessor).waitForReplies(); finishBackupStep.send(); }
@Test public void sendShouldHandleCancelExceptionFromWaitForReplies() throws Exception { ReplyException replyException = new ReplyException("expected exception", new CacheClosedException("expected exception")); doThrow(replyException).when(prepareBackupReplyProcessor).waitForReplies(); prepareBackupStep.send(); }
@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); }
@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), eq(false))) .thenThrow(new CacheClosedException()); function.execute(mockContext); }
@Test public void executeThrowsTransactionDataNodeHasDepartedExceptionIfDoOpFailedWithCacheClosedException() { doThrow(new CacheClosedException("")).when(txState).doBeforeCompletion(); beforeCompletion.doOp(txState); assertThatThrownBy(() -> beforeCompletion.execute(cancelCriterion)) .isInstanceOf(TransactionDataNodeHasDepartedException.class); }
@Test public void testExecuteOnMemberWithNoCache() { final ListDiskStoresFunction testListDiskStoresFunction = new ListDiskStoresFunction(); final TestResultSender testResultSender = new TestResultSender(); when(mockFunctionContext.getCache()) .thenThrow(new CacheClosedException("Mocked CacheClosedException")); when(mockFunctionContext.getResultSender()).thenReturn(testResultSender); testListDiskStoresFunction.execute(mockFunctionContext); assertThatThrownBy(testResultSender::getResults).isInstanceOf(CacheClosedException.class) .hasMessage("Mocked CacheClosedException"); }
@Test(expected = CacheClosedException.class) public void propagatesException_ifCancelInProgress() { persistenceInitialImageAdvisor = persistenceInitialImageAdvisorWithDiskImage(); CancelCriterion cancelCriterion = mock(CancelCriterion.class); when(cacheDistributionAdvisor.getAdvisee().getCancelCriterion()).thenReturn(cancelCriterion); doThrow(new CacheClosedException()).when(cancelCriterion).checkCancelInProgress(any()); persistenceInitialImageAdvisor.getAdvice(null); }