1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.hadoop.hbase.io.hfile.slab;
21
22 import org.apache.hadoop.hbase.io.hfile.CacheTestUtils;
23 import org.junit.After;
24 import org.junit.Before;
25 import org.junit.Test;
26
27
28
29
30
31
32
33
34 public class TestSingleSizeCache {
35 SingleSizeCache cache;
36 final int CACHE_SIZE = 1000000;
37 final int NUM_BLOCKS = 100;
38 final int BLOCK_SIZE = CACHE_SIZE / NUM_BLOCKS;
39 final int NUM_THREADS = 100;
40 final int NUM_QUERIES = 10000;
41
42 @Before
43 public void setup() {
44 cache = new SingleSizeCache(BLOCK_SIZE, NUM_BLOCKS, null);
45 }
46
47 @After
48 public void tearDown() {
49 cache.shutdown();
50 }
51
52 @Test
53 public void testCacheSimple() throws Exception {
54 CacheTestUtils.testCacheSimple(cache, BLOCK_SIZE, NUM_QUERIES);
55 }
56
57 @Test
58 public void testCacheMultiThreaded() throws Exception {
59 CacheTestUtils.testCacheMultiThreaded(cache, BLOCK_SIZE,
60 NUM_THREADS, NUM_QUERIES, 0.80);
61 }
62
63 @Test
64 public void testCacheMultiThreadedSingleKey() throws Exception {
65 CacheTestUtils.hammerSingleKey(cache, BLOCK_SIZE, NUM_THREADS, NUM_QUERIES);
66 }
67
68 @Test
69 public void testCacheMultiThreadedEviction() throws Exception {
70 CacheTestUtils.hammerEviction(cache, BLOCK_SIZE, NUM_THREADS, NUM_QUERIES);
71 }
72
73 @Test
74 public void testHeapSizeChanges(){
75 CacheTestUtils.testHeapSizeChanges(cache, BLOCK_SIZE);
76 }
77
78 }