View Javadoc

1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  package org.apache.hadoop.hbase.wal;
20  
21  import java.io.IOException;
22  import java.util.ArrayList;
23  import java.util.HashMap;
24  import java.util.HashSet;
25  import java.util.List;
26  import java.util.Map;
27  import java.util.Random;
28  import java.util.Set;
29  import java.util.UUID;
30  import java.util.concurrent.TimeUnit;
31  
32  import org.apache.commons.logging.Log;
33  import org.apache.commons.logging.LogFactory;
34  import org.apache.hadoop.hbase.classification.InterfaceAudience;
35  import org.apache.hadoop.conf.Configuration;
36  import org.apache.hadoop.conf.Configured;
37  import org.apache.hadoop.fs.FileStatus;
38  import org.apache.hadoop.fs.FileSystem;
39  import org.apache.hadoop.fs.Path;
40  import org.apache.hadoop.hbase.Cell;
41  import org.apache.hadoop.hbase.HBaseConfiguration;
42  import org.apache.hadoop.hbase.HBaseTestingUtility;
43  import org.apache.hadoop.hbase.HColumnDescriptor;
44  import org.apache.hadoop.hbase.HConstants;
45  import org.apache.hadoop.hbase.HRegionInfo;
46  import org.apache.hadoop.hbase.HTableDescriptor;
47  import org.apache.hadoop.hbase.MockRegionServerServices;
48  import org.apache.hadoop.hbase.TableName;
49  import org.apache.hadoop.hbase.client.Put;
50  import org.apache.hadoop.hbase.io.crypto.KeyProviderForTesting;
51  import org.apache.hadoop.hbase.regionserver.HRegion;
52  import org.apache.hadoop.hbase.regionserver.LogRoller;
53  import org.apache.hadoop.hbase.trace.HBaseHTraceConfiguration;
54  import org.apache.hadoop.hbase.trace.SpanReceiverHost;
55  import org.apache.hadoop.hbase.wal.WALProvider.Writer;
56  import org.apache.hadoop.hbase.wal.WAL;
57  import org.apache.hadoop.hbase.util.Bytes;
58  import org.apache.hadoop.hbase.util.FSUtils;
59  import org.apache.hadoop.hbase.util.Threads;
60  import org.apache.hadoop.util.Tool;
61  import org.apache.hadoop.util.ToolRunner;
62  import org.apache.htrace.HTraceConfiguration;
63  import org.apache.htrace.Sampler;
64  import org.apache.htrace.Trace;
65  import org.apache.htrace.TraceScope;
66  import org.apache.htrace.impl.ProbabilitySampler;
67  
68  import com.yammer.metrics.core.Histogram;
69  import com.yammer.metrics.core.Meter;
70  import com.yammer.metrics.core.MetricsRegistry;
71  import com.yammer.metrics.reporting.ConsoleReporter;
72  
73  // imports for things that haven't moved from regionserver.wal yet.
74  import org.apache.hadoop.hbase.regionserver.wal.SecureProtobufLogReader;
75  import org.apache.hadoop.hbase.regionserver.wal.SecureProtobufLogWriter;
76  import org.apache.hadoop.hbase.regionserver.wal.WALActionsListener;
77  import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
78  
79  /**
80   * This class runs performance benchmarks for {@link WAL}.
81   * See usage for this tool by running:
82   * <code>$ hbase org.apache.hadoop.hbase.wal.WALPerformanceEvaluation -h</code>
83   */
84  @InterfaceAudience.Private
85  public final class WALPerformanceEvaluation extends Configured implements Tool {
86    static final Log LOG = LogFactory.getLog(WALPerformanceEvaluation.class.getName());
87    private final MetricsRegistry metrics = new MetricsRegistry();
88    private final Meter syncMeter =
89      metrics.newMeter(WALPerformanceEvaluation.class, "syncMeter", "syncs", TimeUnit.MILLISECONDS);
90    private final Histogram syncHistogram =
91      metrics.newHistogram(WALPerformanceEvaluation.class, "syncHistogram", "nanos-between-syncs",
92        true);
93    private final Histogram syncCountHistogram =
94        metrics.newHistogram(WALPerformanceEvaluation.class, "syncCountHistogram", "countPerSync",
95          true);
96    private final Meter appendMeter =
97      metrics.newMeter(WALPerformanceEvaluation.class, "appendMeter", "bytes",
98        TimeUnit.MILLISECONDS);
99    private final Histogram latencyHistogram =
100     metrics.newHistogram(WALPerformanceEvaluation.class, "latencyHistogram", "nanos", true);
101 
102   private HBaseTestingUtility TEST_UTIL;
103 
104   static final String TABLE_NAME = "WALPerformanceEvaluation";
105   static final String QUALIFIER_PREFIX = "q";
106   static final String FAMILY_PREFIX = "cf";
107 
108   private int numQualifiers = 1;
109   private int valueSize = 512;
110   private int keySize = 16;
111 
112   @Override
113   public void setConf(Configuration conf) {
114     super.setConf(conf);
115     TEST_UTIL = new HBaseTestingUtility(conf);
116   }
117 
118   /**
119    * Perform WAL.append() of Put object, for the number of iterations requested.
120    * Keys and Vaues are generated randomly, the number of column families,
121    * qualifiers and key/value size is tunable by the user.
122    */
123   class WALPutBenchmark implements Runnable {
124     private final long numIterations;
125     private final int numFamilies;
126     private final boolean noSync;
127     private final HRegion region;
128     private final int syncInterval;
129     private final HTableDescriptor htd;
130     private final Sampler loopSampler;
131 
132     WALPutBenchmark(final HRegion region, final HTableDescriptor htd,
133         final long numIterations, final boolean noSync, final int syncInterval,
134         final double traceFreq) {
135       this.numIterations = numIterations;
136       this.noSync = noSync;
137       this.syncInterval = syncInterval;
138       this.numFamilies = htd.getColumnFamilies().length;
139       this.region = region;
140       this.htd = htd;
141       String spanReceivers = getConf().get("hbase.trace.spanreceiver.classes");
142       if (spanReceivers == null || spanReceivers.isEmpty()) {
143         loopSampler = Sampler.NEVER;
144       } else {
145         if (traceFreq <= 0.0) {
146           LOG.warn("Tracing enabled but traceFreq=0.");
147           loopSampler = Sampler.NEVER;
148         } else if (traceFreq >= 1.0) {
149           loopSampler = Sampler.ALWAYS;
150           if (numIterations > 1000) {
151             LOG.warn("Full tracing of all iterations will produce a lot of data. Be sure your"
152               + " SpanReciever can keep up.");
153           }
154         } else {
155           getConf().setDouble("hbase.sampler.fraction", traceFreq);
156           loopSampler = new ProbabilitySampler(new HBaseHTraceConfiguration(getConf()));
157         }
158       }
159     }
160 
161     @Override
162     public void run() {
163       byte[] key = new byte[keySize];
164       byte[] value = new byte[valueSize];
165       Random rand = new Random(Thread.currentThread().getId());
166       WAL wal = region.getWAL();
167 
168       TraceScope threadScope =
169         Trace.startSpan("WALPerfEval." + Thread.currentThread().getName());
170       try {
171         long startTime = System.currentTimeMillis();
172         int lastSync = 0;
173         for (int i = 0; i < numIterations; ++i) {
174           assert Trace.currentSpan() == threadScope.getSpan() : "Span leak detected.";
175           TraceScope loopScope = Trace.startSpan("runLoopIter" + i, loopSampler);
176           try {
177             long now = System.nanoTime();
178             Put put = setupPut(rand, key, value, numFamilies);
179             WALEdit walEdit = new WALEdit();
180             addFamilyMapToWALEdit(put.getFamilyCellMap(), walEdit);
181             HRegionInfo hri = region.getRegionInfo();
182             final WALKey logkey = new WALKey(hri.getEncodedNameAsBytes(), hri.getTable(), now);
183             wal.append(htd, hri, logkey, walEdit, region.getSequenceId(), true, null);
184             if (!this.noSync) {
185               if (++lastSync >= this.syncInterval) {
186                 wal.sync();
187                 lastSync = 0;
188               }
189             }
190             latencyHistogram.update(System.nanoTime() - now);
191           } finally {
192             loopScope.close();
193           }
194         }
195         long totalTime = (System.currentTimeMillis() - startTime);
196         logBenchmarkResult(Thread.currentThread().getName(), numIterations, totalTime);
197       } catch (Exception e) {
198         LOG.error(getClass().getSimpleName() + " Thread failed", e);
199       } finally {
200         threadScope.close();
201       }
202     }
203   }
204 
205   @Override
206   public int run(String[] args) throws Exception {
207     Path rootRegionDir = null;
208     int numThreads = 1;
209     long numIterations = 1000000;
210     int numFamilies = 1;
211     int syncInterval = 0;
212     boolean noSync = false;
213     boolean verify = false;
214     boolean verbose = false;
215     boolean cleanup = true;
216     boolean noclosefs = false;
217     long roll = Long.MAX_VALUE;
218     boolean compress = false;
219     String cipher = null;
220     int numRegions = 1;
221     String spanReceivers = getConf().get("hbase.trace.spanreceiver.classes");
222     boolean trace = spanReceivers != null && !spanReceivers.isEmpty();
223     double traceFreq = 1.0;
224     // Process command line args
225     for (int i = 0; i < args.length; i++) {
226       String cmd = args[i];
227       try {
228         if (cmd.equals("-threads")) {
229           numThreads = Integer.parseInt(args[++i]);
230         } else if (cmd.equals("-iterations")) {
231           numIterations = Long.parseLong(args[++i]);
232         } else if (cmd.equals("-path")) {
233           rootRegionDir = new Path(args[++i]);
234         } else if (cmd.equals("-families")) {
235           numFamilies = Integer.parseInt(args[++i]);
236         } else if (cmd.equals("-qualifiers")) {
237           numQualifiers = Integer.parseInt(args[++i]);
238         } else if (cmd.equals("-keySize")) {
239           keySize = Integer.parseInt(args[++i]);
240         } else if (cmd.equals("-valueSize")) {
241           valueSize = Integer.parseInt(args[++i]);
242         } else if (cmd.equals("-syncInterval")) {
243           syncInterval = Integer.parseInt(args[++i]);
244         } else if (cmd.equals("-nosync")) {
245           noSync = true;
246         } else if (cmd.equals("-verify")) {
247           verify = true;
248         } else if (cmd.equals("-verbose")) {
249           verbose = true;
250         } else if (cmd.equals("-nocleanup")) {
251           cleanup = false;
252         } else if (cmd.equals("-noclosefs")) {
253           noclosefs = true;
254         } else if (cmd.equals("-roll")) {
255           roll = Long.parseLong(args[++i]);
256         } else if (cmd.equals("-compress")) {
257           compress = true;
258         } else if (cmd.equals("-encryption")) {
259           cipher = args[++i];
260         } else if (cmd.equals("-regions")) {
261           numRegions = Integer.parseInt(args[++i]);
262         } else if (cmd.equals("-traceFreq")) {
263           traceFreq = Double.parseDouble(args[++i]);
264         } else if (cmd.equals("-h")) {
265           printUsageAndExit();
266         } else if (cmd.equals("--help")) {
267           printUsageAndExit();
268         } else {
269           System.err.println("UNEXPECTED: " + cmd);
270           printUsageAndExit();
271         }
272       } catch (Exception e) {
273         printUsageAndExit();
274       }
275     }
276 
277     if (compress) {
278       Configuration conf = getConf();
279       conf.setBoolean(HConstants.ENABLE_WAL_COMPRESSION, true);
280     }
281 
282     if (cipher != null) {
283       // Set up WAL for encryption
284       Configuration conf = getConf();
285       conf.set(HConstants.CRYPTO_KEYPROVIDER_CONF_KEY, KeyProviderForTesting.class.getName());
286       conf.set(HConstants.CRYPTO_MASTERKEY_NAME_CONF_KEY, "hbase");
287       conf.setClass("hbase.regionserver.hlog.reader.impl", SecureProtobufLogReader.class,
288         WAL.Reader.class);
289       conf.setClass("hbase.regionserver.hlog.writer.impl", SecureProtobufLogWriter.class,
290         Writer.class);
291       conf.setBoolean(HConstants.ENABLE_WAL_ENCRYPTION, true);
292       conf.set(HConstants.CRYPTO_WAL_ALGORITHM_CONF_KEY, cipher);
293     }
294 
295     if (numThreads < numRegions) {
296       LOG.warn("Number of threads is less than the number of regions; some regions will sit idle.");
297     }
298 
299     // Internal config. goes off number of threads; if more threads than handlers, stuff breaks.
300     // In regionserver, number of handlers == number of threads.
301     getConf().setInt(HConstants.REGION_SERVER_HANDLER_COUNT, numThreads);
302 
303     // Run WAL Performance Evaluation
304     // First set the fs from configs.  In case we are on hadoop1
305     FSUtils.setFsDefault(getConf(), FSUtils.getRootDir(getConf()));
306     FileSystem fs = FileSystem.get(getConf());
307     LOG.info("FileSystem: " + fs);
308 
309     SpanReceiverHost receiverHost = trace ? SpanReceiverHost.getInstance(getConf()) : null;
310     TraceScope scope = Trace.startSpan("WALPerfEval", trace ? Sampler.ALWAYS : Sampler.NEVER);
311 
312     try {
313       if (rootRegionDir == null) {
314         rootRegionDir = TEST_UTIL.getDataTestDirOnTestFS("WALPerformanceEvaluation");
315       }
316       rootRegionDir = rootRegionDir.makeQualified(fs);
317       cleanRegionRootDir(fs, rootRegionDir);
318       FSUtils.setRootDir(getConf(), rootRegionDir);
319       final WALFactory wals = new WALFactory(getConf(), null, "wals");
320       final HRegion[] regions = new HRegion[numRegions];
321       final Runnable[] benchmarks = new Runnable[numRegions];
322       final MockRegionServerServices mockServices = new MockRegionServerServices(getConf());
323       final LogRoller roller = new LogRoller(mockServices, mockServices);
324       Threads.setDaemonThreadRunning(roller.getThread(), "WALPerfEval.logRoller");
325 
326       try {
327         for(int i = 0; i < numRegions; i++) {
328           // Initialize Table Descriptor
329           // a table per desired region means we can avoid carving up the key space
330           final HTableDescriptor htd = createHTableDescriptor(i, numFamilies);
331           regions[i] = openRegion(fs, rootRegionDir, htd, wals, roll, roller);
332           benchmarks[i] = Trace.wrap(new WALPutBenchmark(regions[i], htd, numIterations, noSync,
333               syncInterval, traceFreq));
334         }
335         ConsoleReporter.enable(this.metrics, 30, TimeUnit.SECONDS);
336         long putTime = runBenchmark(benchmarks, numThreads);
337         logBenchmarkResult("Summary: threads=" + numThreads + ", iterations=" + numIterations +
338           ", syncInterval=" + syncInterval, numIterations * numThreads, putTime);
339         
340         for (int i = 0; i < numRegions; i++) {
341           if (regions[i] != null) {
342             closeRegion(regions[i]);
343             regions[i] = null;
344           }
345         }
346         if (verify) {
347           LOG.info("verifying written log entries.");
348           Path dir = new Path(FSUtils.getRootDir(getConf()),
349               DefaultWALProvider.getWALDirectoryName("wals"));
350           long editCount = 0;
351           FileStatus [] fsss = fs.listStatus(dir);
352           if (fsss.length == 0) throw new IllegalStateException("No WAL found");
353           for (FileStatus fss: fsss) {
354             Path p = fss.getPath();
355             if (!fs.exists(p)) throw new IllegalStateException(p.toString());
356             editCount += verify(wals, p, verbose);
357           }
358           long expected = numIterations * numThreads;
359           if (editCount != expected) {
360             throw new IllegalStateException("Counted=" + editCount + ", expected=" + expected);
361           }
362         }
363       } finally {
364         mockServices.stop("test clean up.");
365         for (int i = 0; i < numRegions; i++) {
366           if (regions[i] != null) {
367             closeRegion(regions[i]);
368           }
369         }
370         if (null != roller) {
371           LOG.info("shutting down log roller.");
372           Threads.shutdown(roller.getThread());
373         }
374         wals.shutdown();
375         // Remove the root dir for this test region
376         if (cleanup) cleanRegionRootDir(fs, rootRegionDir);
377       }
378     } finally {
379       // We may be called inside a test that wants to keep on using the fs.
380       if (!noclosefs) fs.close();
381       scope.close();
382       if (receiverHost != null) receiverHost.closeReceivers();
383     }
384 
385     return(0);
386   }
387 
388   private static HTableDescriptor createHTableDescriptor(final int regionNum,
389       final int numFamilies) {
390     HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(TABLE_NAME + ":" + regionNum));
391     for (int i = 0; i < numFamilies; ++i) {
392       HColumnDescriptor colDef = new HColumnDescriptor(FAMILY_PREFIX + i);
393       htd.addFamily(colDef);
394     }
395     return htd;
396   }
397 
398   /**
399    * Verify the content of the WAL file.
400    * Verify that the file has expected number of edits.
401    * @param wals may not be null
402    * @param wal
403    * @return Count of edits.
404    * @throws IOException
405    */
406   private long verify(final WALFactory wals, final Path wal, final boolean verbose)
407       throws IOException {
408     WAL.Reader reader = wals.createReader(wal.getFileSystem(getConf()), wal);
409     long count = 0;
410     Map<String, Long> sequenceIds = new HashMap<String, Long>();
411     try {
412       while (true) {
413         WAL.Entry e = reader.next();
414         if (e == null) {
415           LOG.debug("Read count=" + count + " from " + wal);
416           break;
417         }
418         count++;
419         long seqid = e.getKey().getLogSeqNum();
420         if (sequenceIds.containsKey(Bytes.toString(e.getKey().getEncodedRegionName()))) {
421           // sequenceIds should be increasing for every regions
422           if (sequenceIds.get(Bytes.toString(e.getKey().getEncodedRegionName())) >= seqid) {
423             throw new IllegalStateException("wal = " + wal.getName() + ", " + "previous seqid = "
424                 + sequenceIds.get(Bytes.toString(e.getKey().getEncodedRegionName()))
425                 + ", current seqid = " + seqid);
426           }
427         }
428         // update the sequence Id.
429         sequenceIds.put(Bytes.toString(e.getKey().getEncodedRegionName()), seqid);
430         if (verbose) LOG.info("seqid=" + seqid);
431       }
432     } finally {
433       reader.close();
434     }
435     return count;
436   }
437 
438   private static void logBenchmarkResult(String testName, long numTests, long totalTime) {
439     float tsec = totalTime / 1000.0f;
440     LOG.info(String.format("%s took %.3fs %.3fops/s", testName, tsec, numTests / tsec));
441     
442   }
443 
444   private void printUsageAndExit() {
445     System.err.printf("Usage: bin/hbase %s [options]\n", getClass().getName());
446     System.err.println(" where [options] are:");
447     System.err.println("  -h|-help         Show this help and exit.");
448     System.err.println("  -threads <N>     Number of threads writing on the WAL.");
449     System.err.println("  -regions <N>     Number of regions to open in the WAL. Default: 1");
450     System.err.println("  -iterations <N>  Number of iterations per thread.");
451     System.err.println("  -path <PATH>     Path where region's root directory is created.");
452     System.err.println("  -families <N>    Number of column families to write.");
453     System.err.println("  -qualifiers <N>  Number of qualifiers to write.");
454     System.err.println("  -keySize <N>     Row key size in byte.");
455     System.err.println("  -valueSize <N>   Row/Col value size in byte.");
456     System.err.println("  -nocleanup       Do NOT remove test data when done.");
457     System.err.println("  -noclosefs       Do NOT close the filesystem when done.");
458     System.err.println("  -nosync          Append without syncing");
459     System.err.println("  -syncInterval <N> Append N edits and then sync. " +
460       "Default=0, i.e. sync every edit.");
461     System.err.println("  -verify          Verify edits written in sequence");
462     System.err.println("  -verbose         Output extra info; " +
463       "e.g. all edit seq ids when verifying");
464     System.err.println("  -roll <N>        Roll the way every N appends");
465     System.err.println("  -encryption <A>  Encrypt the WAL with algorithm A, e.g. AES");
466     System.err.println("  -traceFreq <N>   Rate of trace sampling. Default: 1.0, " +
467       "only respected when tracing is enabled, ie -Dhbase.trace.spanreceiver.classes=...");
468     System.err.println("");
469     System.err.println("Examples:");
470     System.err.println("");
471     System.err.println(" To run 100 threads on hdfs with log rolling every 10k edits and " +
472       "verification afterward do:");
473     System.err.println(" $ ./bin/hbase org.apache.hadoop.hbase.wal." +
474       "WALPerformanceEvaluation \\");
475     System.err.println("    -conf ./core-site.xml -path hdfs://example.org:7000/tmp " +
476       "-threads 100 -roll 10000 -verify");
477     System.exit(1);
478   }
479 
480   private final Set<WAL> walsListenedTo = new HashSet<WAL>();
481 
482   private HRegion openRegion(final FileSystem fs, final Path dir, final HTableDescriptor htd,
483       final WALFactory wals, final long whenToRoll, final LogRoller roller) throws IOException {
484     // Initialize HRegion
485     HRegionInfo regionInfo = new HRegionInfo(htd.getTableName());
486     // Initialize WAL
487     final WAL wal = wals.getWAL(regionInfo.getEncodedNameAsBytes());
488     // If we haven't already, attach a listener to this wal to handle rolls and metrics.
489     if (walsListenedTo.add(wal)) {
490       roller.addWAL(wal);
491       wal.registerWALActionsListener(new WALActionsListener.Base() {
492         private int appends = 0;
493 
494         @Override
495         public void visitLogEntryBeforeWrite(HTableDescriptor htd, WALKey logKey,
496             WALEdit logEdit) {
497           this.appends++;
498           if (this.appends % whenToRoll == 0) {
499             LOG.info("Rolling after " + appends + " edits");
500             // We used to do explicit call to rollWriter but changed it to a request
501             // to avoid dead lock (there are less threads going on in this class than
502             // in the regionserver -- regionserver does not have the issue).
503             DefaultWALProvider.requestLogRoll(wal);
504           }
505         }
506 
507         @Override
508         public void postSync(final long timeInNanos, final int handlerSyncs) {
509           syncMeter.mark();
510           syncHistogram.update(timeInNanos);
511           syncCountHistogram.update(handlerSyncs);
512         }
513 
514         @Override
515         public void postAppend(final long size, final long elapsedTime) {
516           appendMeter.mark(size);
517         }
518       });
519     }
520      
521     return HRegion.createHRegion(regionInfo, dir, getConf(), htd, wal);
522   }
523 
524   private void closeRegion(final HRegion region) throws IOException {
525     if (region != null) {
526       region.close();
527       WAL wal = region.getWAL();
528       if (wal != null) {
529         wal.shutdown();
530       }
531     }
532   }
533 
534   private void cleanRegionRootDir(final FileSystem fs, final Path dir) throws IOException {
535     if (fs.exists(dir)) {
536       fs.delete(dir, true);
537     }
538   }
539 
540   private Put setupPut(Random rand, byte[] key, byte[] value, final int numFamilies) {
541     rand.nextBytes(key);
542     Put put = new Put(key);
543     for (int cf = 0; cf < numFamilies; ++cf) {
544       for (int q = 0; q < numQualifiers; ++q) {
545         rand.nextBytes(value);
546         put.add(Bytes.toBytes(FAMILY_PREFIX + cf), Bytes.toBytes(QUALIFIER_PREFIX + q), value);
547       }
548     }
549     return put;
550   }
551 
552   private void addFamilyMapToWALEdit(Map<byte[], List<Cell>> familyMap,
553       WALEdit walEdit) {
554     for (List<Cell> edits : familyMap.values()) {
555       for (Cell cell : edits) {
556         walEdit.add(cell);
557       }
558     }
559   }
560 
561   private long runBenchmark(Runnable[] runnable, final int numThreads) throws InterruptedException {
562     Thread[] threads = new Thread[numThreads];
563     long startTime = System.currentTimeMillis();
564     for (int i = 0; i < numThreads; ++i) {
565       threads[i] = new Thread(runnable[i%runnable.length], "t" + i + ",r" + (i%runnable.length));
566       threads[i].start();
567     }
568     for (Thread t : threads) t.join();
569     long endTime = System.currentTimeMillis();
570     return(endTime - startTime);
571   }
572 
573   /**
574    * The guts of the {@link #main} method.
575    * Call this method to avoid the {@link #main(String[])} System.exit.
576    * @param args
577    * @return errCode
578    * @throws Exception
579    */
580   static int innerMain(final Configuration c, final String [] args) throws Exception {
581     return ToolRunner.run(c, new WALPerformanceEvaluation(), args);
582   }
583 
584   public static void main(String[] args) throws Exception {
585      System.exit(innerMain(HBaseConfiguration.create(), args));
586   }
587 }