Revert HDFS-7808.

This commit is contained in:
Haohui Mai 2015-04-08 15:59:55 -07:00
parent 8104d52269
commit 35816c438d
4 changed files with 43 additions and 3 deletions

View File

@ -928,9 +928,6 @@ Release 2.7.0 - UNRELEASED
HDFS-6662. WebHDFS cannot open a file if its path contains "%". HDFS-6662. WebHDFS cannot open a file if its path contains "%".
(Gerson Carlos via wheat9) (Gerson Carlos via wheat9)
HDFS-7808. Remove obsolete -ns options in in DFSHAAdmin.java.
(Arshad Mohammad via wheat9)
HDFS-7788. Post-2.6 namenode may not start up with an image containing HDFS-7788. Post-2.6 namenode may not start up with an image containing
inodes created with an old release. (Rushabh Shah via kihwal) inodes created with an old release. (Rushabh Shah via kihwal)

View File

@ -18,6 +18,7 @@
package org.apache.hadoop.hdfs.tools; package org.apache.hadoop.hdfs.tools;
import java.io.PrintStream; import java.io.PrintStream;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@ -97,6 +98,25 @@ protected int runCmd(String[] argv) throws Exception {
printUsage(errOut); printUsage(errOut);
return -1; return -1;
} }
int i = 0;
String cmd = argv[i++];
if ("-ns".equals(cmd)) {
if (i == argv.length) {
errOut.println("Missing nameservice ID");
printUsage(errOut);
return -1;
}
nameserviceId = argv[i++];
if (i >= argv.length) {
errOut.println("Missing command");
printUsage(errOut);
return -1;
}
argv = Arrays.copyOfRange(argv, i, argv.length);
}
return super.runCmd(argv); return super.runCmd(argv);
} }

View File

@ -146,6 +146,17 @@ private void assertOutputContains(String string) {
} }
} }
@Test
public void testNameserviceOption() throws Exception {
assertEquals(-1, runTool("-ns"));
assertOutputContains("Missing nameservice ID");
assertEquals(-1, runTool("-ns", "ns1"));
assertOutputContains("Missing command");
// "ns1" isn't defined but we check this lazily and help doesn't use the ns
assertEquals(0, runTool("-ns", "ns1", "-help", "transitionToActive"));
assertOutputContains("Transitions the service into Active");
}
@Test @Test
public void testNamenodeResolution() throws Exception { public void testNamenodeResolution() throws Exception {
Mockito.doReturn(STANDBY_READY_RESULT).when(mockProtocol).getServiceStatus(); Mockito.doReturn(STANDBY_READY_RESULT).when(mockProtocol).getServiceStatus();
@ -267,6 +278,15 @@ public void testFailoverWithFencerConfigured() throws Exception {
assertEquals(0, runTool("-failover", "nn1", "nn2")); assertEquals(0, runTool("-failover", "nn1", "nn2"));
} }
@Test
public void testFailoverWithFencerAndNameservice() throws Exception {
Mockito.doReturn(STANDBY_READY_RESULT).when(mockProtocol).getServiceStatus();
HdfsConfiguration conf = getHAConf();
conf.set(DFSConfigKeys.DFS_HA_FENCE_METHODS_KEY, getFencerTrueCommand());
tool.setConf(conf);
assertEquals(0, runTool("-ns", "ns1", "-failover", "nn1", "nn2"));
}
@Test @Test
public void testFailoverWithFencerConfiguredAndForce() throws Exception { public void testFailoverWithFencerConfiguredAndForce() throws Exception {
Mockito.doReturn(STANDBY_READY_RESULT).when(mockProtocol).getServiceStatus(); Mockito.doReturn(STANDBY_READY_RESULT).when(mockProtocol).getServiceStatus();

View File

@ -157,6 +157,9 @@ public void testFencer() throws Exception {
assertEquals(0, runTool("-failover", "nn1", "nn2")); assertEquals(0, runTool("-failover", "nn1", "nn2"));
assertEquals(0, runTool("-failover", "nn2", "nn1")); assertEquals(0, runTool("-failover", "nn2", "nn1"));
// Test failover with fencer and nameservice
assertEquals(0, runTool("-ns", "minidfs-ns", "-failover", "nn2", "nn1"));
// Fencer has not run yet, since none of the above required fencing // Fencer has not run yet, since none of the above required fencing
assertEquals("", Files.toString(tmpFile, Charsets.UTF_8)); assertEquals("", Files.toString(tmpFile, Charsets.UTF_8));