Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,15 @@ private void moveHFileToGlobalArchiveDir() throws IOException {
Path globalStoreArchiveDir = HFileArchiveUtil.getStoreArchivePathForArchivePath(
globalArchivePath, region.getRegionInfo(), store.getColumnFamilyDescriptor().getName());
try {
MasterRegionUtils.moveFilesUnderDir(fs, storeArchiveDir, globalStoreArchiveDir,
archivedHFileSuffix);
if (fs.exists(storeArchiveDir)) {
MasterRegionUtils.moveFilesUnderDir(fs, storeArchiveDir, globalStoreArchiveDir,
archivedHFileSuffix);
} else {
LOG.warn(
"Archived dir {} does not exist, there is no need to move archived hfiles from {} "
+ "to global dir {} .",
storeArchiveDir, storeArchiveDir, globalStoreArchiveDir);
}
} catch (IOException e) {
LOG.warn("Failed to move archived hfiles from {} to global dir {}", storeArchiveDir,
globalStoreArchiveDir, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4648,6 +4648,39 @@ public void testWritesWhileScanning() throws IOException, InterruptedException {
}
}

@Test
public void testCloseAndArchiveCompactedFiles() throws IOException {
byte[] CF1 = Bytes.toBytes("CF1");
byte[] CF2 = Bytes.toBytes("CF2");
this.region = initHRegion(tableName, method, CONF, CF1, CF2);
for (int i = 0; i < 2; i++) {
int index = i;
Put put =
new Put(Bytes.toBytes(index)).addColumn(CF1, Bytes.toBytes("q"), Bytes.toBytes(index));
region.put(put);
region.flush(true);
}

region.compact(true);

HStore store1 = region.getStore(CF1);
HStore store2 = region.getStore(CF2);
store1.closeAndArchiveCompactedFiles();
store2.closeAndArchiveCompactedFiles();

int storefilesCount = region.getStores().stream().mapToInt(Store::getStorefilesCount).sum();
assertTrue(storefilesCount == 1);

FileSystem fs = region.getRegionFileSystem().getFileSystem();
Configuration conf = region.getReadOnlyConfiguration();
RegionInfo regionInfo = region.getRegionInfo();
Path store1ArchiveDir = HFileArchiveUtil.getStoreArchivePath(conf, regionInfo, CF1);
assertTrue(fs.exists(store1ArchiveDir));
// The archived dir of CF2 does not exist because this column family has no data at all
Path store2ArchiveDir = HFileArchiveUtil.getStoreArchivePath(conf, regionInfo, CF2);
assertFalse(fs.exists(store2ArchiveDir));
}

protected class PutThread extends Thread {
private volatile boolean done;
private volatile int numPutsFinished = 0;
Expand Down