1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.hadoop.hbase.regionserver;
19
20 import static org.junit.Assert.assertTrue;
21
22 import org.apache.hadoop.conf.Configuration;
23 import org.apache.hadoop.hbase.CategoryBasedTimeout;
24 import org.apache.hadoop.hbase.HBaseConfiguration;
25 import org.apache.hadoop.hbase.ipc.FifoRpcScheduler;
26 import org.apache.hadoop.hbase.ipc.RWQueueRpcExecutor;
27 import org.apache.hadoop.hbase.ipc.RpcExecutor;
28 import org.apache.hadoop.hbase.ipc.RpcScheduler;
29 import org.apache.hadoop.hbase.ipc.SimpleRpcScheduler;
30 import org.apache.hadoop.hbase.testclassification.SmallTests;
31 import org.junit.Before;
32 import org.junit.ClassRule;
33 import org.junit.Rule;
34 import org.junit.Test;
35 import org.junit.experimental.categories.Category;
36 import org.junit.rules.TestName;
37 import org.junit.rules.TestRule;
38
39
40
41
42
43 @Category(SmallTests.class)
44 public class TestRpcSchedulerFactory {
45 @Rule public TestName testName = new TestName();
46 @ClassRule public static TestRule timeout =
47 CategoryBasedTimeout.forClass(TestRpcSchedulerFactory.class);
48 private Configuration conf;
49
50 @Before
51 public void setUp() throws Exception {
52 this.conf = HBaseConfiguration.create();
53 }
54
55 @Test
56 public void testRWQ() {
57
58
59 this.conf.setDouble(RWQueueRpcExecutor.CALL_QUEUE_READ_SHARE_CONF_KEY, 0.5);
60 this.conf.setDouble(RpcExecutor.CALL_QUEUE_HANDLER_FACTOR_CONF_KEY, 0.5);
61 this.conf.setDouble(RWQueueRpcExecutor.CALL_QUEUE_SCAN_SHARE_CONF_KEY, 0.5);
62 RpcSchedulerFactory factory = new SimpleRpcSchedulerFactory();
63 RpcScheduler rpcScheduler = factory.create(this.conf, null, null);
64 assertTrue(rpcScheduler.getClass().equals(SimpleRpcScheduler.class));
65 }
66
67 @Test
68 public void testFifo() {
69 RpcSchedulerFactory factory = new FifoRpcSchedulerFactory();
70 RpcScheduler rpcScheduler = factory.create(this.conf, null, null);
71 assertTrue(rpcScheduler.getClass().equals(FifoRpcScheduler.class));
72 }
73 }