001/** 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.apache.hadoop.hbase.regionserver; 019 020import static org.junit.Assert.assertTrue; 021 022import org.apache.hadoop.conf.Configuration; 023import org.apache.hadoop.hbase.HBaseClassTestRule; 024import org.apache.hadoop.hbase.HBaseConfiguration; 025import org.apache.hadoop.hbase.ipc.FifoRpcScheduler; 026import org.apache.hadoop.hbase.ipc.RWQueueRpcExecutor; 027import org.apache.hadoop.hbase.ipc.RpcExecutor; 028import org.apache.hadoop.hbase.ipc.RpcScheduler; 029import org.apache.hadoop.hbase.ipc.SimpleRpcScheduler; 030import org.apache.hadoop.hbase.testclassification.SmallTests; 031import org.junit.Before; 032import org.junit.ClassRule; 033import org.junit.Rule; 034import org.junit.Test; 035import org.junit.experimental.categories.Category; 036import org.junit.rules.TestName; 037 038/** 039 * A silly test that does nothing but make sure an rpcscheduler factory makes what it says 040 * it is going to make. 041 */ 042@Category(SmallTests.class) 043public class TestRpcSchedulerFactory { 044 045 @ClassRule 046 public static final HBaseClassTestRule CLASS_RULE = 047 HBaseClassTestRule.forClass(TestRpcSchedulerFactory.class); 048 049 @Rule public TestName testName = new TestName(); 050 private Configuration conf; 051 052 @Before 053 public void setUp() throws Exception { 054 this.conf = HBaseConfiguration.create(); 055 } 056 057 @Test 058 public void testRWQ() { 059 // Set some configs just to see how it changes the scheduler. Can't assert the settings had 060 // an effect. Just eyeball the log. 061 this.conf.setDouble(RWQueueRpcExecutor.CALL_QUEUE_READ_SHARE_CONF_KEY, 0.5); 062 this.conf.setDouble(RpcExecutor.CALL_QUEUE_HANDLER_FACTOR_CONF_KEY, 0.5); 063 this.conf.setDouble(RWQueueRpcExecutor.CALL_QUEUE_SCAN_SHARE_CONF_KEY, 0.5); 064 RpcSchedulerFactory factory = new SimpleRpcSchedulerFactory(); 065 RpcScheduler rpcScheduler = factory.create(this.conf, null, null); 066 assertTrue(rpcScheduler.getClass().equals(SimpleRpcScheduler.class)); 067 } 068 069 @Test 070 public void testFifo() { 071 RpcSchedulerFactory factory = new FifoRpcSchedulerFactory(); 072 RpcScheduler rpcScheduler = factory.create(this.conf, null, null); 073 assertTrue(rpcScheduler.getClass().equals(FifoRpcScheduler.class)); 074 } 075}