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