001/**
002 *
003 * Licensed to the Apache Software Foundation (ASF) under one
004 * or more contributor license agreements.  See the NOTICE file
005 * distributed with this work for additional information
006 * regarding copyright ownership.  The ASF licenses this file
007 * to you under the Apache License, Version 2.0 (the
008 * "License"); you may not use this file except in compliance
009 * with the License.  You may obtain a copy of the License at
010 *
011 *     http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing, software
014 * distributed under the License is distributed on an "AS IS" BASIS,
015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016 * See the License for the specific language governing permissions and
017 * limitations under the License.
018 */
019package org.apache.hadoop.hbase.mob;
020import java.io.IOException;
021import org.apache.hadoop.hbase.HBaseClassTestRule;
022import org.apache.hadoop.hbase.testclassification.LargeTests;
023import org.junit.BeforeClass;
024import org.junit.ClassRule;
025import org.junit.experimental.categories.Category;
026
027/**
028  * Mob file compaction chore in a generational non-batch mode test.
029  * 1. Uses default (non-batch) mode for regular MOB compaction, sets generational mode ON
030  * 2. Disables periodic MOB compactions, sets minimum age to archive to 10 sec
031  * 3. Creates MOB table with 20 regions
032  * 4. Loads MOB data (randomized keys, 1000 rows), flushes data.
033  * 5. Repeats 4. two more times
034  * 6. Verifies that we have 20 *3 = 60 mob files (equals to number of regions x 3)
035  * 7. Runs major MOB compaction.
036  * 8. Verifies that number of MOB files in a mob directory is 20 x4 = 80
037  * 9. Waits for a period of time larger than minimum age to archive
038  * 10. Runs Mob cleaner chore
039  * 11 Verifies that number of MOB files in a mob directory is 20.
040  * 12 Runs scanner and checks all 3 * 1000 rows.
041 */
042@Category(LargeTests.class)
043public class TestMobCompactionOptMode extends TestMobCompactionWithDefaults {
044
045  @ClassRule
046  public static final HBaseClassTestRule CLASS_RULE =
047      HBaseClassTestRule.forClass(TestMobCompactionOptMode.class);
048
049  @BeforeClass
050  public static void configureOptimizedCompaction() throws InterruptedException, IOException {
051    HTU.shutdownMiniHBaseCluster();
052    conf.set(MobConstants.MOB_COMPACTION_TYPE_KEY,
053      MobConstants.OPTIMIZED_MOB_COMPACTION_TYPE);
054    conf.setLong(MobConstants.MOB_COMPACTION_MAX_FILE_SIZE_KEY, 1000000);
055    HTU.startMiniHBaseCluster();
056  }
057
058  @Override
059  protected String description() {
060    return "generational (non-batch) mode";
061  }
062
063}