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.hadoop.conf.Configuration;
27  import org.apache.hadoop.hbase.HBaseTestingUtility;
28  import org.apache.hadoop.hbase.HColumnDescriptor;
29  import org.apache.hadoop.hbase.TableName;
30  import org.apache.hadoop.hbase.mob.MobConstants;
31  import org.apache.hadoop.hbase.snapshot.MobSnapshotTestingUtils;
32  import org.apache.hadoop.hbase.testclassification.LargeTests;
33  import org.junit.BeforeClass;
34  import org.junit.experimental.categories.Category;
35  
36  /**
37   * Test restore snapshots from the client
38   */
39  @Category({LargeTests.class})
40  public class TestMobRestoreSnapshotFromClient extends TestRestoreSnapshotFromClient {
41  
42    @BeforeClass
43    public static void setupCluster() throws Exception {
44      setupConf(TEST_UTIL.getConfiguration());
45      TEST_UTIL.startMiniCluster(3);
46    }
47  
48    protected static void setupConf(Configuration conf) {
49      TestRestoreSnapshotFromClient.setupConf(conf);
50      TEST_UTIL.getConfiguration().setInt(MobConstants.MOB_FILE_CACHE_SIZE_KEY, 0);
51    }
52  
53    @Override
54    protected void createTable() throws Exception {
55      MobSnapshotTestingUtils.createMobTable(TEST_UTIL, tableName, getNumReplicas(), FAMILY);
56    }
57  
58    @Override
59    protected HColumnDescriptor getTestRestoreSchemaChangeHCD() {
60      HColumnDescriptor hcd = new HColumnDescriptor(TEST_FAMILY2);
61      hcd.setMobEnabled(true);
62      hcd.setMobThreshold(3L);
63      return hcd;
64    }
65  
66    @Override
67    protected void verifyRowCount(final HBaseTestingUtility util, final TableName tableName,
68        long expectedRows) throws IOException {
69      MobSnapshotTestingUtils.verifyMobRowCount(util, tableName, expectedRows);
70    }
71  
72    @Override
73    protected int countRows(final Table table, final byte[]... families) throws IOException {
74      return MobSnapshotTestingUtils.countMobRows(table, families);
75    }
76  }