You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-commits@hadoop.apache.org by co...@apache.org on 2009/11/06 19:13:34 UTC
svn commit: r833507 - in /hadoop/hdfs/branches/branch-0.21: ./
.eclipse.templates/.launches/ src/contrib/block_forensics/
src/contrib/hdfsproxy/ src/java/ src/java/org/apache/hadoop/hdfs/protocol/
src/java/org/apache/hadoop/hdfs/server/datanode/ src/te...
Author: cos
Date: Fri Nov 6 18:13:33 2009
New Revision: 833507
URL: http://svn.apache.org/viewvc?rev=833507&view=rev
Log:
HDFS-733. svn merge -c 833499 from trunk to branch 0.21
Modified:
hadoop/hdfs/branches/branch-0.21/ (props changed)
hadoop/hdfs/branches/branch-0.21/.eclipse.templates/.launches/ (props changed)
hadoop/hdfs/branches/branch-0.21/CHANGES.txt
hadoop/hdfs/branches/branch-0.21/build.xml (props changed)
hadoop/hdfs/branches/branch-0.21/src/contrib/block_forensics/ (props changed)
hadoop/hdfs/branches/branch-0.21/src/contrib/hdfsproxy/ (props changed)
hadoop/hdfs/branches/branch-0.21/src/java/ (props changed)
hadoop/hdfs/branches/branch-0.21/src/java/org/apache/hadoop/hdfs/protocol/RecoveryInProgressException.java (props changed)
hadoop/hdfs/branches/branch-0.21/src/java/org/apache/hadoop/hdfs/server/datanode/ReplicaInfo.java (props changed)
hadoop/hdfs/branches/branch-0.21/src/test/aop/org/apache/hadoop/hdfs/protocol/ (props changed)
hadoop/hdfs/branches/branch-0.21/src/test/hdfs/ (props changed)
hadoop/hdfs/branches/branch-0.21/src/test/hdfs/org/apache/hadoop/hdfs/server/datanode/TestBlockReport.java
hadoop/hdfs/branches/branch-0.21/src/webapps/datanode/ (props changed)
hadoop/hdfs/branches/branch-0.21/src/webapps/hdfs/ (props changed)
hadoop/hdfs/branches/branch-0.21/src/webapps/secondary/ (props changed)
Propchange: hadoop/hdfs/branches/branch-0.21/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Nov 6 18:13:33 2009
@@ -1,3 +1,3 @@
/hadoop/core/branches/branch-0.19/hdfs:713112
/hadoop/hdfs/branches/HDFS-265:796829-820463
-/hadoop/hdfs/trunk:818294-818298,824552,824944,826149,828116,828926,829880,829894,830003,831436,832043
+/hadoop/hdfs/trunk:818294-818298,824552,824944,826149,828116,828926,829880,829894,830003,831436,832043,833499
Propchange: hadoop/hdfs/branches/branch-0.21/.eclipse.templates/.launches/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Nov 6 18:13:33 2009
@@ -1 +1 @@
-/hadoop/hdfs/trunk/.eclipse.templates/.launches:824552,824944,826149,828116,828926,829880,829894,830003,831436,832043
+/hadoop/hdfs/trunk/.eclipse.templates/.launches:824552,824944,826149,828116,828926,829880,829894,830003,831436,832043,833499
Modified: hadoop/hdfs/branches/branch-0.21/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hdfs/branches/branch-0.21/CHANGES.txt?rev=833507&r1=833506&r2=833507&view=diff
==============================================================================
--- hadoop/hdfs/branches/branch-0.21/CHANGES.txt (original)
+++ hadoop/hdfs/branches/branch-0.21/CHANGES.txt Fri Nov 6 18:13:33 2009
@@ -443,6 +443,8 @@
HDFS-691. Fix an overflow error in DFSClient.DFSInputStream.available().
(szetszwo)
+ HDFS-733. TestBlockReport fails intermittently. (cos)
+
Release 0.20.2 - Unreleased
IMPROVEMENTS
Propchange: hadoop/hdfs/branches/branch-0.21/build.xml
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Nov 6 18:13:33 2009
@@ -1,4 +1,4 @@
/hadoop/core/branches/branch-0.19/hdfs/build.xml:713112
/hadoop/core/trunk/build.xml:779102
/hadoop/hdfs/branches/HDFS-265/build.xml:796829-820463
-/hadoop/hdfs/trunk/build.xml:818294-818298,824552,824944,825229,826149,828116,828926,829258,829880,829894,830003,831436,832043
+/hadoop/hdfs/trunk/build.xml:818294-818298,824552,824944,825229,826149,828116,828926,829258,829880,829894,830003,831436,832043,833499
Propchange: hadoop/hdfs/branches/branch-0.21/src/contrib/block_forensics/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Nov 6 18:13:33 2009
@@ -1 +1 @@
-/hadoop/hdfs/trunk/src/contrib/block_forensics:824552,824944,826149,828116,828926,829880,829894,830003,831436,832043
+/hadoop/hdfs/trunk/src/contrib/block_forensics:824552,824944,826149,828116,828926,829880,829894,830003,831436,832043,833499
Propchange: hadoop/hdfs/branches/branch-0.21/src/contrib/hdfsproxy/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Nov 6 18:13:33 2009
@@ -1,4 +1,4 @@
/hadoop/core/branches/branch-0.19/hdfs/src/contrib/hdfsproxy:713112
/hadoop/core/trunk/src/contrib/hdfsproxy:776175-784663
/hadoop/hdfs/branches/HDFS-265/src/contrib/hdfsproxy:796829-820463
-/hadoop/hdfs/trunk/src/contrib/hdfsproxy:818294-818298,824552,824944,826149,828116,828926,829880,829894,830003,831436,832043
+/hadoop/hdfs/trunk/src/contrib/hdfsproxy:818294-818298,824552,824944,826149,828116,828926,829880,829894,830003,831436,832043,833499
Propchange: hadoop/hdfs/branches/branch-0.21/src/java/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Nov 6 18:13:33 2009
@@ -1,4 +1,4 @@
/hadoop/core/branches/branch-0.19/hdfs/src/java:713112
/hadoop/core/trunk/src/hdfs:776175-785643,785929-786278
/hadoop/hdfs/branches/HDFS-265/src/java:796829-820463
-/hadoop/hdfs/trunk/src/java:818294-818298,824552,824944,826149,828116,828926,829880,829894,830003,831436,832043
+/hadoop/hdfs/trunk/src/java:818294-818298,824552,824944,826149,828116,828926,829880,829894,830003,831436,832043,833499
Propchange: hadoop/hdfs/branches/branch-0.21/src/java/org/apache/hadoop/hdfs/protocol/RecoveryInProgressException.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Nov 6 18:13:33 2009
@@ -1,5 +1,5 @@
/hadoop/core/branches/branch-0.19/hdfs/src/java/org/apache/hadoop/hdfs/server/datanode/RecoveryInProgressException.java:713112
/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/datanode/RecoveryInProgressException.java:776175-785643,785929-786278
/hadoop/hdfs/branches/branch-0.21/src/java/org/apache/hadoop/hdfs/server/datanode/RecoveryInProgressException.java:817353-818319,818321-818553
-/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/protocol/RecoveryInProgressException.java:824552,824944,826149,828116,828926,829880,829894,830003,831436,832043
+/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/protocol/RecoveryInProgressException.java:824552,824944,826149,828116,828926,829880,829894,830003,831436,832043,833499
/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/datanode/RecoveryInProgressException.java:796829-800617,800619-803337,804756-805652,808672-809439,811495-813103,813105-813630,814223-815964,818294-818298
Propchange: hadoop/hdfs/branches/branch-0.21/src/java/org/apache/hadoop/hdfs/server/datanode/ReplicaInfo.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Nov 6 18:13:33 2009
@@ -3,4 +3,4 @@
/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/datanode/DatanodeBlockInfo.java:776175-785643,785929-786278
/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/datanode/ReplicaInfo.java:776175-785643,785929-786278
/hadoop/hdfs/branches/HDFS-265/src/java/org/apache/hadoop/hdfs/server/datanode/ReplicaInfo.java:796829-820463
-/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/datanode/ReplicaInfo.java:818294-818298,824552,824944,826149,828116,828926,829880,829894,830003,831436,832043
+/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/datanode/ReplicaInfo.java:818294-818298,824552,824944,826149,828116,828926,829880,829894,830003,831436,832043,833499
Propchange: hadoop/hdfs/branches/branch-0.21/src/test/aop/org/apache/hadoop/hdfs/protocol/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Nov 6 18:13:33 2009
@@ -1 +1 @@
-/hadoop/hdfs/trunk/src/test/aop/org/apache/hadoop/hdfs/protocol:824552,824944,826149,828116,828926,829880,829894,830003,831436,832043
+/hadoop/hdfs/trunk/src/test/aop/org/apache/hadoop/hdfs/protocol:824552,824944,826149,828116,828926,829880,829894,830003,831436,832043,833499
Propchange: hadoop/hdfs/branches/branch-0.21/src/test/hdfs/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Nov 6 18:13:33 2009
@@ -1,4 +1,4 @@
/hadoop/core/branches/branch-0.19/hdfs/src/test/hdfs:713112
/hadoop/core/trunk/src/test/hdfs:776175-785643
/hadoop/hdfs/branches/HDFS-265/src/test/hdfs:796829-820463
-/hadoop/hdfs/trunk/src/test/hdfs:818294-818298,824552,824944,826149,828116,828926,829880,829894,830003,831436,832043
+/hadoop/hdfs/trunk/src/test/hdfs:818294-818298,824552,824944,826149,828116,828926,829880,829894,830003,831436,832043,833499
Modified: hadoop/hdfs/branches/branch-0.21/src/test/hdfs/org/apache/hadoop/hdfs/server/datanode/TestBlockReport.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/branches/branch-0.21/src/test/hdfs/org/apache/hadoop/hdfs/server/datanode/TestBlockReport.java?rev=833507&r1=833506&r2=833507&view=diff
==============================================================================
--- hadoop/hdfs/branches/branch-0.21/src/test/hdfs/org/apache/hadoop/hdfs/server/datanode/TestBlockReport.java (original)
+++ hadoop/hdfs/branches/branch-0.21/src/test/hdfs/org/apache/hadoop/hdfs/server/datanode/TestBlockReport.java Fri Nov 6 18:13:33 2009
@@ -272,9 +272,8 @@
Path filePath = new Path("/" + METHOD_NAME + ".dat");
final int DN_N1 = DN_N0 + 1;
- ArrayList<Block> blocks =
- writeFileAndStartDN(METHOD_NAME,
- FILE_SIZE, filePath, true);
+ ArrayList<Block> blocks = writeFile(METHOD_NAME, FILE_SIZE, filePath);
+ startDNandWait(filePath, true);
cluster.getNameNode().blockReport(
cluster.getDataNodes().get(DN_N1).dnRegistration,
@@ -306,8 +305,8 @@
final int DN_N1 = DN_N0 + 1;
// write file and start second node to be "older" than the original
- ArrayList<Block> blocks = writeFileAndStartDN(METHOD_NAME,
- FILE_SIZE, filePath, true);
+ ArrayList<Block> blocks = writeFile(METHOD_NAME, FILE_SIZE, filePath);
+ startDNandWait(filePath, true);
int randIndex = rand.nextInt(blocks.size());
// Get a block and screw its GS
@@ -378,12 +377,14 @@
shutDownCluster();
startUpCluster();
- // write file and start second node to be "older" than the original
try {
ArrayList<Block> blocks =
- writeFileAndStartDN(METHOD_NAME, 6 * bytesChkSum, filePath, false);
+ writeFile(METHOD_NAME, 6 * bytesChkSum, filePath);
+ Block bl = findBlock(filePath, 6 * bytesChkSum);
+ BlockChecker bc = new BlockChecker(filePath);
+ bc.start();
- prepareSecondReplica(filePath, DN_N1);
+ waitForTempReplica(bl, DN_N1);
cluster.getNameNode().blockReport(
cluster.getDataNodes().get(DN_N1).dnRegistration,
@@ -391,6 +392,10 @@
printStats();
assertEquals("Wrong number of PendingReplication blocks",
blocks.size(), cluster.getNamesystem().getPendingReplicationBlocks());
+
+ try {
+ bc.join();
+ } catch (InterruptedException e) { }
} finally {
resetConfiguration(); // return the initial state of the configuration
}
@@ -414,28 +419,78 @@
try {
ArrayList<Block> blocks =
- writeFileAndStartDN(METHOD_NAME, 6 * bytesChkSum, filePath, false);
- Block b = prepareSecondReplica(filePath, DN_N1);
- corruptBlockGS(b);
- corruptBlockLen(b);
+ writeFile(METHOD_NAME, 6 * bytesChkSum, filePath);
- DatanodeCommand dnC = cluster.getNameNode().blockReport(
+ Block bl = findBlock(filePath, 6 * bytesChkSum);
+ BlockChecker bc = new BlockChecker(filePath);
+ bc.start();
+ corruptBlockGS(bl);
+ corruptBlockLen(bl);
+
+ waitForTempReplica(bl, DN_N1);
+
+ cluster.getNameNode().blockReport(
cluster.getDataNodes().get(DN_N1).dnRegistration,
new BlockListAsLongs(blocks, null).getBlockListAsLongs());
- LOG.debug("Getting command back: " + dnC);
printStats();
assertEquals("Wrong number of PendingReplication blocks",
2, cluster.getNamesystem().getPendingReplicationBlocks());
+
+ try {
+ bc.join();
+ } catch (InterruptedException e) {}
} finally {
resetConfiguration(); // return the initial state of the configuration
}
}
+ private void waitForTempReplica(Block bl, int DN_N1) {
+ final boolean tooLongWait = false;
+ final int TIMEOUT = 40000;
+
+ LOG.debug("Wait for datanode " + DN_N1 + " to appear");
+ while (cluster.getDataNodes().size() <= DN_N1) {
+ waitTil(20);
+ }
+ LOG.debug("Total number of DNs " + cluster.getDataNodes().size());
+ // Look about specified DN for the replica of the block from 1st DN
+ Replica r;
+ r = ((FSDataset) cluster.getDataNodes().get(DN_N1).getFSDataset()).
+ fetchReplicaInfo(bl.getBlockId());
+ long start = System.currentTimeMillis();
+ int count = 0;
+ while (r == null) {
+ waitTil(50);
+ r = ((FSDataset) cluster.getDataNodes().get(DN_N1).getFSDataset()).
+ fetchReplicaInfo(bl.getBlockId());
+ long waiting_period = System.currentTimeMillis() - start;
+ if (count++ % 10 == 0)
+ LOG.debug("Has been waiting for " + waiting_period + " ms.");
+ if (waiting_period > TIMEOUT)
+ assertTrue("Was waiting too long to get ReplicaInfo from a datanode",
+ tooLongWait);
+ }
+
+ HdfsConstants.ReplicaState state = r.getState();
+ LOG.debug("Replica state before the loop " + state.getValue());
+ start = System.currentTimeMillis();
+ while (state != HdfsConstants.ReplicaState.TEMPORARY) {
+ waitTil(100);
+ state = r.getState();
+ LOG.debug("Keep waiting for " + bl.getBlockName() +
+ " is in state " + state.getValue());
+ if (System.currentTimeMillis() - start > TIMEOUT)
+ assertTrue("Was waiting too long for a replica to become TEMPORARY",
+ tooLongWait);
+ }
+ LOG.debug("Replica state after the loop " + state.getValue());
+ }
+
// Helper methods from here below...
- private ArrayList<Block> writeFileAndStartDN(final String METHOD_NAME,
+ // Write file and start second data node.
+ private ArrayList<Block> writeFile(final String METHOD_NAME,
final long fileSize,
- Path filePath,
- boolean waitReplicas)
+ Path filePath)
throws IOException {
ArrayList<Block> blocks = null;
try {
@@ -444,6 +499,12 @@
} catch (IOException e) {
LOG.debug("Caught exception ", e);
}
+ return blocks;
+ }
+
+ private void startDNandWait(Path filePath, boolean waitReplicas)
+ throws IOException {
+ LOG.debug("Before next DN start: " + cluster.getDataNodes().size());
cluster.startDataNodes(conf, 1, true, null, null);
ArrayList<DataNode> datanodes = cluster.getDataNodes();
assertEquals(datanodes.size(), 2);
@@ -452,7 +513,6 @@
+ cluster.getDataNodes().get(datanodes.size() - 1)
.getDatanodeRegistration() + " has been started");
if (waitReplicas) DFSTestUtil.waitReplication(fs, filePath, REPL_FACTOR);
- return blocks;
}
private ArrayList<Block> prepareForRide(final Path filePath,
@@ -543,6 +603,9 @@
private void corruptBlockLen(final Block block)
throws IOException {
+ if (block == null) {
+ throw new IOException("Block isn't suppose to be null");
+ }
long oldLen = block.getNumBytes();
long newLen = oldLen - rand.nextLong();
assertTrue("Old and new length shouldn't be the same",
@@ -554,6 +617,9 @@
private void corruptBlockGS(final Block block)
throws IOException {
+ if (block == null) {
+ throw new IOException("Block isn't suppose to be null");
+ }
long oldGS = block.getGenerationStamp();
long newGS = oldGS - rand.nextLong();
assertTrue("Old and new GS shouldn't be the same",
@@ -563,49 +629,33 @@
" is changed to " + block.getGenerationStamp() + " from " + oldGS);
}
- // The method simply start second node and wait until a TEMPORARY replica
- // appears on it.
- // Returns the block from the specified <code>nodeNum</code> datanode
- private Block prepareSecondReplica(Path filePath,
- int nodeNum) throws IOException {
-
- final boolean tooLongWait = false;
- final int TIMEOUT = 4000;
+ private Block findBlock(Path path, long size) throws IOException {
+ Block ret;
+ List<LocatedBlock> lbs =
+ cluster.getNameNode().getBlockLocations(path.toString(),
+ FILE_START, size).getLocatedBlocks();
+ LocatedBlock lb = lbs.get(lbs.size() - 1);
+
+ // Get block from the first DN
+ ret = cluster.getDataNodes().get(DN_N0).
+ data.getStoredBlock(lb.getBlock().getBlockId());
+ return ret;
+ }
- List<LocatedBlock> lbs =
- cluster.getNameNode().getBlockLocations(filePath.toString(),
- FILE_START, FILE_SIZE).getLocatedBlocks();
- LocatedBlock lb = lbs.get(lbs.size() - 1);
-
- Block ret = cluster.getDataNodes().get(DN_N0).
- data.getStoredBlock(lb.getBlock().getBlockId());
- Replica r =
- ((FSDataset) cluster.getDataNodes().get(nodeNum).getFSDataset()).
- fetchReplicaInfo(ret.getBlockId());
- long start = System.currentTimeMillis();
- while (r == null) {
- waitTil(50);
- r = ((FSDataset) cluster.getDataNodes().get(nodeNum).getFSDataset()).
- fetchReplicaInfo(ret.getBlockId());
- if (System.currentTimeMillis() - start > TIMEOUT)
- assertTrue("Was waiting too long to get ReplicaInfo from a datanode",
- tooLongWait);
+ private class BlockChecker extends Thread {
+ Path filePath;
+
+ public BlockChecker(final Path filePath) {
+ this.filePath = filePath;
}
-
- HdfsConstants.ReplicaState state = r.getState();
- LOG.debug("Replica state before the loop " + state.getValue());
- start = System.currentTimeMillis();
- while (state != HdfsConstants.ReplicaState.TEMPORARY) {
- waitTil(100);
- state = r.getState();
- LOG.debug("Keep waiting for " + ret.getBlockName() +
- " is in state " + state.getValue());
- if (System.currentTimeMillis() - start > TIMEOUT)
- assertTrue("Was waiting too long for a replica to become TEMPORARY",
- tooLongWait);
+
+ public void run() {
+ try {
+ startDNandWait(filePath, true);
+ } catch (IOException e) {
+ LOG.warn("Shouldn't happen", e);
+ }
}
- LOG.debug("Replica state after the loop " + state.getValue());
- return ret;
}
private static void resetConfiguration() {
Propchange: hadoop/hdfs/branches/branch-0.21/src/webapps/datanode/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Nov 6 18:13:33 2009
@@ -1,4 +1,4 @@
/hadoop/core/branches/branch-0.19/hdfs/src/webapps/datanode:713112
/hadoop/core/trunk/src/webapps/datanode:776175-784663
/hadoop/hdfs/branches/HDFS-265/src/webapps/datanode:796829-820463
-/hadoop/hdfs/trunk/src/webapps/datanode:818294-818298,824552,824944,826149,828116,828926,829880,829894,830003,831436,832043
+/hadoop/hdfs/trunk/src/webapps/datanode:818294-818298,824552,824944,826149,828116,828926,829880,829894,830003,831436,832043,833499
Propchange: hadoop/hdfs/branches/branch-0.21/src/webapps/hdfs/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Nov 6 18:13:33 2009
@@ -1,4 +1,4 @@
/hadoop/core/branches/branch-0.19/hdfs/src/webapps/hdfs:713112
/hadoop/core/trunk/src/webapps/hdfs:776175-784663
/hadoop/hdfs/branches/HDFS-265/src/webapps/hdfs:796829-820463
-/hadoop/hdfs/trunk/src/webapps/hdfs:818294-818298,824552,824944,826149,828116,828926,829880,829894,830003,831436,832043
+/hadoop/hdfs/trunk/src/webapps/hdfs:818294-818298,824552,824944,826149,828116,828926,829880,829894,830003,831436,832043,833499
Propchange: hadoop/hdfs/branches/branch-0.21/src/webapps/secondary/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Nov 6 18:13:33 2009
@@ -1,4 +1,4 @@
/hadoop/core/branches/branch-0.19/hdfs/src/webapps/secondary:713112
/hadoop/core/trunk/src/webapps/secondary:776175-784663
/hadoop/hdfs/branches/HDFS-265/src/webapps/secondary:796829-820463
-/hadoop/hdfs/trunk/src/webapps/secondary:818294-818298,824552,824944,826149,828116,828926,829880,829894,830003,831436,832043
+/hadoop/hdfs/trunk/src/webapps/secondary:818294-818298,824552,824944,826149,828116,828926,829880,829894,830003,831436,832043,833499