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.regionserver;
19  
20  import java.io.IOException;
21  
22  import org.apache.hadoop.hbase.HConstants;
23  import org.apache.hadoop.hbase.regionserver.compactions.CompactionConfiguration;
24  import org.apache.hadoop.hbase.regionserver.compactions.ExponentialCompactionWindowFactory;
25  import org.apache.hadoop.hbase.testclassification.RegionServerTests;
26  import org.apache.hadoop.hbase.testclassification.SmallTests;
27  import org.junit.Test;
28  import org.junit.experimental.categories.Category;
29  
30  @Category({ RegionServerTests.class, SmallTests.class })
31  public class TestDateTieredCompactionPolicyOverflow extends AbstractTestDateTieredCompactionPolicy {
32  
33    @Override
34    protected void config() {
35      super.config();
36  
37      // Set up policy
38      conf.set(StoreEngine.STORE_ENGINE_CLASS_KEY,
39        "org.apache.hadoop.hbase.regionserver.DateTieredStoreEngine");
40      conf.setLong(CompactionConfiguration.DATE_TIERED_MAX_AGE_MILLIS_KEY, 100);
41      conf.setLong(CompactionConfiguration.DATE_TIERED_INCOMING_WINDOW_MIN_KEY, 3);
42      conf.setLong(ExponentialCompactionWindowFactory.BASE_WINDOW_MILLIS_KEY, Long.MAX_VALUE / 2);
43      conf.setInt(ExponentialCompactionWindowFactory.WINDOWS_PER_TIER_KEY, 2);
44      conf.setBoolean(CompactionConfiguration.DATE_TIERED_SINGLE_OUTPUT_FOR_MINOR_COMPACTION_KEY,
45        false);
46  
47      // Special settings for compaction policy per window
48      this.conf.setInt(CompactionConfiguration.MIN_KEY, 2);
49      this.conf.setInt(CompactionConfiguration.MAX_KEY, 12);
50      this.conf.setFloat(CompactionConfiguration.RATIO_KEY, 1.2F);
51  
52      conf.setInt(HStore.BLOCKING_STOREFILES_KEY, 20);
53      conf.setLong(HConstants.MAJOR_COMPACTION_PERIOD, 10);
54    }
55  
56    /**
57     * Major compaction with maximum values
58     * @throws IOException with error
59     */
60    @Test
61    public void maxValuesForMajor() throws IOException {
62      long[] minTimestamps = new long[] { Long.MIN_VALUE, -100 };
63      long[] maxTimestamps = new long[] { -8, Long.MAX_VALUE };
64      long[] sizes = new long[] { 0, 1 };
65  
66      compactEquals(Long.MAX_VALUE, sfCreate(minTimestamps, maxTimestamps, sizes),
67        new long[] { 0, 1 }, new long[] { Long.MIN_VALUE, -4611686018427387903L, 0,
68            4611686018427387903L, 9223372036854775806L }, true, true);
69    }
70  }