private void doTestThreading(final int numFakeEdits, final int bufferSize,
    final int writerSlowness) throws Exception {

    Configuration localConf = new Configuration(conf);
    localConf.setInt("hbase.regionserver.hlog.splitlog.buffersize", bufferSize);

    // Create a fake log file (we'll override the reader to produce a stream of edits)
    Path logPath = new Path(WALDIR, WAL_FILE_PREFIX + ".fake");
    FSDataOutputStream out = fs.create(logPath);
    out.close();

    // Make region dirs for our destination regions so the output doesn't get skipped
    final List<String> regions = ImmutableList.of("r0", "r1", "r2", "r3", "r4");
    makeRegionDirs(regions);

    // Create a splitter that reads and writes the data without touching disk
    WALSplitter logSplitter = new WALSplitter(wals, localConf, HBASEDIR, fs, HBASEDIR, fs) {
      /* Produce a mock writer that doesn't write anywhere */
      @Override
      protected Writer createWriter(Path logfile) throws IOException {
        Writer mockWriter = Mockito.mock(Writer.class);
        Mockito.doAnswer(new Answer<Void>() {
          int expectedIndex = 0;

          @Override
          public Void answer(InvocationOnMock invocation) {
            if (writerSlowness > 0) {
              try {
                Thread.sleep(writerSlowness);
              } catch (InterruptedException ie) {
                Thread.currentThread().interrupt();
              }
            }
            Entry entry = (Entry) invocation.getArgument(0);
            WALEdit edit = entry.getEdit();
            List<Cell> cells = edit.getCells();
            assertEquals(1, cells.size());
            Cell cell = cells.get(0);

            // Check that the edits come in the right order.
            assertEquals(expectedIndex,
              Bytes.toInt(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength()));
            expectedIndex++;
            return null;
          }
        }).when(mockWriter).append(Mockito.<Entry> any());
        return mockWriter;
      }

      /* Produce a mock reader that generates fake entries */
      @Override
      protected WALStreamReader getReader(FileStatus file, boolean skipErrors,
        CancelableProgressable reporter) throws IOException, CorruptedLogFileException {
        WALStreamReader mockReader = Mockito.mock(WALStreamReader.class);
        Mockito.doAnswer(new Answer<Entry>() {
          int index = 0;

          @Override
          public Entry answer(InvocationOnMock invocation) throws Throwable {
            if (index >= numFakeEdits) {
              return null;
            }

            // Generate r0 through r4 in round robin fashion
            int regionIdx = index % regions.size();
            byte region[] = new byte[] { (byte) 'r', (byte) (0x30 + regionIdx) };

            Entry ret = createTestEntry(TABLE_NAME, region, Bytes.toBytes(index / regions.size()),
              FAMILY, QUALIFIER, VALUE, index);
            index++;
            return ret;
          }
        }).when(mockReader).next();
        return mockReader;
      }
    };

    logSplitter.splitWAL(fs.getFileStatus(logPath), null);

    // Verify number of written edits per region
    Map<String, Long> outputCounts = logSplitter.outputSink.getOutputCounts();
    for (Map.Entry<String, Long> entry : outputCounts.entrySet()) {
      LOG.info("Got " + entry.getValue() + " output edits for region " + entry.getKey());
      assertEquals((long) entry.getValue(), numFakeEdits / regions.size());
    }
    assertEquals("Should have as many outputs as regions", regions.size(), outputCounts.size());
  }
Sets up a log splitter with a mock reader and writer. The mock reader generates a specified
number of edits spread across 5 regions. The mock writer optionally sleeps for each edit it is
fed. After the split is complete, verifies that the statistics show the correct number of edits
output into each region.
@param numFakeEdits   number of fake edits to push through pipeline
@param bufferSize     size of in-memory buffer
@param writerSlowness writer threads will sleep this many ms per edit
hbase-server/src/test/java/org/apache/hadoop/hbase/wal/TestWALSplit.java