001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.apache.hadoop.hbase.mob; 019 020import java.io.IOException; 021import org.apache.hadoop.hbase.HBaseParameterizedTestTemplate; 022import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor; 023import org.apache.hadoop.hbase.client.TableDescriptor; 024import org.apache.hadoop.hbase.testclassification.LargeTests; 025import org.junit.jupiter.api.BeforeEach; 026import org.junit.jupiter.api.Tag; 027import org.junit.jupiter.api.TestInfo; 028import org.slf4j.Logger; 029import org.slf4j.LoggerFactory; 030 031/** 032 * Mob file compaction chore in a regular batch mode test. 1. Enables batch mode for regular MOB 033 * compaction, Sets batch size to 7 regions. 2. Disables periodic MOB compactions, sets minimum age 034 * to archive to 10 sec 3. Creates MOB table with 20 regions 4. Loads MOB data (randomized keys, 035 * 1000 rows), flushes data. 5. Repeats 4. two more times 6. Verifies that we have 20 *3 = 60 mob 036 * files (equals to number of regions x 3) 7. Runs major MOB compaction. 8. Verifies that number of 037 * MOB files in a mob directory is 20 x4 = 80 9. Waits for a period of time larger than minimum age 038 * to archive 10. Runs Mob cleaner chore 11 Verifies that number of MOB files in a mob directory is 039 * 20. 12 Runs scanner and checks all 3 * 1000 rows. 040 */ 041@Tag(LargeTests.TAG) 042@HBaseParameterizedTestTemplate(name = "{index}: useFileBasedSFT={0}") 043public class TestMobCompactionRegularRegionBatchMode extends TestMobCompactionWithDefaults { 044 private static final Logger LOG = 045 LoggerFactory.getLogger(TestMobCompactionRegularRegionBatchMode.class); 046 047 private static final int batchSize = 7; 048 private MobFileCompactionChore compactionChore; 049 050 public TestMobCompactionRegularRegionBatchMode(Boolean useFileBasedSFT) { 051 super(useFileBasedSFT); 052 } 053 054 @BeforeEach 055 public void setUp(TestInfo testInfo) throws Exception { 056 super.setUp(testInfo); 057 compactionChore = new MobFileCompactionChore(conf, batchSize); 058 } 059 060 protected void additonalConfigSetup() { 061 conf.setInt(MobConstants.MOB_MAJOR_COMPACTION_REGION_BATCH_SIZE, batchSize); 062 } 063 064 @Override 065 protected void mobCompactImpl(TableDescriptor tableDescriptor, 066 ColumnFamilyDescriptor familyDescriptor) throws IOException, InterruptedException { 067 LOG.debug("compacting {} in batch mode.", tableDescriptor.getTableName()); 068 compactionChore.performMajorCompactionInBatches(admin, tableDescriptor, familyDescriptor); 069 } 070 071 @Override 072 protected String description() { 073 return "regular batch mode"; 074 } 075 076}