Author: rangadi
Date: Tue Jul 15 18:41:01 2008
New Revision: 677127
URL: http://svn.apache.org/viewvc?rev=677127&view=rev
Log:
HADOOP-3732. Delay intialization of datanode block verification till
the verification thread is started. (rangadi)
Modified:
hadoop/core/trunk/CHANGES.txt
hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataBlockScanner.java
Modified: hadoop/core/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=677127&r1=677126&r2=677127&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Tue Jul 15 18:41:01 2008
@@ -54,6 +54,9 @@
IMPROVEMENTS
+ HADOOP-3732. Delay intialization of datanode block verification till
+ the verification thread is started. (rangadi)
+
HADOOP-1627. Various small improvements to 'dfsadmin -report' output.
(rangadi)
Modified:
hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataBlockScanner.java
URL:
http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataBlockScanner.java?rev=677127&r1=677126&r2=677127&view=diff
==============================================================================
---
hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataBlockScanner.java
(original)
+++
hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataBlockScanner.java
Tue Jul 15 18:41:01 2008
@@ -95,7 +95,7 @@
Random random = new Random();
- DataNode.Throttler throttler = new DataNode.Throttler(200, MAX_SCAN_RATE);
+ DataNode.Throttler throttler = null;
private static enum ScanType {
REMOTE_READ, // Verified when a block read by a client etc
@@ -143,7 +143,11 @@
scanPeriod = DEFAULT_SCAN_PERIOD_HOURS;
}
scanPeriod *= 3600 * 1000;
- init();
+ // initialized when the scanner thread is started.
+ }
+
+ private synchronized boolean isInitiliazed() {
+ return throttler != null;
}
private void updateBytesToScan(long len, long lastScanTime) {
@@ -234,6 +238,9 @@
"Verification times are not stored.");
}
+ synchronized (this) {
+ throttler = new DataNode.Throttler(200, MAX_SCAN_RATE);
+ }
}
private synchronized long getNewBlockScanTime() {
@@ -248,6 +255,9 @@
/** Adds block to list of blocks */
synchronized void addBlock(Block block) {
+ if (!isInitiliazed()) {
+ return;
+ }
BlockScanInfo info = blockMap.get(block);
if ( info != null ) {
@@ -264,6 +274,9 @@
/** Deletes the block from internal structures */
synchronized void deleteBlock(Block block) {
+ if (!isInitiliazed()) {
+ return;
+ }
BlockScanInfo info = blockMap.get(block);
if ( info != null ) {
delBlockInfo(info);
@@ -272,6 +285,9 @@
/** @return the last scan time */
public synchronized long getLastScanTime(Block block) {
+ if (!isInitiliazed()) {
+ return 0;
+ }
BlockScanInfo info = blockMap.get(block);
return info == null? 0: info.lastScanTime;
}
@@ -550,6 +566,9 @@
public void run() {
try {
+
+ init();
+
//Read last verification times
if (!assignInitialVerificationTimes()) {
return;
@@ -816,7 +835,7 @@
* If the data is not read completely (i.e, untill hasNext() returns
* false), it needs to be explicitly
*/
- class Reader implements Iterator<String>, Closeable {
+ private class Reader implements Iterator<String>, Closeable {
BufferedReader reader;
File file;
@@ -929,10 +948,13 @@
StringBuilder buffer = new StringBuilder(8*1024);
if (blockScanner == null) {
- buffer.append("Period block scanner is not running. " +
+ buffer.append("Periodic block scanner is not running. " +
"Please check the datanode log if this is unexpected.");
- } else {
+ } else if (blockScanner.isInitiliazed()) {
blockScanner.printBlockReport(buffer, summary);
+ } else {
+ buffer.append("Periodic block scanner is not yet initialized. " +
+ "Please check back again after some time.");
}
response.getWriter().write(buffer.toString()); // extra copy!
}