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 java.io.IOException;
21  import java.util.UUID;
22  import org.apache.hadoop.conf.Configuration;
23  import org.apache.hadoop.fs.Path;
24  import org.apache.hadoop.hbase.HConstants;
25  import org.apache.hadoop.hbase.master.snapshot.SnapshotManager;
26  import org.apache.hadoop.hbase.regionserver.ConstantSizeRegionSplitPolicy;
27  import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils;
28  import org.apache.hadoop.hbase.testclassification.LargeTests;
29  import org.junit.BeforeClass;
30  import org.junit.experimental.categories.Category;
31  
32  /**
33   * This class tests that the use of a temporary snapshot directory supports snapshot functionality
34   * while the temporary directory is on the same file system as the root directory
35   * <p>
36   * This is an end-to-end test for the snapshot utility
37   */
38  @Category(LargeTests.class)
39  public class TestSnapshotDFSTemporaryDirectory
40      extends TestSnapshotTemporaryDirectory {
41  
42    /**
43     * Setup the config for the cluster
44     *
45     * @throws Exception on failure
46     */
47    @BeforeClass public static void setupCluster() throws Exception {
48      setupConf(UTIL.getConfiguration());
49      UTIL.startMiniCluster(NUM_RS);
50      admin = UTIL.getHBaseAdmin();
51    }
52  
53    private static void setupConf(Configuration conf) throws IOException {
54      // disable the ui
55      conf.setInt("hbase.regionsever.info.port", -1);
56      // change the flush size to a small amount, regulating number of store files
57      conf.setInt("hbase.hregion.memstore.flush.size", 25000);
58      // so make sure we get a compaction when doing a load, but keep around some
59      // files in the store
60      conf.setInt("hbase.hstore.compaction.min", 10);
61      conf.setInt("hbase.hstore.compactionThreshold", 10);
62      // block writes if we get to 12 store files
63      conf.setInt("hbase.hstore.blockingStoreFiles", 12);
64      // Enable snapshot
65      conf.setBoolean(SnapshotManager.HBASE_SNAPSHOT_ENABLED, true);
66      conf.set(HConstants.HBASE_REGION_SPLIT_POLICY_KEY,
67          ConstantSizeRegionSplitPolicy.class.getName());
68  
69      String snapshotPath = UTIL.getDefaultRootDirPath().toString() + Path.SEPARATOR +
70          UUID.randomUUID().toString() + Path.SEPARATOR + ".tmpdir" + Path.SEPARATOR;
71      conf.set(SnapshotDescriptionUtils.SNAPSHOT_WORKING_DIR, "file://" + new Path(snapshotPath).toUri());
72    }
73  }