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.mockito.Mockito.when; 021 022import org.apache.hadoop.conf.Configuration; 023import org.apache.hadoop.hbase.HBaseConfiguration; 024import org.apache.hadoop.hbase.HConstants; 025import org.apache.hadoop.hbase.ipc.QosTestBase; 026import org.apache.hadoop.hbase.testclassification.MediumTests; 027import org.apache.hadoop.hbase.testclassification.RegionServerTests; 028import org.junit.jupiter.api.BeforeEach; 029import org.junit.jupiter.api.Tag; 030import org.junit.jupiter.api.Test; 031import org.mockito.Mockito; 032 033import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MultiRequest; 034 035/** 036 * Basic test that qos function is sort of working; i.e. a change in method naming style over in pb 037 * doesn't break it. 038 */ 039@Tag(RegionServerTests.TAG) 040@Tag(MediumTests.TAG) 041public class TestRSQosFunction extends QosTestBase { 042 043 private Configuration conf; 044 private RSRpcServices rpcServices; 045 private RSAnnotationReadingPriorityFunction qosFunction; 046 047 @BeforeEach 048 public void setUp() { 049 conf = HBaseConfiguration.create(); 050 rpcServices = Mockito.mock(RSRpcServices.class); 051 when(rpcServices.getConfiguration()).thenReturn(conf); 052 qosFunction = new RSAnnotationReadingPriorityFunction(rpcServices); 053 } 054 055 @Test 056 public void testPriority() { 057 // Set method name in pb style with the method name capitalized. 058 checkMethod(conf, "ReplicateWALEntry", HConstants.REPLICATION_QOS, qosFunction); 059 // Set method name in pb style with the method name capitalized. 060 checkMethod(conf, "OpenRegion", HConstants.ADMIN_QOS, qosFunction); 061 // Check multi works. 062 checkMethod(conf, "Multi", HConstants.NORMAL_QOS, qosFunction, 063 MultiRequest.getDefaultInstance()); 064 } 065 066 @Test 067 public void testAnnotations() { 068 checkMethod(conf, "CloseRegion", HConstants.ADMIN_QOS, qosFunction); 069 checkMethod(conf, "CompactRegion", HConstants.ADMIN_QOS, qosFunction); 070 checkMethod(conf, "FlushRegion", HConstants.ADMIN_QOS, qosFunction); 071 checkMethod(conf, "UpdateConfiguration", HConstants.ADMIN_QOS, qosFunction); 072 checkMethod(conf, "CompactionSwitch", HConstants.ADMIN_QOS, qosFunction); 073 checkMethod(conf, "RollWALWriter", HConstants.ADMIN_QOS, qosFunction); 074 } 075}