1 package org.apache.hadoop.hbase.regionserver;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import static org.junit.Assert.assertEquals;
20
21 import org.apache.hadoop.hbase.HConstants;
22 import org.apache.hadoop.hbase.SmallTests;
23 import org.apache.hadoop.hbase.util.Pair;
24 import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MultiRequest;
25 import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.RequestHeader;
26 import org.junit.Test;
27 import org.junit.experimental.categories.Category;
28 import org.mockito.Mockito;
29
30 import com.google.protobuf.Message;
31
32
33
34
35
36 @Category(SmallTests.class)
37 public class TestQosFunction {
38 @Test
39 public void testPriority() {
40 HRegionServer hrs = Mockito.mock(HRegionServer.class);
41 QosFunction qosFunction = new QosFunction(hrs);
42
43
44 checkMethod("ReplicateWALEntry", HConstants.REPLICATION_QOS, qosFunction);
45
46 checkMethod("OpenRegion", HConstants.HIGH_QOS, qosFunction);
47 }
48
49 private void checkMethod(final String methodName, final int expected, final QosFunction qosf) {
50 RequestHeader.Builder builder = RequestHeader.newBuilder();
51 builder.setMethodName(methodName);
52 Pair<RequestHeader, Message> headerAndParam =
53 new Pair<RequestHeader, Message>(builder.build(), null);
54 assertEquals(methodName, expected, qosf.apply(headerAndParam).intValue());
55 }
56 }