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.junit.Assert.assertEquals;
22
23 import java.util.concurrent.ThreadPoolExecutor;
24
25 import org.apache.commons.logging.Log;
26 import org.apache.commons.logging.LogFactory;
27 import org.apache.hadoop.hbase.HBaseTestingUtility;
28 import org.apache.hadoop.hbase.HColumnDescriptor;
29 import org.apache.hadoop.hbase.HConstants;
30 import org.apache.hadoop.hbase.HTableDescriptor;
31 import org.apache.hadoop.hbase.TableName;
32 import org.apache.hadoop.hbase.client.ConnectionFactory;
33 import org.apache.hadoop.hbase.executor.ExecutorType;
34 import org.apache.hadoop.hbase.testclassification.MediumTests;
35 import org.apache.hadoop.hbase.client.Admin;
36 import org.apache.hadoop.hbase.client.Connection;
37 import org.junit.AfterClass;
38 import org.junit.BeforeClass;
39 import org.junit.Test;
40 import org.junit.experimental.categories.Category;
41
42 @Category({MediumTests.class})
43 public class TestRegionOpen {
44 @SuppressWarnings("unused")
45 private static final Log LOG = LogFactory.getLog(TestRegionOpen.class);
46 private static final int NB_SERVERS = 1;
47
48 private static final HBaseTestingUtility HTU = new HBaseTestingUtility();
49 final TableName tableName = TableName.valueOf(TestRegionOpen.class.getSimpleName());
50
51 @BeforeClass
52 public static void before() throws Exception {
53
54
55 HTU.getConfiguration().setBoolean("hbase.master.start.wait.for.namespacemanager", true);
56 HTU.startMiniCluster(NB_SERVERS);
57 HTU.waitUntilAllSystemRegionsAssigned();
58 }
59
60 @AfterClass
61 public static void afterClass() throws Exception {
62 HTU.shutdownMiniCluster();
63 }
64
65 private static HRegionServer getRS() {
66 return HTU.getHBaseCluster().getLiveRegionServerThreads().get(0).getRegionServer();
67 }
68
69 @Test(timeout = 60000)
70 public void testPriorityRegionIsOpenedWithSeparateThreadPool() throws Exception {
71 ThreadPoolExecutor exec = getRS().getExecutorService()
72 .getExecutorThreadPool(ExecutorType.RS_OPEN_PRIORITY_REGION);
73
74 long taskCount = exec.getCompletedTaskCount();
75
76 HTableDescriptor htd = new HTableDescriptor(tableName);
77 htd.setPriority(HConstants.HIGH_QOS);
78 htd.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY));
79 try (Connection connection = ConnectionFactory.createConnection(HTU.getConfiguration());
80 Admin admin = connection.getAdmin()) {
81 admin.createTable(htd);
82 }
83
84 assertEquals(taskCount+1, exec.getCompletedTaskCount());
85 }
86 }