HBASE-8986 Replace hardcoded special file/dir names with the relative HConstant

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1504652 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
mbertozzi 2013-07-18 20:47:38 +00:00
parent ac924da7af
commit 3ea120a69b
10 changed files with 33 additions and 28 deletions

View File

@ -503,7 +503,7 @@ public class HBaseFsck extends Configured implements Tool {
for (FileStatus cf : dirs) {
String cfName= cf.getPath().getName();
// TODO Figure out what the special dirs are
if (cfName.startsWith(".") || cfName.equals("splitlog")) continue;
if (cfName.startsWith(".") || cfName.equals(HConstants.SPLIT_LOGDIR_NAME)) continue;
FileStatus[] hfiles = fs.listStatus(cf.getPath());
for (FileStatus hfile : hfiles) {

View File

@ -394,7 +394,8 @@ public class TestHFileArchiving {
}
private void clearArchiveDirectory() throws IOException {
UTIL.getTestFileSystem().delete(new Path(UTIL.getDefaultRootDirPath(), ".archive"), true);
UTIL.getTestFileSystem().delete(
new Path(UTIL.getDefaultRootDirPath(), HConstants.HFILE_ARCHIVE_DIRECTORY), true);
}
/**

View File

@ -102,7 +102,8 @@ public class TestSnapshotCloneIndependence {
UTIL.deleteTable(TABLE_NAME);
// and cleanup the archive directory
try {
UTIL.getTestFileSystem().delete(new Path(UTIL.getDefaultRootDirPath(), ".archive"), true);
UTIL.getTestFileSystem().delete(
new Path(UTIL.getDefaultRootDirPath(), HConstants.HFILE_ARCHIVE_DIRECTORY), true);
} catch (IOException e) {
LOG.warn("Failure to delete archive directory", e);
}

View File

@ -103,7 +103,8 @@ public class TestSnapshotFromClient {
UTIL.deleteTable(TABLE_NAME);
// and cleanup the archive directory
try {
UTIL.getTestFileSystem().delete(new Path(UTIL.getDefaultRootDirPath(), ".archive"), true);
UTIL.getTestFileSystem().delete(
new Path(UTIL.getDefaultRootDirPath(), HConstants.HFILE_ARCHIVE_DIRECTORY), true);
} catch (IOException e) {
LOG.warn("Failure to delete archive directory", e);
}
@ -144,7 +145,7 @@ public class TestSnapshotFromClient {
/**
* Test HBaseAdmin#deleteSnapshots(String) which deletes snapshots whose names match the parameter
*
*
* @throws Exception
*/
@Test
@ -157,15 +158,15 @@ public class TestSnapshotFromClient {
HTable table = new HTable(UTIL.getConfiguration(), TABLE_NAME);
UTIL.loadTable(table, TEST_FAM);
table.close();
byte[] snapshot1 = Bytes.toBytes("TableSnapshot1");
admin.snapshot(snapshot1, TABLE_NAME);
LOG.debug("Snapshot1 completed.");
byte[] snapshot2 = Bytes.toBytes("TableSnapshot2");
admin.snapshot(snapshot2, TABLE_NAME);
LOG.debug("Snapshot2 completed.");
String snapshot3 = "3rdTableSnapshot";
admin.snapshot(Bytes.toBytes(snapshot3), TABLE_NAME);
LOG.debug(snapshot3 + " completed.");
@ -175,7 +176,7 @@ public class TestSnapshotFromClient {
List<SnapshotDescription> snapshots = admin.listSnapshots();
assertEquals(1, snapshots.size());
assertEquals(snapshots.get(0).getName(), snapshot3);
admin.deleteSnapshot(snapshot3);
admin.close();
}

View File

@ -75,7 +75,7 @@ public class TestSnapshotLogCleaner {
fs.create(new Path(hostSnapshotLogDir, snapshotlogfile));
// now check to see if that log file would get deleted.
Path oldlogDir = new Path(rootDir, ".oldlogs");
Path oldlogDir = new Path(rootDir, HConstants.HREGION_OLDLOGDIR_NAME);
Path logFile = new Path(oldlogDir, snapshotlogfile);
fs.create(logFile);

View File

@ -78,7 +78,7 @@ public class TestHLog {
private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
private static Path hbaseDir;
private static Path oldLogDir;
@Before
public void setUp() throws Exception {
@ -120,7 +120,7 @@ public class TestHLog {
fs = cluster.getFileSystem();
hbaseDir = TEST_UTIL.createRootDir();
oldLogDir = new Path(hbaseDir, ".oldlogs");
oldLogDir = new Path(hbaseDir, HConstants.HREGION_OLDLOGDIR_NAME);
dir = new Path(hbaseDir, getName());
}
@AfterClass
@ -159,7 +159,7 @@ public class TestHLog {
final byte [] tableName = Bytes.toBytes(getName());
final byte [] rowName = tableName;
Path logdir = new Path(hbaseDir, HConstants.HREGION_LOGDIR_NAME);
HLog log = HLogFactory.createHLog(fs, hbaseDir,
HLog log = HLogFactory.createHLog(fs, hbaseDir,
HConstants.HREGION_LOGDIR_NAME, conf);
final int howmany = 3;
HRegionInfo[] infos = new HRegionInfo[3];
@ -237,7 +237,7 @@ public class TestHLog {
in.close();
HLog wal = HLogFactory.createHLog(fs, dir, "hlogdir", conf);
final int total = 20;
HLog.Reader reader = null;
@ -367,10 +367,10 @@ public class TestHLog {
}
}
}
/*
* We pass different values to recoverFileLease() so that different code paths are covered
*
*
* For this test to pass, requires:
* 1. HDFS-200 (append support)
* 2. HDFS-988 (SafeMode should freeze file operations
@ -506,7 +506,7 @@ public class TestHLog {
HLog log = null;
try {
log = HLogFactory.createHLog(fs, hbaseDir, getName(), conf);
// Write columns named 1, 2, 3, etc. and then values of single byte
// 1, 2, 3...
long timestamp = System.currentTimeMillis();
@ -652,7 +652,7 @@ public class TestHLog {
final byte [] tableName = Bytes.toBytes("testLogCleaning");
final byte [] tableName2 = Bytes.toBytes("testLogCleaning2");
HLog log = HLogFactory.createHLog(fs, hbaseDir,
HLog log = HLogFactory.createHLog(fs, hbaseDir,
getName(), conf);
try {
HRegionInfo hri = new HRegionInfo(tableName,
@ -736,7 +736,7 @@ public class TestHLog {
@Test
public void testWALCoprocessorLoaded() throws Exception {
// test to see whether the coprocessor is loaded or not.
HLog log = HLogFactory.createHLog(fs, hbaseDir,
HLog log = HLogFactory.createHLog(fs, hbaseDir,
getName(), conf);
try {
WALCoprocessorHost host = log.getCoprocessorHost();
@ -760,7 +760,7 @@ public class TestHLog {
log.append(hri, tableName, cols, timestamp, htd);
}
}
/**
* @throws IOException
@ -953,7 +953,7 @@ public class TestHLog {
@Override
public void logRollRequested() {
// TODO Auto-generated method stub
}
@Override

View File

@ -109,7 +109,7 @@ public class TestHLogSplit {
private static final Path HBASEDIR = new Path("/hbase");
private static final Path HLOGDIR = new Path(HBASEDIR, "hlog");
private static final Path OLDLOGDIR = new Path(HBASEDIR, "hlog.old");
private static final Path CORRUPTDIR = new Path(HBASEDIR, ".corrupt");
private static final Path CORRUPTDIR = new Path(HBASEDIR, HConstants.CORRUPT_DIR_NAME);
private static final int NUM_WRITERS = 10;
private static final int ENTRIES = 10; // entries per writer per region
@ -140,7 +140,7 @@ public class TestHLogSplit {
TEST_UTIL.getConfiguration().setClass("hbase.regionserver.hlog.writer.impl",
InstrumentedSequenceFileLogWriter.class, HLog.Writer.class);
TEST_UTIL.getConfiguration().setBoolean("dfs.support.broken.append", true);
TEST_UTIL.getConfiguration().setBoolean("dfs.support.append", true);
TEST_UTIL.getConfiguration().setBoolean("dfs.support.append", true);
// This is how you turn off shortcircuit read currently. TODO: Fix. Should read config.
System.setProperty("hbase.tests.use.shortcircuit.reads", "false");
// Create fake maping user to group and set it to the conf.
@ -888,7 +888,7 @@ public class TestHLogSplit {
fs.initialize(fs.getUri(), conf);
final AtomicInteger count = new AtomicInteger();
CancelableProgressable localReporter
= new CancelableProgressable() {
@Override
@ -1232,7 +1232,7 @@ public class TestHLogSplit {
HLogSplitter.split(HBASEDIR, HLOGDIR, OLDLOGDIR, fs, conf);
final Path corruptDir = new Path(FSUtils.getRootDir(conf), conf.get(
"hbase.regionserver.hlog.splitlog.corrupt.dir", ".corrupt"));
"hbase.regionserver.hlog.splitlog.corrupt.dir", HConstants.CORRUPT_DIR_NAME));
assertEquals(1, fs.listStatus(corruptDir).length);
}

View File

@ -248,7 +248,8 @@ public class TestExportSnapshot {
for (FileStatus fileStatus: rootFiles) {
String name = fileStatus.getPath().getName();
assertTrue(fileStatus.isDir());
assertTrue(name.equals(HConstants.SNAPSHOT_DIR_NAME) || name.equals(".archive"));
assertTrue(name.equals(HConstants.SNAPSHOT_DIR_NAME) ||
name.equals(HConstants.HFILE_ARCHIVE_DIRECTORY));
}
// compare the snapshot metadata and verify the hfiles

View File

@ -123,7 +123,8 @@ public class TestFlushSnapshotFromClient {
UTIL.deleteTable(TABLE_NAME);
// and cleanup the archive directory
try {
UTIL.getTestFileSystem().delete(new Path(UTIL.getDefaultRootDirPath(), ".archive"), true);
UTIL.getTestFileSystem().delete(
new Path(UTIL.getDefaultRootDirPath(), HConstants.HFILE_ARCHIVE_DIRECTORY), true);
} catch (IOException e) {
LOG.warn("Failure to delete archive directory", e);
}

View File

@ -55,7 +55,7 @@ public class TestWALReferenceTask {
// setup the log dir
Path testDir = UTIL.getDataTestDir();
Set<String> servers = new HashSet<String>();
Path logDir = new Path(testDir, ".logs");
Path logDir = new Path(testDir, HConstants.HREGION_LOGDIR_NAME);
Path server1Dir = new Path(logDir, "Server1");
servers.add(server1Dir.getName());
Path server2Dir = new Path(logDir, "me.hbase.com,56073,1348618509968");