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;
21
22 import static org.junit.Assert.assertEquals;
23
24 import org.apache.hadoop.conf.Configuration;
25 import org.apache.hadoop.hbase.client.HTable;
26 import org.apache.hadoop.hbase.testclassification.LargeTests;
27 import org.apache.hadoop.hbase.util.Bytes;
28 import org.junit.After;
29 import org.junit.AfterClass;
30 import org.junit.Before;
31 import org.junit.BeforeClass;
32 import org.junit.Test;
33 import org.junit.experimental.categories.Category;
34
35 @Category(LargeTests.class)
36 public class TestFullLogReconstruction {
37
38 private final static HBaseTestingUtility
39 TEST_UTIL = new HBaseTestingUtility();
40
41 private final static byte[] TABLE_NAME = Bytes.toBytes("tabletest");
42 private final static byte[] FAMILY = Bytes.toBytes("family");
43
44
45
46
47 @BeforeClass
48 public static void setUpBeforeClass() throws Exception {
49 Configuration c = TEST_UTIL.getConfiguration();
50 c.setBoolean("dfs.support.append", true);
51
52 c.setInt("heartbeat.recheck.interval", 5000);
53 c.setInt("dfs.heartbeat.interval", 1);
54 c.setInt("dfs.socket.timeout", 5000);
55
56 c.setInt("hbase.ipc.client.connect.max.retries", 1);
57 c.setInt("dfs.client.block.recovery.retries", 1);
58 c.setInt(HConstants.ZK_SESSION_TIMEOUT, 1000);
59 TEST_UTIL.startMiniCluster(3);
60 }
61
62
63
64
65 @AfterClass
66 public static void tearDownAfterClass() throws Exception {
67 TEST_UTIL.shutdownMiniCluster();
68 }
69
70
71
72
73 @Before
74 public void setUp() throws Exception {
75 }
76
77
78
79
80 @After
81 public void tearDown() throws Exception {
82 }
83
84
85
86
87
88
89
90
91 @Test (timeout=300000)
92 public void testReconstruction() throws Exception {
93
94 HTable table = TEST_UTIL.createTable(TABLE_NAME, FAMILY);
95
96 TEST_UTIL.createMultiRegions(table, Bytes.toBytes("family"));
97
98
99 int initialCount = TEST_UTIL.loadTable(table, FAMILY);
100 int count = TEST_UTIL.countRows(table);
101
102 assertEquals(initialCount, count);
103
104 for(int i = 0; i < 4; i++) {
105 TEST_UTIL.loadTable(table, FAMILY);
106 }
107
108 TEST_UTIL.expireRegionServerSession(0);
109 int newCount = TEST_UTIL.countRows(table);
110 assertEquals(count, newCount);
111 table.close();
112 }
113 }