View Javadoc

1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.hadoop.hbase.client;
19  
20  import static org.junit.Assert.assertEquals;
21  import static org.junit.Assert.assertFalse;
22  import static org.junit.Assert.fail;
23  
24  import java.io.IOException;
25  
26  import org.apache.commons.logging.Log;
27  import org.apache.commons.logging.LogFactory;
28  import org.apache.hadoop.conf.Configuration;
29  import org.apache.hadoop.hbase.HBaseTestingUtility;
30  import org.apache.hadoop.hbase.HColumnDescriptor;
31  import org.apache.hadoop.hbase.TableName;
32  import org.apache.hadoop.hbase.mob.MobConstants;
33  import org.apache.hadoop.hbase.snapshot.MobSnapshotTestingUtils;
34  import org.apache.hadoop.hbase.testclassification.LargeTests;
35  import org.junit.BeforeClass;
36  import org.junit.experimental.categories.Category;
37  
38  /**
39   * Test restore snapshots from the client
40   */
41  @Category({LargeTests.class})
42  public class TestMobRestoreSnapshotFromClient extends TestRestoreSnapshotFromClient {
43    private static final Log LOG = LogFactory.getLog(TestMobRestoreSnapshotFromClient.class);
44  
45    @BeforeClass
46    public static void setupCluster() throws Exception {
47      setupConf(TEST_UTIL.getConfiguration());
48      TEST_UTIL.startMiniCluster(3);
49    }
50  
51    protected static void setupConf(Configuration conf) {
52      TestRestoreSnapshotFromClient.setupConf(conf);
53      TEST_UTIL.getConfiguration().setInt(MobConstants.MOB_FILE_CACHE_SIZE_KEY, 0);
54    }
55  
56    @Override
57    protected void createTable() throws Exception {
58      MobSnapshotTestingUtils.createMobTable(TEST_UTIL, tableName, getNumReplicas(), FAMILY);
59    }
60  
61    @Override
62    protected HColumnDescriptor getTestRestoreSchemaChangeHCD() {
63      HColumnDescriptor hcd = new HColumnDescriptor(TEST_FAMILY2);
64      hcd.setMobEnabled(true);
65      hcd.setMobThreshold(3L);
66      return hcd;
67    }
68  
69    @Override
70    protected void verifyRowCount(final HBaseTestingUtility util, final TableName tableName,
71        long expectedRows) throws IOException {
72      MobSnapshotTestingUtils.verifyMobRowCount(util, tableName, expectedRows);
73    }
74  
75    @Override
76    protected int countRows(final Table table, final byte[]... families) throws IOException {
77      return MobSnapshotTestingUtils.countMobRows(table, families);
78    }
79  }