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.regionserver; 019 020import java.io.IOException; 021import org.apache.hadoop.hbase.HConstants; 022import org.apache.hadoop.hbase.regionserver.compactions.CompactionConfiguration; 023import org.apache.hadoop.hbase.regionserver.compactions.ExponentialCompactionWindowFactory; 024import org.apache.hadoop.hbase.testclassification.RegionServerTests; 025import org.apache.hadoop.hbase.testclassification.SmallTests; 026import org.junit.jupiter.api.Tag; 027import org.junit.jupiter.api.Test; 028 029@Tag(RegionServerTests.TAG) 030@Tag(SmallTests.TAG) 031public class TestDateTieredCompactionPolicyOverflow extends AbstractTestDateTieredCompactionPolicy { 032 033 @Override 034 protected void config() { 035 super.config(); 036 037 // Set up policy 038 conf.set(StoreEngine.STORE_ENGINE_CLASS_KEY, 039 "org.apache.hadoop.hbase.regionserver.DateTieredStoreEngine"); 040 conf.setLong(CompactionConfiguration.DATE_TIERED_MAX_AGE_MILLIS_KEY, 100); 041 conf.setLong(CompactionConfiguration.DATE_TIERED_INCOMING_WINDOW_MIN_KEY, 3); 042 conf.setLong(ExponentialCompactionWindowFactory.BASE_WINDOW_MILLIS_KEY, Long.MAX_VALUE / 2); 043 conf.setInt(ExponentialCompactionWindowFactory.WINDOWS_PER_TIER_KEY, 2); 044 conf.setBoolean(CompactionConfiguration.DATE_TIERED_SINGLE_OUTPUT_FOR_MINOR_COMPACTION_KEY, 045 false); 046 047 // Special settings for compaction policy per window 048 this.conf.setInt(CompactionConfiguration.HBASE_HSTORE_COMPACTION_MIN_KEY, 2); 049 this.conf.setInt(CompactionConfiguration.HBASE_HSTORE_COMPACTION_MAX_KEY, 12); 050 this.conf.setFloat(CompactionConfiguration.HBASE_HSTORE_COMPACTION_RATIO_KEY, 1.2F); 051 052 conf.setInt(HStore.BLOCKING_STOREFILES_KEY, 20); 053 conf.setLong(HConstants.MAJOR_COMPACTION_PERIOD, 10); 054 } 055 056 /** 057 * Major compaction with maximum values 058 * @throws IOException with error 059 */ 060 @Test 061 public void maxValuesForMajor() throws IOException { 062 long[] minTimestamps = new long[] { Long.MIN_VALUE, -100 }; 063 long[] maxTimestamps = new long[] { -8, Long.MAX_VALUE }; 064 long[] sizes = new long[] { 0, 1 }; 065 066 compactEquals(Long.MAX_VALUE, sfCreate(minTimestamps, maxTimestamps, sizes), 067 new long[] { 0, 1 }, new long[] { Long.MIN_VALUE, -4611686018427387903L, 0, 068 4611686018427387903L, 9223372036854775806L }, 069 true, true); 070 } 071}