|
@@ -24,6 +24,7 @@ import static org.junit.Assume.assumeTrue;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
+import java.util.concurrent.TimeoutException;
|
|
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
@@ -37,6 +38,7 @@ import org.apache.hadoop.hdfs.DFSTestUtil;
|
|
|
import org.apache.hadoop.hdfs.HdfsConfiguration;
|
|
|
import org.apache.hadoop.hdfs.MiniDFSCluster;
|
|
|
import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeManager;
|
|
|
+import org.apache.hadoop.hdfs.server.namenode.FSNamesystem;
|
|
|
import org.apache.log4j.Level;
|
|
|
import org.junit.After;
|
|
|
import org.junit.Before;
|
|
@@ -189,7 +191,7 @@ public class TestDataNodeVolumeFailureToleration {
|
|
|
*/
|
|
|
private void restartDatanodes(int volTolerated, boolean manageDfsDirs)
|
|
|
throws IOException {
|
|
|
- //Make sure no datanode is running
|
|
|
+ // Make sure no datanode is running
|
|
|
cluster.shutdownDataNodes();
|
|
|
conf.setInt(DFSConfigKeys.DFS_DATANODE_FAILED_VOLUMES_TOLERATED_KEY, volTolerated);
|
|
|
cluster.startDataNodes(conf, 1, manageDfsDirs, null, null);
|
|
@@ -226,7 +228,7 @@ public class TestDataNodeVolumeFailureToleration {
|
|
|
*/
|
|
|
private void testVolumeConfig(int volumesTolerated, int volumesFailed,
|
|
|
boolean expectedBPServiceState, boolean manageDfsDirs)
|
|
|
- throws IOException, InterruptedException {
|
|
|
+ throws IOException, InterruptedException, TimeoutException {
|
|
|
assumeTrue(!System.getProperty("os.name").startsWith("Windows"));
|
|
|
final int dnIndex = 0;
|
|
|
// Fail the current directory since invalid storage directory perms
|
|
@@ -261,4 +263,30 @@ public class TestDataNodeVolumeFailureToleration {
|
|
|
assertEquals("Couldn't chmod local vol", 0,
|
|
|
FileUtil.chmod(dir.toString(), "000"));
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Test that a volume that is considered failed on startup is seen as
|
|
|
+ * a failed volume by the NN.
|
|
|
+ */
|
|
|
+ @Test
|
|
|
+ public void testFailedVolumeOnStartupIsCounted() throws Exception {
|
|
|
+ assumeTrue(!System.getProperty("os.name").startsWith("Windows"));
|
|
|
+ final DatanodeManager dm = cluster.getNamesystem().getBlockManager(
|
|
|
+ ).getDatanodeManager();
|
|
|
+ long origCapacity = DFSTestUtil.getLiveDatanodeCapacity(dm);
|
|
|
+ File dir = new File(MiniDFSCluster.getStorageDir(0, 0), "current");
|
|
|
+
|
|
|
+ try {
|
|
|
+ prepareDirToFail(dir);
|
|
|
+ restartDatanodes(1, false);
|
|
|
+ // The cluster is up..
|
|
|
+ assertEquals(true, cluster.getDataNodes().get(0)
|
|
|
+ .isBPServiceAlive(cluster.getNamesystem().getBlockPoolId()));
|
|
|
+ // but there has been a single volume failure
|
|
|
+ DFSTestUtil.waitForDatanodeStatus(dm, 1, 0, 1,
|
|
|
+ origCapacity / 2, WAIT_FOR_HEARTBEATS);
|
|
|
+ } finally {
|
|
|
+ FileUtil.chmod(dir.toString(), "755");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|