HBASE-5804 Add more to verification step in HLogPerformanceEvaluation

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1326902 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2012-04-17 03:57:18 +00:00
parent 6858d30b13
commit ae3cbd0605
2 changed files with 15 additions and 9 deletions

View File

@ -49,6 +49,8 @@ import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
/** /**
* This class runs performance benchmarks for {@link HLog}. * This class runs performance benchmarks for {@link HLog}.
* See usage for this tool by running:
* <code>$ hbase org.apache.hadoop.hbase.regionserver.wal.HLogPerformanceEvaluation -h</code>
*/ */
@InterfaceAudience.Private @InterfaceAudience.Private
public final class HLogPerformanceEvaluation extends Configured implements Tool { public final class HLogPerformanceEvaluation extends Configured implements Tool {
@ -178,7 +180,7 @@ public final class HLogPerformanceEvaluation extends Configured implements Tool
if (verify) { if (verify) {
Path dir = hlog.getDir(); Path dir = hlog.getDir();
for (FileStatus fss: fs.listStatus(dir)) { for (FileStatus fss: fs.listStatus(dir)) {
verifyInSequence(fss.getPath()); verify(fss.getPath(), numIterations * numThreads);
} }
} }
} finally { } finally {
@ -202,13 +204,23 @@ public final class HLogPerformanceEvaluation extends Configured implements Tool
return htd; return htd;
} }
void verifyInSequence(final Path wal) throws IOException { /**
* Verify the content of the WAL file.
* Verify that sequenceids are ascending and that the file has expected number
* of edits.
* @param wal
* @param editsCount
* @throws IOException
*/
private void verify(final Path wal, final long editsCount) throws IOException {
HLog.Reader reader = HLog.getReader(wal.getFileSystem(getConf()), wal, getConf()); HLog.Reader reader = HLog.getReader(wal.getFileSystem(getConf()), wal, getConf());
long previousSeqid = -1; long previousSeqid = -1;
long count = 0;
try { try {
while (true) { while (true) {
Entry e = reader.next(); Entry e = reader.next();
if (e == null) break; if (e == null) break;
count++;
long seqid = e.getKey().getLogSeqNum(); long seqid = e.getKey().getLogSeqNum();
if (previousSeqid >= seqid) { if (previousSeqid >= seqid) {
throw new IllegalStateException("wal=" + wal.getName() + throw new IllegalStateException("wal=" + wal.getName() +
@ -216,6 +228,7 @@ public final class HLogPerformanceEvaluation extends Configured implements Tool
} }
previousSeqid = seqid; previousSeqid = seqid;
} }
if (count != editsCount) throw new IllegalStateException("Expected=" + editsCount + ", found=" + count);
} finally { } finally {
reader.close(); reader.close();
} }

View File

@ -142,11 +142,4 @@
version is X.X.X-SNAPSHOT" version is X.X.X-SNAPSHOT"
</description> </description>
</property> </property>
<property>
<name>hbase.client.retries.number</name>
<value>100</value>
<description>
Use a lot of retries in unit tests.
</description>
</property>
</configuration> </configuration>