1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.hadoop.hbase.client;
21
22 import org.apache.hadoop.hbase.HBaseTestingUtility;
23 import org.apache.hadoop.hbase.HRegionLocation;
24 import org.apache.hadoop.hbase.util.Bytes;
25 import org.junit.BeforeClass;
26 import org.junit.Test;
27
28 import static org.junit.Assert.assertNull;
29 import static org.junit.Assert.assertNotNull;
30
31
32
33
34 public class TestHCM {
35
36 private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
37 private static final byte[] TABLE_NAME = Bytes.toBytes("test");
38 private static final byte[] FAM_NAM = Bytes.toBytes("f");
39 private static final byte[] ROW = Bytes.toBytes("bbb");
40
41 @BeforeClass
42 public static void setUpBeforeClass() throws Exception {
43 TEST_UTIL.startMiniCluster(1);
44 }
45
46
47
48
49
50
51 @Test
52 public void testRegionCaching() throws Exception{
53 HTable table = TEST_UTIL.createTable(TABLE_NAME, FAM_NAM);
54 TEST_UTIL.createMultiRegions(table, FAM_NAM);
55 Put put = new Put(ROW);
56 put.add(FAM_NAM, ROW, ROW);
57 table.put(put);
58 HConnectionManager.TableServers conn =
59 (HConnectionManager.TableServers) table.getConnection();
60 assertNotNull(conn.getCachedLocation(TABLE_NAME, ROW));
61 conn.deleteCachedLocation(TABLE_NAME, ROW);
62 HRegionLocation rl = conn.getCachedLocation(TABLE_NAME, ROW);
63 assertNull("What is this location?? " + rl, rl);
64 }
65 }
66