svn merge -c 1501841. Merging from trunk to branch-2 to fix HDFS-4887.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1501843 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Kihwal Lee 2013-07-10 16:42:38 +00:00
parent 88a0d9cc2c
commit 2d88e826e1
4 changed files with 32 additions and 8 deletions

View File

@ -449,6 +449,8 @@ Release 2.1.0-beta - 2013-07-02
HDFS-4948. mvn site for hadoop-hdfs-nfs fails. (brandonli) HDFS-4948. mvn site for hadoop-hdfs-nfs fails. (brandonli)
HDFS-4887. TestNNThroughputBenchmark exits abruptly. (kihwal)
BREAKDOWN OF HDFS-347 SUBTASKS AND RELATED JIRAS BREAKDOWN OF HDFS-347 SUBTASKS AND RELATED JIRAS
HDFS-4353. Encapsulate connections to peers in Peer and PeerServer classes. HDFS-4353. Encapsulate connections to peers in Peer and PeerServer classes.

View File

@ -228,6 +228,9 @@ public class BlockManager {
/** for block replicas placement */ /** for block replicas placement */
private BlockPlacementPolicy blockplacement; private BlockPlacementPolicy blockplacement;
/** Check whether name system is running before terminating */
private boolean checkNSRunning = true;
public BlockManager(final Namesystem namesystem, final FSClusterStats stats, public BlockManager(final Namesystem namesystem, final FSClusterStats stats,
final Configuration conf) throws IOException { final Configuration conf) throws IOException {
this.namesystem = namesystem; this.namesystem = namesystem;
@ -356,6 +359,12 @@ public class BlockManager {
return blockTokenSecretManager; return blockTokenSecretManager;
} }
/** Allow silent termination of replication monitor for testing */
@VisibleForTesting
void enableRMTerminationForTesting() {
checkNSRunning = false;
}
private boolean isBlockTokenEnabled() { private boolean isBlockTokenEnabled() {
return blockTokenSecretManager != null; return blockTokenSecretManager != null;
} }
@ -3113,6 +3122,9 @@ assert storedBlock.findDatanode(dn) < 0 : "Block " + block
+ " while shutting down.", t); + " while shutting down.", t);
} }
break; break;
} else if (!checkNSRunning && t instanceof InterruptedException) {
LOG.info("Stopping ReplicationMonitor for testing.");
break;
} }
LOG.fatal("ReplicationMonitor thread received Runtime exception. ", t); LOG.fatal("ReplicationMonitor thread received Runtime exception. ", t);
terminate(1, t); terminate(1, t);

View File

@ -107,6 +107,22 @@ public class BlockManagerTestUtil {
return blockManager.replicationThread; return blockManager.replicationThread;
} }
/**
* Stop the replication monitor thread
* @param blockManager
*/
public static void stopReplicationThread(final BlockManager blockManager)
throws IOException {
blockManager.enableRMTerminationForTesting();
blockManager.replicationThread.interrupt();
try {
blockManager.replicationThread.join();
} catch(InterruptedException ie) {
throw new IOException(
"Interrupted while trying to stop ReplicationMonitor");
}
}
/** /**
* @param blockManager * @param blockManager
* @return corruptReplicas from block manager * @return corruptReplicas from block manager

View File

@ -1194,14 +1194,8 @@ public class NNThroughputBenchmark {
// start data-nodes; create a bunch of files; generate block reports. // start data-nodes; create a bunch of files; generate block reports.
blockReportObject.generateInputs(ignore); blockReportObject.generateInputs(ignore);
// stop replication monitor // stop replication monitor
BlockManagerTestUtil.getReplicationThread(namesystem.getBlockManager()) BlockManagerTestUtil.stopReplicationThread(namesystem.getBlockManager());
.interrupt();
try {
BlockManagerTestUtil.getReplicationThread(namesystem.getBlockManager())
.join();
} catch(InterruptedException ei) {
return;
}
// report blocks once // report blocks once
int nrDatanodes = blockReportObject.getNumDatanodes(); int nrDatanodes = blockReportObject.getNumDatanodes();
for(int idx=0; idx < nrDatanodes; idx++) { for(int idx=0; idx < nrDatanodes; idx++) {