1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.hadoop.hbase.regionserver;
20
21 import static org.mockito.Mockito.when;
22
23 import org.apache.hadoop.conf.Configuration;
24 import org.apache.hadoop.hbase.*;
25 import org.apache.hadoop.hbase.testclassification.SmallTests;
26 import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MultiRequest;
27 import org.junit.Before;
28 import org.junit.Test;
29 import org.junit.experimental.categories.Category;
30 import org.mockito.Mockito;
31
32
33
34
35
36 @Category({ SmallTests.class})
37 public class TestQosFunction extends QosTestHelper {
38 private Configuration conf;
39 private RSRpcServices rpcServices;
40 private AnnotationReadingPriorityFunction qosFunction;
41
42 @Before
43 public void setUp() {
44 conf = HBaseConfiguration.create();
45 rpcServices = Mockito.mock(RSRpcServices.class);
46 when(rpcServices.getConfiguration()).thenReturn(conf);
47 qosFunction = new AnnotationReadingPriorityFunction(rpcServices, RSRpcServices.class);
48 }
49
50 @Test
51 public void testPriority() {
52
53 checkMethod(conf, "ReplicateWALEntry", HConstants.REPLICATION_QOS, qosFunction);
54
55 checkMethod(conf, "OpenRegion", HConstants.ADMIN_QOS, qosFunction);
56
57 checkMethod(conf, "Multi", HConstants.NORMAL_QOS, qosFunction,
58 MultiRequest.getDefaultInstance());
59
60 }
61
62
63 @Test
64 public void testAnnotations() {
65 checkMethod(conf, "CloseRegion", HConstants.ADMIN_QOS, qosFunction);
66 checkMethod(conf, "CompactRegion", HConstants.ADMIN_QOS, qosFunction);
67 checkMethod(conf, "FlushRegion", HConstants.ADMIN_QOS, qosFunction);
68 }
69 }