Author: sradia
Date: Wed Jun 6 01:53:58 2012
New Revision: 1346702
URL: http://svn.apache.org/viewvc?rev=1346702&view=rev
Log:
HDFS-3424 TestDatanodeBlockScanner and TestReplication fail intermittently on
Windows (Bikas Saha via Sanjay)
Modified:
hadoop/common/branches/branch-1-win/CHANGES.txt
hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/hdfs/TestDatanodeBlockScanner.java
hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/hdfs/TestReplication.java
Modified: hadoop/common/branches/branch-1-win/CHANGES.txt
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/CHANGES.txt?rev=1346702&r1=1346701&r2=1346702&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/CHANGES.txt (original)
+++ hadoop/common/branches/branch-1-win/CHANGES.txt Wed Jun 6 01:53:58 2012
@@ -27,6 +27,8 @@ branch-hadoop-1-win - unreleased
HADOOP-8374 Improve support for hard link manipulation on Windows (Bikas
Saha via Sanjay)
+ HDFS-3424 TestDatanodeBlockScanner and TestReplication fail intermittently
on Windows (Bikas Saha via Sanjay)
+
Release 1.1.0 - unreleased
NEW FEATURES
Modified:
hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/hdfs/TestDatanodeBlockScanner.java
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/hdfs/TestDatanodeBlockScanner.java?rev=1346702&r1=1346701&r2=1346702&view=diff
==============================================================================
---
hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/hdfs/TestDatanodeBlockScanner.java
(original)
+++
hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/hdfs/TestDatanodeBlockScanner.java
Wed Jun 6 01:53:58 2012
@@ -388,26 +388,31 @@ public class TestDatanodeBlockScanner ex
final short REPLICATION_FACTOR = (short)2;
MiniDFSCluster cluster = new MiniDFSCluster(conf, REPLICATION_FACTOR,
true, null);
- cluster.waitActive();
- FileSystem fs = cluster.getFileSystem();
+ String block = null;
+ final Path fileName = new Path("/file1");
try {
- final Path fileName = new Path("/file1");
+ cluster.waitActive();
+ FileSystem fs = cluster.getFileSystem();
DFSTestUtil.createFile(fs, fileName, 1, REPLICATION_FACTOR, 0);
DFSTestUtil.waitReplication(fs, fileName, REPLICATION_FACTOR);
- String block = DFSTestUtil.getFirstBlock(fs, fileName).getBlockName();
-
- // Truncate replica of block
- changeReplicaLength(block, 0, -1);
+ block = DFSTestUtil.getFirstBlock(fs, fileName).getBlockName();
+ } finally {
cluster.shutdown();
+ }
+
+ // Truncate replica of block
+ changeReplicaLength(block, 0, -1);
- // restart the cluster
- cluster = new MiniDFSCluster(
- 0, conf, REPLICATION_FACTOR, false, true, null, null, null);
+ // restart the cluster
+ cluster = new MiniDFSCluster(
+ 0, conf, REPLICATION_FACTOR, false, true, null, null, null);
+
+ try {
cluster.startDataNodes(conf, 1, true, null, null);
cluster.waitActive(); // now we have 3 datanodes
-
+
// wait for truncated block be detected and the block to be replicated
DFSTestUtil.waitReplication(
cluster.getFileSystem(), fileName, REPLICATION_FACTOR);
@@ -425,7 +430,7 @@ public class TestDatanodeBlockScanner ex
static boolean changeReplicaLength(String blockName, int dnIndex, int
lenDelta) throws IOException {
File baseDir = new File(System.getProperty("test.build.data"), "dfs/data");
for (int i=dnIndex*2; i<dnIndex*2+2; i++) {
- File blockFile = new File(baseDir, "data" + (i+1)+ "/current/" +
+ File blockFile = new File(baseDir.getAbsolutePath(), "/data" + (i+1)+
"/current/" +
blockName);
if (blockFile.exists()) {
RandomAccessFile raFile = new RandomAccessFile(blockFile, "rw");
Modified:
hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/hdfs/TestReplication.java
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/hdfs/TestReplication.java?rev=1346702&r1=1346701&r2=1346702&view=diff
==============================================================================
---
hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/hdfs/TestReplication.java
(original)
+++
hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/hdfs/TestReplication.java
Wed Jun 6 01:53:58 2012
@@ -396,20 +396,22 @@ public class TestReplication extends Tes
* @throws Exception
*/
public void testReplicateLenMismatchedBlock() throws Exception {
- MiniDFSCluster cluster = new MiniDFSCluster(new Configuration(), 2, true,
null);
+ Configuration conf = new Configuration();
+ int numDN = 2;
+ MiniDFSCluster cluster = new MiniDFSCluster(conf, numDN, true, null);
try {
cluster.waitActive();
// test truncated block
- changeBlockLen(cluster, -1);
+ changeBlockLen(cluster, -1, conf, numDN);
// test extended block
- changeBlockLen(cluster, 1);
+ changeBlockLen(cluster, 1, conf, numDN);
} finally {
cluster.shutdown();
}
}
private void changeBlockLen(MiniDFSCluster cluster,
- int lenDelta) throws IOException, InterruptedException {
+ int lenDelta, Configuration conf, int numDN) throws IOException,
InterruptedException {
final Path fileName = new Path("/file1");
final short REPLICATION_FACTOR = (short)1;
final FileSystem fs = cluster.getFileSystem();
@@ -419,13 +421,18 @@ public class TestReplication extends Tes
String block = DFSTestUtil.getFirstBlock(fs, fileName).getBlockName();
+ cluster.shutdownDataNodes();
+
// Change the length of a replica
- for (int i=0; i<cluster.getDataNodes().size(); i++) {
+ for (int i=0; i<numDN; i++) {
if (TestDatanodeBlockScanner.changeReplicaLength(block, i, lenDelta)) {
break;
}
}
+ cluster.startDataNodes(conf, numDN, true, null, null);
+ cluster.waitActive();
+
// increase the file's replication factor
fs.setReplication(fileName, (short)(REPLICATION_FACTOR+1));