1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.hadoop.hbase.client;
19
20 import java.io.IOException;
21
22 import org.apache.commons.logging.Log;
23 import org.apache.commons.logging.LogFactory;
24 import org.apache.hadoop.hbase.HBaseTestingUtility;
25 import org.apache.hadoop.hbase.TableName;
26 import org.apache.hadoop.hbase.mob.MobConstants;
27 import org.apache.hadoop.hbase.snapshot.MobSnapshotTestingUtils;
28 import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils;
29 import org.apache.hadoop.hbase.testclassification.LargeTests;
30 import org.junit.BeforeClass;
31 import org.junit.experimental.categories.Category;
32
33
34
35
36 @Category({LargeTests.class})
37 public class TestMobCloneSnapshotFromClient extends TestCloneSnapshotFromClient {
38 private static final Log LOG = LogFactory.getLog(TestMobCloneSnapshotFromClient.class);
39
40 protected static void setupConfiguration() {
41 TestCloneSnapshotFromClient.setupConfiguration();
42 TEST_UTIL.getConfiguration().setInt(MobConstants.MOB_FILE_CACHE_SIZE_KEY, 0);
43 }
44
45 @BeforeClass
46 public static void setUpBeforeClass() throws Exception {
47 setupConfiguration();
48 TEST_UTIL.startMiniCluster(3);
49 }
50
51 @Override
52 protected void createTableAndSnapshots() throws Exception {
53
54 MobSnapshotTestingUtils.createMobTable(TEST_UTIL, tableName, getNumReplicas(), FAMILY);
55 admin.disableTable(tableName);
56
57
58 admin.snapshot(emptySnapshot, tableName);
59
60 Connection c = ConnectionFactory.createConnection(TEST_UTIL.getConfiguration());
61 Table table = c.getTable(tableName);
62 try {
63
64 admin.enableTable(tableName);
65 SnapshotTestingUtils.loadData(TEST_UTIL, tableName, 500, FAMILY);
66 snapshot0Rows = MobSnapshotTestingUtils.countMobRows(table);
67 admin.disableTable(tableName);
68
69
70 admin.snapshot(snapshotName0, tableName);
71
72
73 admin.enableTable(tableName);
74 SnapshotTestingUtils.loadData(TEST_UTIL, tableName, 500, FAMILY);
75 snapshot1Rows = MobSnapshotTestingUtils.countMobRows(table);
76 admin.disableTable(tableName);
77
78
79 admin.snapshot(snapshotName1, tableName);
80
81
82 admin.enableTable(tableName);
83 } finally {
84 table.close();
85 }
86 }
87
88 @Override
89 protected void verifyRowCount(final HBaseTestingUtility util, final TableName tableName,
90 long expectedRows) throws IOException {
91 MobSnapshotTestingUtils.verifyMobRowCount(util, tableName, expectedRows);
92 }
93 }