HDFS-4274. BlockPoolSliceScanner does not close verification log during shutdown. Contributed by Chris Nauroth

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1432318 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Eli Collins 2013-01-11 22:21:21 +00:00
parent 596007fdc4
commit f07582bc84
3 changed files with 33 additions and 3 deletions

View File

@ -399,6 +399,9 @@ Release 2.0.3-alpha - Unreleased
HDFS-4328. TestLargeBlock#testLargeBlockSize is timing out. (Chris Nauroth HDFS-4328. TestLargeBlock#testLargeBlockSize is timing out. (Chris Nauroth
via atm) via atm)
HDFS-4274. BlockPoolSliceScanner does not close verification log during
shutdown. (Chris Nauroth via suresh)
BREAKDOWN OF HDFS-3077 SUBTASKS BREAKDOWN OF HDFS-3077 SUBTASKS
HDFS-3077. Quorum-based protocol for reading and writing edit logs. HDFS-3077. Quorum-based protocol for reading and writing edit logs.

View File

@ -602,6 +602,15 @@ class BlockPoolSliceScanner {
lastScanTime.set(Time.now()); lastScanTime.set(Time.now());
} }
} }
/**
* Shuts down this BlockPoolSliceScanner and releases any internal resources.
*/
void shutdown() {
if (verificationLog != null) {
verificationLog.close();
}
}
private void scan() { private void scan() {
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
@ -610,7 +619,8 @@ class BlockPoolSliceScanner {
try { try {
adjustThrottler(); adjustThrottler();
while (datanode.shouldRun && !Thread.interrupted() while (datanode.shouldRun
&& !datanode.blockScanner.blockScannerThread.isInterrupted()
&& datanode.isBPServiceAlive(blockPoolId)) { && datanode.isBPServiceAlive(blockPoolId)) {
long now = Time.now(); long now = Time.now();
synchronized (this) { synchronized (this) {

View File

@ -100,6 +100,11 @@ public class DataBlockScanner implements Runnable {
} }
bpScanner.scanBlockPoolSlice(); bpScanner.scanBlockPoolSlice();
} }
// Call shutdown for each allocated BlockPoolSliceScanner.
for (BlockPoolSliceScanner bpss: blockPoolScannerMap.values()) {
bpss.shutdown();
}
} }
// Wait for at least one block pool to be up // Wait for at least one block pool to be up
@ -232,9 +237,21 @@ public class DataBlockScanner implements Runnable {
} }
} }
public synchronized void shutdown() { public void shutdown() {
synchronized (this) {
if (blockScannerThread != null) {
blockScannerThread.interrupt();
}
}
// We cannot join within the synchronized block, because it would create a
// deadlock situation. blockScannerThread calls other synchronized methods.
if (blockScannerThread != null) { if (blockScannerThread != null) {
blockScannerThread.interrupt(); try {
blockScannerThread.join();
} catch (InterruptedException e) {
// shutting down anyway
}
} }
} }