use of org.apache.hadoop.hbase.regionserver.StoreFileInfo in project hbase by apache.
the class TestMajorCompactionRequest method mockStoreFiles.
protected List<StoreFileInfo> mockStoreFiles(Path regionStoreDir, int howMany, long timestamp) throws IOException {
List<StoreFileInfo> infos = Lists.newArrayList();
int i = 0;
while (i < howMany) {
StoreFileInfo storeFileInfo = mock(StoreFileInfo.class);
doReturn(timestamp).doReturn(timestamp).when(storeFileInfo).getModificationTime();
doReturn(new Path(regionStoreDir, RandomStringUtils.randomAlphabetic(10))).when(storeFileInfo).getPath();
infos.add(storeFileInfo);
i++;
}
return infos;
}
use of org.apache.hadoop.hbase.regionserver.StoreFileInfo in project hbase by apache.
the class TestMajorCompactionRequest method testIfWeHaveNewReferenceFilesButOldStoreFiles.
@Test
public void testIfWeHaveNewReferenceFilesButOldStoreFiles() throws Exception {
// this tests that reference files that are new, but have older timestamps for the files
// they reference still will get compacted.
TableName table = TableName.valueOf("TestMajorCompactor");
TableDescriptor htd = UTILITY.createTableDescriptor(table, Bytes.toBytes(FAMILY));
RegionInfo hri = RegionInfoBuilder.newBuilder(htd.getTableName()).build();
HRegion region = HBaseTestingUtil.createRegionAndWAL(hri, rootRegionDir, UTILITY.getConfiguration(), htd);
Connection connection = mock(Connection.class);
// the reference file timestamp is newer
List<StoreFileInfo> storeFiles = mockStoreFiles(regionStoreDir, 4, 101);
List<Path> paths = storeFiles.stream().map(StoreFileInfo::getPath).collect(Collectors.toList());
// the files that are referenced are older, thus we still compact.
HRegionFileSystem fileSystem = mockFileSystem(region.getRegionInfo(), true, storeFiles, 50);
MajorCompactionRequest majorCompactionRequest = spy(new MajorCompactionRequest(connection, region.getRegionInfo(), Sets.newHashSet(FAMILY)));
doReturn(paths).when(majorCompactionRequest).getReferenceFilePaths(any(FileSystem.class), any(Path.class));
doReturn(fileSystem).when(majorCompactionRequest).getFileSystem();
Set<String> result = majorCompactionRequest.getStoresRequiringCompaction(Sets.newHashSet("a"), 100);
assertEquals(FAMILY, Iterables.getOnlyElement(result));
}
Aggregations