HBASE-23723 Ensure MOB compaction works in optimized mode after snapshot clone (...
[hbase.git] / hbase-server / src / test / java / org / apache / hadoop / hbase / mob / TestMobCompactionOptRegionBatchMode.java
blob117b9eed28f4a634ffec10cfa2728977b5c0a217
1 /**
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 package org.apache.hadoop.hbase.mob;
20 import java.io.IOException;
22 import org.apache.hadoop.hbase.HBaseClassTestRule;
23 import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor;
24 import org.apache.hadoop.hbase.client.TableDescriptor;
25 import org.apache.hadoop.hbase.testclassification.LargeTests;
26 import org.junit.Before;
27 import org.junit.BeforeClass;
28 import org.junit.ClassRule;
29 import org.junit.experimental.categories.Category;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
33 /**
34 * Mob file compaction chore in a generational batch mode test.
35 * 1. Enables batch mode for regular MOB compaction,
36 * Sets batch size to 7 regions. Enables generational mode.
37 * 2. Disables periodic MOB compactions, sets minimum age to archive to 10 sec
38 * 3. Creates MOB table with 20 regions
39 * 4. Loads MOB data (randomized keys, 1000 rows), flushes data.
40 * 5. Repeats 4. two more times
41 * 6. Verifies that we have 20 *3 = 60 mob files (equals to number of regions x 3)
42 * 7. Runs major MOB compaction.
43 * 8. Verifies that number of MOB files in a mob directory is 20 x4 = 80
44 * 9. Waits for a period of time larger than minimum age to archive
45 * 10. Runs Mob cleaner chore
46 * 11 Verifies that number of MOB files in a mob directory is 20.
47 * 12 Runs scanner and checks all 3 * 1000 rows.
49 @SuppressWarnings("deprecation")
50 @Category(LargeTests.class)
51 public class TestMobCompactionOptRegionBatchMode extends TestMobCompactionWithDefaults {
52 private static final Logger LOG =
53 LoggerFactory.getLogger(TestMobCompactionOptRegionBatchMode.class);
54 @ClassRule
55 public static final HBaseClassTestRule CLASS_RULE =
56 HBaseClassTestRule.forClass(TestMobCompactionOptRegionBatchMode.class);
58 private static final int batchSize = 7;
59 private MobFileCompactionChore compactionChore;
61 @Before
62 public void setUp() throws Exception {
63 super.setUp();
64 compactionChore = new MobFileCompactionChore(conf, batchSize);
67 @BeforeClass
68 public static void configureOptimizedCompactionAndBatches()
69 throws InterruptedException, IOException {
70 HTU.shutdownMiniHBaseCluster();
71 conf.setInt(MobConstants.MOB_MAJOR_COMPACTION_REGION_BATCH_SIZE, batchSize);
72 conf.set(MobConstants.MOB_COMPACTION_TYPE_KEY,
73 MobConstants.OPTIMIZED_MOB_COMPACTION_TYPE);
74 conf.setLong(MobConstants.MOB_COMPACTION_MAX_FILE_SIZE_KEY, 1000000);
75 HTU.startMiniHBaseCluster();
78 @Override
79 protected void mobCompactImpl(TableDescriptor tableDescriptor,
80 ColumnFamilyDescriptor familyDescriptor) throws IOException, InterruptedException {
81 LOG.debug("compacting {} in batch mode.", tableDescriptor.getTableName());
82 compactionChore.performMajorCompactionInBatches(admin, tableDescriptor, familyDescriptor);
85 @Override
86 protected String description() {
87 return "generational batch mode";