Repository: hadoop
Updated Branches:
refs/heads/branch-2.6.1 81a445edf -> 553efd719
HDFS-7930. commitBlockSynchronization() does not remove locations. (yliu)
(cherry picked from commit 90164ffd84f6ef56e9f8f99dcc7424a8d115dbae)
Conflicts:
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFileTruncate.java
(cherry picked from commit 2c9a7461ec2ceba5885e95bc79f8dcbfd198df60)
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/553efd71
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/553efd71
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/553efd71
Branch: refs/heads/branch-2.6.1
Commit: 553efd719061e8fee98f91ed1b766d2e77c78c9c
Parents: 81a445e
Author: yliu <[email protected]>
Authored: Thu Mar 19 23:24:55 2015 +0800
Committer: Vinod Kumar Vavilapalli <[email protected]>
Committed: Tue Sep 1 17:06:37 2015 -0700
----------------------------------------------------------------------
hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 2 +
.../server/blockmanagement/BlockManager.java | 41 ++++++++++++++++++++
.../hdfs/server/namenode/FSNamesystem.java | 8 +++-
3 files changed, 49 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/553efd71/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
index ff335ab..904d02d 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
+++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
@@ -100,6 +100,8 @@ Release 2.6.1 - UNRELEASED
HDFS-7929. inotify unable fetch pre-upgrade edit log segments once upgrade
starts (Zhe Zhang via Colin P. McCabe)
+ HDFS-7930. commitBlockSynchronization() does not remove locations. (yliu)
+
Release 2.6.0 - 2014-11-18
INCOMPATIBLE CHANGES
http://git-wip-us.apache.org/repos/asf/hadoop/blob/553efd71/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java
----------------------------------------------------------------------
diff --git
a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java
index d26cc52..5a38351 100644
---
a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java
+++
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java
@@ -1931,6 +1931,47 @@ public class BlockManager {
}
/**
+ * Mark block replicas as corrupt except those on the storages in
+ * newStorages list.
+ */
+ public void markBlockReplicasAsCorrupt(BlockInfo block,
+ long oldGenerationStamp, long oldNumBytes,
+ DatanodeStorageInfo[] newStorages) throws IOException {
+ assert namesystem.hasWriteLock();
+ BlockToMarkCorrupt b = null;
+ if (block.getGenerationStamp() != oldGenerationStamp) {
+ b = new BlockToMarkCorrupt(block, oldGenerationStamp,
+ "genstamp does not match " + oldGenerationStamp
+ + " : " + block.getGenerationStamp(), Reason.GENSTAMP_MISMATCH);
+ } else if (block.getNumBytes() != oldNumBytes) {
+ b = new BlockToMarkCorrupt(block,
+ "length does not match " + oldNumBytes
+ + " : " + block.getNumBytes(), Reason.SIZE_MISMATCH);
+ } else {
+ return;
+ }
+
+ for (DatanodeStorageInfo storage : getStorages(block)) {
+ boolean isCorrupt = true;
+ if (newStorages != null) {
+ for (DatanodeStorageInfo newStorage : newStorages) {
+ if (newStorage!= null && storage.equals(newStorage)) {
+ isCorrupt = false;
+ break;
+ }
+ }
+ }
+ if (isCorrupt) {
+ blockLog.info("BLOCK* markBlockReplicasAsCorrupt: mark block replica" +
+ b + " on " + storage.getDatanodeDescriptor() +
+ " as corrupt because the dn is not in the new committed " +
+ "storage list.");
+ markBlockAsCorrupt(b, storage, storage.getDatanodeDescriptor());
+ }
+ }
+ }
+
+ /**
* processFirstBlockReport is intended only for processing "initial" block
* reports, the first block report received from a DN after it registers.
* It just adds all the valid replicas to the datanode, without calculating
http://git-wip-us.apache.org/repos/asf/hadoop/blob/553efd71/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
----------------------------------------------------------------------
diff --git
a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
index c92b431..fa52981 100644
---
a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
+++
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
@@ -4791,6 +4791,8 @@ public class FSNamesystem implements Namesystem,
FSClusterStats,
throw new IOException("Block (=" + lastblock + ") not found");
}
}
+ final long oldGenerationStamp = storedBlock.getGenerationStamp();
+ final long oldNumBytes = storedBlock.getNumBytes();
//
// The implementation of delete operation (see @deleteInternal method)
// first removes the file paths from namespace, and delays the removal
@@ -4845,8 +4847,6 @@ public class FSNamesystem implements Namesystem,
FSClusterStats,
storedBlock.setNumBytes(newlength);
// find the DatanodeDescriptor objects
- // There should be no locations in the blockManager till now because
the
- // file is underConstruction
ArrayList<DatanodeDescriptor> trimmedTargets =
new ArrayList<DatanodeDescriptor>(newtargets.length);
ArrayList<String> trimmedStorages =
@@ -4883,6 +4883,10 @@ public class FSNamesystem implements Namesystem,
FSClusterStats,
trimmedTargets.toArray(new DatanodeID[trimmedTargets.size()]),
trimmedStorages.toArray(new String[trimmedStorages.size()]));
iFile.setLastBlock(storedBlock, trimmedStorageInfos);
+ if (closeFile) {
+ blockManager.markBlockReplicasAsCorrupt(storedBlock,
+ oldGenerationStamp, oldNumBytes, trimmedStorageInfos);
+ }
}
if (closeFile) {