HBASE-20469 Directory used for sidelining old recovered edits files should be made configurable

Signed-off-by: Andrew Purtell <apurtell@apache.org>
This commit is contained in:
Nihal Jain 2018-04-21 16:40:21 +05:30 committed by Andrew Purtell
parent ee3507d456
commit 145c92f3d6
2 changed files with 11 additions and 6 deletions

View File

@ -459,6 +459,7 @@ public class WALSplitter {
* creating it if necessary.
* @param logEntry
* @param fileNameBeingSplit the file being split currently. Used to generate tmp file name.
* @param tmpDirName of the directory used to sideline old recovered edits file
* @param conf
* @return Path to file into which to dump split log edits.
* @throws IOException
@ -466,8 +467,7 @@ public class WALSplitter {
@SuppressWarnings("deprecation")
@VisibleForTesting
static Path getRegionSplitEditsPath(final Entry logEntry, String fileNameBeingSplit,
Configuration conf)
throws IOException {
String tmpDirName, Configuration conf) throws IOException {
FileSystem fs = FileSystem.get(conf);
Path rootDir = FSUtils.getRootDir(conf);
Path tableDir = FSUtils.getTableDir(rootDir, logEntry.getKey().getTableName());
@ -482,7 +482,7 @@ public class WALSplitter {
return null;
}
if (fs.exists(dir) && fs.isFile(dir)) {
Path tmp = new Path("/tmp");
Path tmp = new Path(tmpDirName);
if (!fs.exists(tmp)) {
fs.mkdirs(tmp);
}
@ -1513,8 +1513,10 @@ public class WALSplitter {
* @return a path with a write for that path. caller should close.
*/
WriterAndPath createWAP(byte[] region, Entry entry) throws IOException {
String tmpDirName = conf.get(HConstants.TEMPORARY_FS_DIRECTORY_KEY,
HConstants.DEFAULT_TEMPORARY_HDFS_DIRECTORY);
Path regionedits = getRegionSplitEditsPath(entry,
fileBeingSplit.getPath().getName(), conf);
fileBeingSplit.getPath().getName(), tmpDirName, conf);
if (regionedits == null) {
return null;
}

View File

@ -130,6 +130,7 @@ public class TestWALSplit {
private Path OLDLOGDIR;
private Path CORRUPTDIR;
private Path TABLEDIR;
private String TMPDIRNAME;
private static final int NUM_WRITERS = 10;
private static final int ENTRIES = 10; // entries per writer per region
@ -191,6 +192,8 @@ public class TestWALSplit {
OLDLOGDIR = new Path(HBASELOGDIR, HConstants.HREGION_OLDLOGDIR_NAME);
CORRUPTDIR = new Path(HBASELOGDIR, HConstants.CORRUPT_DIR_NAME);
TABLEDIR = FSUtils.getTableDir(HBASEDIR, TABLE_NAME);
TMPDIRNAME = conf.get(HConstants.TEMPORARY_FS_DIRECTORY_KEY,
HConstants.DEFAULT_TEMPORARY_HDFS_DIRECTORY);
REGIONS.clear();
Collections.addAll(REGIONS, "bbb", "ccc");
InstrumentedLogWriter.activateFailure = false;
@ -391,7 +394,7 @@ public class TestWALSplit {
TableName.META_TABLE_NAME, 1, now, HConstants.DEFAULT_CLUSTER_ID),
new WALEdit());
Path p = WALSplitter.getRegionSplitEditsPath(entry,
FILENAME_BEING_SPLIT, conf);
FILENAME_BEING_SPLIT, TMPDIRNAME, conf);
String parentOfParent = p.getParent().getParent().getName();
assertEquals(parentOfParent, RegionInfoBuilder.FIRST_META_REGIONINFO.getEncodedName());
}
@ -417,7 +420,7 @@ public class TestWALSplit {
fs.createNewFile(parent); // create a recovered.edits file
Path p = WALSplitter.getRegionSplitEditsPath(entry,
FILENAME_BEING_SPLIT, conf);
FILENAME_BEING_SPLIT, TMPDIRNAME, conf);
String parentOfParent = p.getParent().getParent().getName();
assertEquals(parentOfParent, RegionInfoBuilder.FIRST_META_REGIONINFO.getEncodedName());
WALFactory.createRecoveredEditsWriter(fs, p, conf).close();