Java 类org.apache.hadoop.hbase.io.hfile.bucket.BucketCache.RAMQueueEntry 实例源码

项目:ditb    文件:TestBucketWriterThread.java   
/**
 * Do Cache full exception
 * @throws IOException
 * @throws InterruptedException
 */
@Test (timeout=30000)
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(), (AtomicLong)Mockito.any());
  this.q.add(spiedRqe);
  doDrainOfOneEntry(bc, wt, q);
}
项目:pbase    文件:TestBucketWriterThread.java   
/**
 * Do Cache full exception
 * @throws IOException
 * @throws InterruptedException
 */
@Test (timeout=30000)
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(), (AtomicLong)Mockito.any());
  this.q.add(spiedRqe);
  doDrainOfOneEntry(bc, wt, q);
}
项目:hbase    文件:TestBucketWriterThread.java   
/**
 * Do Cache full exception
 * @throws IOException
 * @throws InterruptedException
 */
@Test (timeout=30000)
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);
}
项目:ditb    文件:TestBucketWriterThread.java   
/**
 * 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 (timeout=30000)
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(), (AtomicLong)Mockito.any());
  this.q.add(spiedRqe);
  doDrainOfOneEntry(bc, wt, q);
  // Cache disabled when ioes w/o ever healing.
  assertTrue(!bc.isCacheEnabled());
}
项目:ditb    文件:TestBucketWriterThread.java   
private static void doDrainOfOneEntry(final BucketCache bc, final BucketCache.WriterThread wt,
    final BlockingQueue<RAMQueueEntry> q)
throws InterruptedException {
  List<RAMQueueEntry> rqes = BucketCache.getRAMQueueEntries(q, new ArrayList<RAMQueueEntry>(1));
  wt.doDrain(rqes);
  assertTrue(q.isEmpty());
  assertTrue(bc.ramCache.isEmpty());
  assertEquals(0, bc.heapSize());
}
项目:pbase    文件:TestBucketWriterThread.java   
/**
 * 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 (timeout=30000)
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(), (AtomicLong)Mockito.any());
  this.q.add(spiedRqe);
  doDrainOfOneEntry(bc, wt, q);
  // Cache disabled when ioes w/o ever healing.
  assertTrue(!bc.isCacheEnabled());
}
项目:pbase    文件:TestBucketWriterThread.java   
private static void doDrainOfOneEntry(final BucketCache bc, final BucketCache.WriterThread wt,
    final BlockingQueue<RAMQueueEntry> q)
throws InterruptedException {
  List<RAMQueueEntry> rqes = BucketCache.getRAMQueueEntries(q, new ArrayList<RAMQueueEntry>(1));
  wt.doDrain(rqes);
  assertTrue(q.isEmpty());
  assertTrue(bc.ramCache.isEmpty());
  assertEquals(0, bc.heapSize());
}
项目:hbase    文件:TestBucketWriterThread.java   
/**
 * 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 (timeout=30000)
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());
}
项目:hbase    文件:TestBucketWriterThread.java   
private static void doDrainOfOneEntry(final BucketCache bc, final BucketCache.WriterThread wt,
    final BlockingQueue<RAMQueueEntry> q)
throws InterruptedException {
  List<RAMQueueEntry> rqes = BucketCache.getRAMQueueEntries(q, new ArrayList<>(1));
  wt.doDrain(rqes);
  assertTrue(q.isEmpty());
  assertTrue(bc.ramCache.isEmpty());
  assertEquals(0, bc.heapSize());
}