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
.Admin
;
24 import org
.apache
.hadoop
.hbase
.client
.ColumnFamilyDescriptor
;
25 import org
.apache
.hadoop
.hbase
.client
.TableDescriptor
;
26 import org
.apache
.hadoop
.hbase
.testclassification
.LargeTests
;
27 import org
.junit
.Before
;
28 import org
.junit
.ClassRule
;
29 import org
.junit
.Test
;
30 import org
.junit
.experimental
.categories
.Category
;
31 import org
.slf4j
.Logger
;
32 import org
.slf4j
.LoggerFactory
;
35 * Mob file compaction chore in a generational batch mode test.
36 * 1. Enables batch mode for regular MOB compaction,
37 * Sets batch size to 7 regions. Enables generational mode.
38 * 2. Disables periodic MOB compactions, sets minimum age to archive to 10 sec
39 * 3. Creates MOB table with 20 regions
40 * 4. Loads MOB data (randomized keys, 1000 rows), flushes data.
41 * 5. Repeats 4. two more times
42 * 6. Verifies that we have 20 *3 = 60 mob files (equals to number of regions x 3)
43 * 7. Runs major MOB compaction.
44 * 8. Verifies that number of MOB files in a mob directory is 20 x4 = 80
45 * 9. Waits for a period of time larger than minimum age to archive
46 * 10. Runs Mob cleaner chore
47 * 11 Verifies that number of MOB files in a mob directory is 20.
48 * 12 Runs scanner and checks all 3 * 1000 rows.
50 @SuppressWarnings("deprecation")
51 @Category(LargeTests
.class)
52 public class TestMobCompactionOptRegionBatchMode
extends TestMobCompactionBase
{
53 private static final Logger LOG
=
54 LoggerFactory
.getLogger(TestMobCompactionOptRegionBatchMode
.class);
56 public static final HBaseClassTestRule CLASS_RULE
=
57 HBaseClassTestRule
.forClass(TestMobCompactionOptRegionBatchMode
.class);
59 private int batchSize
= 7;
60 private MobFileCompactionChore compactionChore
;
62 public TestMobCompactionOptRegionBatchMode() {
66 public void setUp() throws Exception
{
68 compactionChore
= new MobFileCompactionChore(conf
, batchSize
);
71 protected void initConf() {
73 conf
.setInt(MobConstants
.MOB_MAJOR_COMPACTION_REGION_BATCH_SIZE
, batchSize
);
74 conf
.set(MobConstants
.MOB_COMPACTION_TYPE_KEY
,
75 MobConstants
.OPTIMIZED_MOB_COMPACTION_TYPE
);
76 conf
.setLong(MobConstants
.MOB_COMPACTION_MAX_FILE_SIZE_KEY
, 1000000);
80 protected void mobCompact(Admin admin
, TableDescriptor tableDescriptor
,
81 ColumnFamilyDescriptor familyDescriptor
) throws IOException
, InterruptedException
{
82 // Major compact with batch mode enabled
83 compactionChore
.performMajorCompactionInBatches(admin
, tableDescriptor
, familyDescriptor
);
87 public void testMobFileCompactionBatchMode() throws InterruptedException
, IOException
{
88 LOG
.info("MOB compaction chore generational batch mode started");
89 baseTestMobFileCompaction();
90 LOG
.info("MOB compaction chore generational batch mode finished OK");