re.writeToCache(ioEngine, bucketAllocator, realCacheSize); LOG.warn("Failed allocation for " + (re == null ? "" : re.getKey()) + "; " + fle); BlockCacheKey key = entries.get(i).getKey(); heapSize.add(-1 * entries.get(i).getData().heapSize()); } else if (bucketEntries[i] != null){
new RAMQueueEntry(cacheKey, cachedItem, accessCount.incrementAndGet(), inMemory);
re.writeToCache(ioEngine, bucketAllocator, deserialiserMap, realCacheSize); LOG.warn("Failed allocation for " + (re == null ? "" : re.getKey()) + "; " + fle); BlockCacheKey key = entries.get(i).getKey(); heapSize.addAndGet(-1 * entries.get(i).getData().heapSize()); } else if (bucketEntries[i] != null){
new RAMQueueEntry(cacheKey, cachedItem, accessCount.incrementAndGet(), inMemory); if (ramCache.putIfAbsent(cacheKey, re) != null) { return;
if (removedBlock != null) { this.blockNumber.decrementAndGet(); this.heapSize.addAndGet(-1 * removedBlock.getData().heapSize());
/** * Do IOE. Take the RAMQueueEntry that was on the queue, doctor it to throw exception, then * put it back and process it. * @throws IOException * @throws InterruptedException */ @SuppressWarnings("unchecked") @Test public void testIOE() throws IOException, InterruptedException { this.bc.cacheBlock(this.plainKey, plainCacheable); RAMQueueEntry rqe = q.remove(); RAMQueueEntry spiedRqe = Mockito.spy(rqe); Mockito.doThrow(new IOException("Mocked!")).when(spiedRqe). writeToCache((IOEngine)Mockito.any(), (BucketAllocator)Mockito.any(), (UniqueIndexMap<Integer>)Mockito.any(), (LongAdder) Mockito.any()); this.q.add(spiedRqe); doDrainOfOneEntry(bc, wt, q); // Cache disabled when ioes w/o ever healing. assertTrue(!bc.isCacheEnabled()); }
/** * Do Cache full exception * @throws IOException * @throws InterruptedException */ @Test public void testCacheFullException() throws IOException, InterruptedException { this.bc.cacheBlock(this.plainKey, plainCacheable); RAMQueueEntry rqe = q.remove(); RAMQueueEntry spiedRqe = Mockito.spy(rqe); final CacheFullException cfe = new CacheFullException(0, 0); BucketEntry mockedBucketEntry = Mockito.mock(BucketEntry.class); Mockito.doThrow(cfe). doReturn(mockedBucketEntry). when(spiedRqe).writeToCache((IOEngine)Mockito.any(), (BucketAllocator)Mockito.any(), (UniqueIndexMap<Integer>)Mockito.any(), (LongAdder) Mockito.any()); this.q.add(spiedRqe); doDrainOfOneEntry(bc, wt, q); }
/** * Do Cache full exception * @throws IOException * @throws InterruptedException */ @Test public void testCacheFullException() throws IOException, InterruptedException { this.bc.cacheBlock(this.plainKey, plainCacheable); RAMQueueEntry rqe = q.remove(); RAMQueueEntry spiedRqe = Mockito.spy(rqe); final CacheFullException cfe = new CacheFullException(0, 0); BucketEntry mockedBucketEntry = Mockito.mock(BucketEntry.class); Mockito.doThrow(cfe). doReturn(mockedBucketEntry). when(spiedRqe).writeToCache(Mockito.any(), Mockito.any(), Mockito.any()); this.q.add(spiedRqe); doDrainOfOneEntry(bc, wt, q); }
/** * Do IOE. Take the RAMQueueEntry that was on the queue, doctor it to throw exception, then * put it back and process it. * @throws IOException * @throws InterruptedException */ @SuppressWarnings("unchecked") @Test public void testIOE() throws IOException, InterruptedException { this.bc.cacheBlock(this.plainKey, plainCacheable); RAMQueueEntry rqe = q.remove(); RAMQueueEntry spiedRqe = Mockito.spy(rqe); Mockito.doThrow(new IOException("Mocked!")).when(spiedRqe). writeToCache(Mockito.any(), Mockito.any(), Mockito.any()); this.q.add(spiedRqe); doDrainOfOneEntry(bc, wt, q); // Cache disabled when ioes w/o ever healing. assertTrue(!bc.isCacheEnabled()); }
private RAMQueueEntry checkRamCache(BlockCacheKey cacheKey) { RAMQueueEntry removedBlock = ramCache.remove(cacheKey); if (removedBlock != null) { this.blockNumber.decrement(); this.heapSize.add(-1 * removedBlock.getData().heapSize()); } return removedBlock; }