Skip to content

Commit

Permalink
HBASE-26579 Set storage policy of recovered edits when hbase.wal.stor…
Browse files Browse the repository at this point in the history
…age.type is configured (#3948)

Signed-off-by: Duo Zhang <[email protected]>
Signed-off-by: Peter Somogyi <[email protected]>
  • Loading branch information
zhengzhuobinzzb authored Dec 18, 2021
1 parent da616c0 commit ea0fe22
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ public static void moveWAL(FileSystem fs, Path p, Path targetDir) throws IOExcep
* named for the sequenceid in the passed <code>logEntry</code>: e.g.
* /hbase/some_table/2323432434/recovered.edits/2332. This method also ensures existence of
* RECOVERED_EDITS_DIR under the region creating it if necessary.
* And also set storage policy for RECOVERED_EDITS_DIR if WAL_STORAGE_POLICY is configured.
* @param tableName the table name
* @param encodedRegionName the encoded region name
* @param seqId the sequence id which used to generate file name
Expand Down Expand Up @@ -184,6 +185,10 @@ static Path getRegionSplitEditsPath(TableName tableName, byte[] encodedRegionNam

if (!walFS.exists(dir) && !walFS.mkdirs(dir)) {
LOG.warn("mkdir failed on {}", dir);
} else {
String storagePolicy =
conf.get(HConstants.WAL_STORAGE_POLICY, HConstants.DEFAULT_WAL_STORAGE_POLICY);
CommonFSUtils.setStoragePolicy(walFS, dir, storagePolicy);
}
// Append fileBeingSplit to prevent name conflict since we may have duplicate wal entries now.
// Append file name ends with RECOVERED_LOG_TMPFILE_SUFFIX to ensure
Expand Down Expand Up @@ -583,4 +588,4 @@ public static FileStatus[] getRecoveredHFiles(final FileSystem rootFS,
Path dir = getRecoveredHFilesDir(regionDir, familyName);
return CommonFSUtils.listStatus(rootFS, dir);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,18 @@ protected Writer createWriter(Path logfile)
}
}

@Test
public void testRecoveredEditsStoragePolicy() throws IOException {
conf.set(HConstants.WAL_STORAGE_POLICY, "ALL_SSD");
try {
Path path = createRecoveredEditsPathForRegion();
assertEquals("ALL_SSD", fs.getStoragePolicy(path.getParent()).getName());
} finally {
conf.unset(HConstants.WAL_STORAGE_POLICY);
}

}

private Writer generateWALs(int leaveOpen) throws IOException {
return generateWALs(NUM_WRITERS, ENTRIES, leaveOpen, 0);
}
Expand Down

0 comments on commit ea0fe22

Please sign in to comment.