-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HBASE-23680 RegionProcedureStore missing cleaning of hfile archive
- Loading branch information
Showing
3 changed files
with
133 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
...a/org/apache/hadoop/hbase/procedure2/store/region/TestRegionProcedureStoreCompaction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.hadoop.hbase.procedure2.store.region; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.io.IOException; | ||
import org.apache.hadoop.conf.Configuration; | ||
import org.apache.hadoop.fs.FileSystem; | ||
import org.apache.hadoop.fs.Path; | ||
import org.apache.hadoop.hbase.HBaseClassTestRule; | ||
import org.apache.hadoop.hbase.HBaseCommonTestingUtility; | ||
import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility.LoadCounter; | ||
import org.apache.hadoop.hbase.regionserver.MemStoreLAB; | ||
import org.apache.hadoop.hbase.testclassification.MasterTests; | ||
import org.apache.hadoop.hbase.testclassification.MediumTests; | ||
import org.apache.hadoop.hbase.util.CommonFSUtils; | ||
import org.apache.hadoop.hbase.util.HFileArchiveUtil; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.ClassRule; | ||
import org.junit.Test; | ||
import org.junit.experimental.categories.Category; | ||
|
||
import org.apache.hbase.thirdparty.com.google.common.collect.Iterables; | ||
|
||
@Category({ MasterTests.class, MediumTests.class }) | ||
public class TestRegionProcedureStoreCompaction { | ||
|
||
@ClassRule | ||
public static final HBaseClassTestRule CLASS_RULE = | ||
HBaseClassTestRule.forClass(TestRegionProcedureStoreCompaction.class); | ||
|
||
private HBaseCommonTestingUtility htu; | ||
|
||
private FileSystem fs; | ||
|
||
private RegionProcedureStore store; | ||
|
||
private int compactMin = 4; | ||
|
||
@Before | ||
public void setUp() throws IOException { | ||
htu = new HBaseCommonTestingUtility(); | ||
Configuration conf = htu.getConfiguration(); | ||
conf.setBoolean(MemStoreLAB.USEMSLAB_KEY, false); | ||
Path testDir = htu.getDataTestDir(); | ||
fs = testDir.getFileSystem(conf); | ||
CommonFSUtils.setWALRootDir(conf, testDir); | ||
conf.setInt(RegionFlusherAndCompactor.COMPACT_MIN_KEY, compactMin); | ||
store = RegionProcedureStoreTestHelper.createStore(conf, new LoadCounter()); | ||
} | ||
|
||
@After | ||
public void tearDown() throws IOException { | ||
store.stop(true); | ||
htu.cleanupTestDir(); | ||
} | ||
|
||
private int getStorefilesCount() { | ||
return Iterables.getOnlyElement(store.region.getStores()).getStorefilesCount(); | ||
} | ||
|
||
@Test | ||
public void test() throws IOException { | ||
for (int i = 0; i < compactMin - 1; i++) { | ||
store.insert(new RegionProcedureStoreTestProcedure(), null); | ||
store.region.flush(true); | ||
} | ||
assertEquals(compactMin - 1, getStorefilesCount()); | ||
store.insert(new RegionProcedureStoreTestProcedure(), null); | ||
store.flusherAndCompactor.requestFlush(); | ||
htu.waitFor(15000, () -> getStorefilesCount() == 1); | ||
Path tableArchivePath = HFileArchiveUtil.getTableArchivePath( | ||
new Path(htu.getDataTestDir(), RegionProcedureStore.MASTER_PROCEDURE_DIR), | ||
RegionProcedureStore.TABLE_NAME); | ||
// we should have created this directory, when archiving compacted files | ||
htu.waitFor(15000, () -> fs.exists(tableArchivePath)); | ||
// and then we deleted the store file directory, for deleting the archived compacted files | ||
htu.waitFor(15000, () -> !fs.listFiles(tableArchivePath, true).hasNext()); | ||
} | ||
} |