You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-commits@hadoop.apache.org by co...@apache.org on 2010/01/28 00:36:00 UTC
svn commit: r903906 - in /hadoop/hdfs/trunk: CHANGES.txt
src/test/hdfs/org/apache/hadoop/hdfs/TestDatanodeBlockScanner.java
Author: cos
Date: Wed Jan 27 23:35:59 2010
New Revision: 903906
URL: http://svn.apache.org/viewvc?rev=903906&view=rev
Log:
HDFS-919. Create test to validate the BlocksVerified metric. Contributed by Gary Murry.
Modified:
hadoop/hdfs/trunk/CHANGES.txt
hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDatanodeBlockScanner.java
Modified: hadoop/hdfs/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/CHANGES.txt?rev=903906&r1=903905&r2=903906&view=diff
==============================================================================
--- hadoop/hdfs/trunk/CHANGES.txt (original)
+++ hadoop/hdfs/trunk/CHANGES.txt Wed Jan 27 23:35:59 2010
@@ -663,6 +663,9 @@
HDFS-737. Add full path name of the file to the block information and
summary of total number of files, blocks, live and deadnodes to
metasave output. (Jitendra Nath Pandey via suresh)
+
+ HDFS-919. Create test to validate the BlocksVerified metric (Gary Murry
+ via cos)
BUG FIXES
Modified: hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDatanodeBlockScanner.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDatanodeBlockScanner.java?rev=903906&r1=903905&r2=903906&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDatanodeBlockScanner.java (original)
+++ hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDatanodeBlockScanner.java Wed Jan 27 23:35:59 2010
@@ -50,12 +50,15 @@
private static Pattern pattern =
Pattern.compile(".*?(blk_[-]*\\d+).*?scan time\\s*:\\s*(\\d+)");
+
+ private static Pattern pattern_blockVerify =
+ Pattern.compile(".*?(SCAN_PERIOD)\\s*:\\s*(\\d+.*?)");
/**
* This connects to datanode and fetches block verification data.
* It repeats this until the given block has a verification time > 0.
*/
private static long waitForVerification(DatanodeInfo dn, FileSystem fs,
- Path file) throws IOException {
+ Path file, int blocksValidated) throws IOException {
URL url = new URL("http://localhost:" + dn.getInfoPort() +
"/blockScannerReport?listblocks");
long lastWarnTime = System.currentTimeMillis();
@@ -65,6 +68,14 @@
while (verificationTime <= 0) {
String response = DFSTestUtil.urlGet(url);
+ if(blocksValidated >= 0) {
+ for(Matcher matcher = pattern_blockVerify.matcher(response); matcher.find();) {
+ if (block.equals(matcher.group(1))) {
+ assertEquals(1, blocksValidated);
+ break;
+ }
+ }
+ }
for(Matcher matcher = pattern.matcher(response); matcher.find();) {
if (block.equals(matcher.group(1))) {
verificationTime = Long.parseLong(matcher.group(2));
@@ -115,7 +126,7 @@
/*
* The cluster restarted. The block should be verified by now.
*/
- assertTrue(waitForVerification(dn, fs, file1) > startTime);
+ assertTrue(waitForVerification(dn, fs, file1, 1) > startTime);
/*
* Create a new file and read the block. The block should be marked
@@ -124,7 +135,7 @@
DFSTestUtil.createFile(fs, file2, 10, (short)1, 0);
IOUtils.copyBytes(fs.open(file2), new IOUtils.NullOutputStream(),
conf, true);
- assertTrue(waitForVerification(dn, fs, file2) > startTime);
+ assertTrue(waitForVerification(dn, fs, file2, 2) > startTime);
cluster.shutdown();
}