HDFS-3279. Move the FSEditLog constructor with @VisibleForTesting to TestEditLog. Contributed by Arpit Gupta
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1326762 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
258da66cc7
commit
f1667dee14
@ -379,6 +379,9 @@ Release 2.0.0 - UNRELEASED
|
||||
|
||||
HDFS-2708. Stats for the # of blocks per DN. (atm)
|
||||
|
||||
HDFS-3279. Move the FSEditLog constructor with @VisibleForTesting to
|
||||
TestEditLog. (Arpit Gupta via szetszwo)
|
||||
|
||||
OPTIMIZATIONS
|
||||
|
||||
HDFS-3024. Improve performance of stringification in addStoredBlock (todd)
|
||||
|
@ -26,7 +26,6 @@
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.hadoop.classification.InterfaceAudience;
|
||||
@ -178,20 +177,6 @@ protected synchronized TransactionId initialValue() {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Construct FSEditLog with default configuration, taking editDirs from NNStorage
|
||||
*
|
||||
* @param storage Storage object used by namenode
|
||||
*/
|
||||
@VisibleForTesting
|
||||
FSEditLog(NNStorage storage) throws IOException {
|
||||
Configuration conf = new Configuration();
|
||||
// Make sure the edits dirs are set in the provided configuration object.
|
||||
conf.set(DFSConfigKeys.DFS_NAMENODE_EDITS_DIR_KEY,
|
||||
StringUtils.join(storage.getEditsDirectories(), ","));
|
||||
init(conf, storage, FSNamesystem.getNamespaceEditsDirs(conf));
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for FSEditLog. Underlying journals are constructed, but
|
||||
* no streams are opened until open() is called.
|
||||
|
@ -142,6 +142,20 @@ public void run() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct FSEditLog with default configuration, taking editDirs from NNStorage
|
||||
*
|
||||
* @param storage Storage object used by namenode
|
||||
*/
|
||||
private static FSEditLog getFSEditLog(NNStorage storage) throws IOException {
|
||||
Configuration conf = new Configuration();
|
||||
// Make sure the edits dirs are set in the provided configuration object.
|
||||
conf.set(DFSConfigKeys.DFS_NAMENODE_EDITS_DIR_KEY,
|
||||
StringUtils.join(",", storage.getEditsDirectories()));
|
||||
FSEditLog log = new FSEditLog(conf, storage, FSNamesystem.getNamespaceEditsDirs(conf));
|
||||
return log;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for an empty edit log from a prior version of Hadoop.
|
||||
*/
|
||||
@ -863,7 +877,7 @@ public void testEditLogManifestMocks() throws IOException {
|
||||
storage = mockStorageWithEdits(
|
||||
"[1,100]|[101,200]|[201,]",
|
||||
"[1,100]|[101,200]|[201,]");
|
||||
log = new FSEditLog(storage);
|
||||
log = getFSEditLog(storage);
|
||||
log.initJournalsForWrite();
|
||||
assertEquals("[[1,100], [101,200]]",
|
||||
log.getEditLogManifest(1).toString());
|
||||
@ -875,7 +889,7 @@ public void testEditLogManifestMocks() throws IOException {
|
||||
storage = mockStorageWithEdits(
|
||||
"[1,100]|[101,200]",
|
||||
"[1,100]|[201,300]|[301,400]"); // nothing starting at 101
|
||||
log = new FSEditLog(storage);
|
||||
log = getFSEditLog(storage);
|
||||
log.initJournalsForWrite();
|
||||
assertEquals("[[1,100], [101,200], [201,300], [301,400]]",
|
||||
log.getEditLogManifest(1).toString());
|
||||
@ -885,7 +899,7 @@ public void testEditLogManifestMocks() throws IOException {
|
||||
storage = mockStorageWithEdits(
|
||||
"[1,100]|[301,400]", // gap from 101 to 300
|
||||
"[301,400]|[401,500]");
|
||||
log = new FSEditLog(storage);
|
||||
log = getFSEditLog(storage);
|
||||
log.initJournalsForWrite();
|
||||
assertEquals("[[301,400], [401,500]]",
|
||||
log.getEditLogManifest(1).toString());
|
||||
@ -895,7 +909,7 @@ public void testEditLogManifestMocks() throws IOException {
|
||||
storage = mockStorageWithEdits(
|
||||
"[1,100]|[101,150]", // short log at 101
|
||||
"[1,50]|[101,200]"); // short log at 1
|
||||
log = new FSEditLog(storage);
|
||||
log = getFSEditLog(storage);
|
||||
log.initJournalsForWrite();
|
||||
assertEquals("[[1,100], [101,200]]",
|
||||
log.getEditLogManifest(1).toString());
|
||||
@ -908,7 +922,7 @@ public void testEditLogManifestMocks() throws IOException {
|
||||
storage = mockStorageWithEdits(
|
||||
"[1,100]|[101,]",
|
||||
"[1,100]|[101,200]");
|
||||
log = new FSEditLog(storage);
|
||||
log = getFSEditLog(storage);
|
||||
log.initJournalsForWrite();
|
||||
assertEquals("[[1,100], [101,200]]",
|
||||
log.getEditLogManifest(1).toString());
|
||||
@ -998,7 +1012,7 @@ public static NNStorage setupEdits(List<URI> editUris, int numrolls,
|
||||
Collections.<URI>emptyList(),
|
||||
editUris);
|
||||
storage.format(new NamespaceInfo());
|
||||
FSEditLog editlog = new FSEditLog(storage);
|
||||
FSEditLog editlog = getFSEditLog(storage);
|
||||
// open the edit log and add two transactions
|
||||
// logGenerationStamp is used, simply because it doesn't
|
||||
// require complex arguments.
|
||||
@ -1080,7 +1094,7 @@ public void testAlternatingJournalFailure() throws IOException {
|
||||
new AbortSpec(9, 0),
|
||||
new AbortSpec(10, 1));
|
||||
long totaltxnread = 0;
|
||||
FSEditLog editlog = new FSEditLog(storage);
|
||||
FSEditLog editlog = getFSEditLog(storage);
|
||||
editlog.initJournalsForWrite();
|
||||
long startTxId = 1;
|
||||
Iterable<EditLogInputStream> editStreams = editlog.selectInputStreams(startTxId,
|
||||
@ -1130,7 +1144,7 @@ public boolean accept(File dir, String name) {
|
||||
assertEquals(1, files.length);
|
||||
assertTrue(files[0].delete());
|
||||
|
||||
FSEditLog editlog = new FSEditLog(storage);
|
||||
FSEditLog editlog = getFSEditLog(storage);
|
||||
editlog.initJournalsForWrite();
|
||||
long startTxId = 1;
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user