|
@@ -24,12 +24,15 @@ import static org.junit.Assert.*;
|
|
|
import org.apache.hadoop.hdfs.MiniDFSCluster;
|
|
|
import org.apache.hadoop.conf.Configuration;
|
|
|
import org.apache.hadoop.hdfs.DFSConfigKeys;
|
|
|
+import org.apache.hadoop.hdfs.server.protocol.NamespaceInfo;
|
|
|
|
|
|
import java.net.URI;
|
|
|
import java.util.Collection;
|
|
|
import java.io.IOException;
|
|
|
|
|
|
public class TestGenericJournalConf {
|
|
|
+ private static final String DUMMY_URI = "dummy://test";
|
|
|
+
|
|
|
/**
|
|
|
* Test that an exception is thrown if a journal class doesn't exist
|
|
|
* in the configuration
|
|
@@ -114,12 +117,17 @@ public class TestGenericJournalConf {
|
|
|
|
|
|
conf.set(DFSConfigKeys.DFS_NAMENODE_EDITS_PLUGIN_PREFIX + ".dummy",
|
|
|
DummyJournalManager.class.getName());
|
|
|
- conf.set(DFSConfigKeys.DFS_NAMENODE_EDITS_DIR_KEY,
|
|
|
- "dummy://test");
|
|
|
+ conf.set(DFSConfigKeys.DFS_NAMENODE_EDITS_DIR_KEY, DUMMY_URI);
|
|
|
conf.setInt(DFSConfigKeys.DFS_NAMENODE_CHECKED_VOLUMES_MINIMUM_KEY, 0);
|
|
|
try {
|
|
|
cluster = new MiniDFSCluster.Builder(conf).numDataNodes(0).build();
|
|
|
cluster.waitActive();
|
|
|
+
|
|
|
+ assertNotNull(DummyJournalManager.conf);
|
|
|
+ assertEquals(new URI(DUMMY_URI), DummyJournalManager.uri);
|
|
|
+ assertNotNull(DummyJournalManager.nsInfo);
|
|
|
+ assertEquals(DummyJournalManager.nsInfo.getClusterID(),
|
|
|
+ cluster.getNameNode().getNamesystem().getClusterId());
|
|
|
} finally {
|
|
|
if (cluster != null) {
|
|
|
cluster.shutdown();
|
|
@@ -128,7 +136,17 @@ public class TestGenericJournalConf {
|
|
|
}
|
|
|
|
|
|
public static class DummyJournalManager implements JournalManager {
|
|
|
- public DummyJournalManager(Configuration conf, URI u) {}
|
|
|
+ static Configuration conf = null;
|
|
|
+ static URI uri = null;
|
|
|
+ static NamespaceInfo nsInfo = null;
|
|
|
+
|
|
|
+ public DummyJournalManager(Configuration conf, URI u,
|
|
|
+ NamespaceInfo nsInfo) {
|
|
|
+ // Set static vars so the test case can verify them.
|
|
|
+ DummyJournalManager.conf = conf;
|
|
|
+ DummyJournalManager.uri = u;
|
|
|
+ DummyJournalManager.nsInfo = nsInfo;
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public EditLogOutputStream startLogSegment(long txId) throws IOException {
|
|
@@ -162,7 +180,7 @@ public class TestGenericJournalConf {
|
|
|
|
|
|
public static class BadConstructorJournalManager extends DummyJournalManager {
|
|
|
public BadConstructorJournalManager() {
|
|
|
- super(null, null);
|
|
|
+ super(null, null, null);
|
|
|
}
|
|
|
}
|
|
|
}
|