HDFS-4022. Replication not happening for appended block. Contributed by Vinay.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1400578 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uma Maheswara Rao G 2012-10-21 06:31:31 +00:00
parent 85b158998e
commit 35ec20b7c6
3 changed files with 41 additions and 1 deletions

View File

@ -480,6 +480,8 @@ Release 2.0.3-alpha - Unreleased
HDFS-4072. On file deletion remove corresponding blocks pending HDFS-4072. On file deletion remove corresponding blocks pending
replications. (Jing Zhao via suresh) replications. (Jing Zhao via suresh)
HDFS-4022. Replication not happening for appended block. (Vinay via umamahesh)
Release 2.0.2-alpha - 2012-09-07 Release 2.0.2-alpha - 2012-09-07
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -624,7 +624,10 @@ public class BlockManager {
blocksMap.replaceBlock(ucBlock); blocksMap.replaceBlock(ucBlock);
// Remove block from replication queue. // Remove block from replication queue.
updateNeededReplications(oldBlock, 0, 0); NumberReplicas replicas = countNodes(ucBlock);
neededReplications.remove(ucBlock, replicas.liveReplicas(),
replicas.decommissionedReplicas(), getReplication(ucBlock));
pendingReplications.remove(ucBlock);
// remove this block from the list of pending blocks to be deleted. // remove this block from the list of pending blocks to be deleted.
for (DatanodeDescriptor dd : targets) { for (DatanodeDescriptor dd : targets) {

View File

@ -291,4 +291,39 @@ public class TestFileAppend4 {
cluster.shutdown(); cluster.shutdown();
} }
} }
/**
* Test the updation of NeededReplications for the Appended Block
*/
@Test(timeout = 60000)
public void testUpdateNeededReplicationsForAppendedFile() throws Exception {
Configuration conf = new Configuration();
MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).numDataNodes(1)
.build();
DistributedFileSystem fileSystem = null;
try {
// create a file.
fileSystem = cluster.getFileSystem();
Path f = new Path("/testAppend");
FSDataOutputStream create = fileSystem.create(f, (short) 2);
create.write("/testAppend".getBytes());
create.close();
// Append to the file.
FSDataOutputStream append = fileSystem.append(f);
append.write("/testAppend".getBytes());
append.close();
// Start a new datanode
cluster.startDataNodes(conf, 1, true, null, null);
// Check for replications
DFSTestUtil.waitReplication(fileSystem, f, (short) 2);
} finally {
if (null != fileSystem) {
fileSystem.close();
}
cluster.shutdown();
}
}
} }