HDFS-12371. BlockVerificationFailures and BlocksVerified show up as 0 in Datanode JMX. Contributed by Hanisha Koneru.

This commit is contained in:
Kihwal Lee 2017-09-21 08:42:50 -05:00
parent 10d7493587
commit 6bf921a5c3

View File

@ -37,6 +37,7 @@
import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsVolumeReference; import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsVolumeReference;
import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsVolumeSpi.BlockIterator; import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsVolumeSpi.BlockIterator;
import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsVolumeSpi; import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsVolumeSpi;
import org.apache.hadoop.hdfs.server.datanode.metrics.DataNodeMetrics;
import org.apache.hadoop.hdfs.util.DataTransferThrottler; import org.apache.hadoop.hdfs.util.DataTransferThrottler;
import org.apache.hadoop.io.IOUtils; import org.apache.hadoop.io.IOUtils;
import org.apache.hadoop.util.Time; import org.apache.hadoop.util.Time;
@ -81,6 +82,8 @@ void setConf(Conf conf) {
*/ */
private final DataNode datanode; private final DataNode datanode;
private final DataNodeMetrics metrics;
/** /**
* A reference to the volume that we're scanning. * A reference to the volume that we're scanning.
*/ */
@ -299,6 +302,7 @@ public void handle(ExtendedBlock block, IOException e) {
VolumeScanner(Conf conf, DataNode datanode, FsVolumeReference ref) { VolumeScanner(Conf conf, DataNode datanode, FsVolumeReference ref) {
this.conf = conf; this.conf = conf;
this.datanode = datanode; this.datanode = datanode;
this.metrics = datanode.getMetrics();
this.ref = ref; this.ref = ref;
this.volume = ref.getVolume(); this.volume = ref.getVolume();
ScanResultHandler handler; ScanResultHandler handler;
@ -443,12 +447,14 @@ private long scanBlock(ExtendedBlock cblock, long bytesPerSec) {
throttler.setBandwidth(bytesPerSec); throttler.setBandwidth(bytesPerSec);
long bytesRead = blockSender.sendBlock(nullStream, null, throttler); long bytesRead = blockSender.sendBlock(nullStream, null, throttler);
resultHandler.handle(block, null); resultHandler.handle(block, null);
metrics.incrBlocksVerified();
return bytesRead; return bytesRead;
} catch (IOException e) { } catch (IOException e) {
resultHandler.handle(block, e); resultHandler.handle(block, e);
} finally { } finally {
IOUtils.cleanup(null, blockSender); IOUtils.cleanup(null, blockSender);
} }
metrics.incrBlockVerificationFailures();
return -1; return -1;
} }