private HRegion openRegion(final FileSystem fs, final Path dir, final TableDescriptor htd,
    final WALFactory wals, final long whenToRoll, final LogRoller roller) throws IOException {
    // Initialize HRegion
    RegionInfo regionInfo = RegionInfoBuilder.newBuilder(htd.getTableName()).build();
    // Initialize WAL
    final WAL wal = wals.getWAL(regionInfo);
    // If we haven't already, attach a listener to this wal to handle rolls and metrics.
    if (walsListenedTo.add(wal)) {
      roller.addWAL(wal);
      wal.registerWALActionsListener(new WALActionsListener() {
        private int appends = 0;

        @Override
        public void visitLogEntryBeforeWrite(RegionInfo info, WALKey logKey, WALEdit logEdit) {
          this.appends++;
          if (this.appends % whenToRoll == 0) {
            LOG.info("Rolling after " + appends + " edits");
            // We used to do explicit call to rollWriter but changed it to a request
            // to avoid dead lock (there are less threads going on in this class than
            // in the regionserver -- regionserver does not have the issue).
            AbstractFSWALProvider.requestLogRoll(wal);
          }
        }

        @Override
        public void postSync(final long timeInNanos, final int handlerSyncs) {
          syncMeter.mark();
          syncHistogram.update(timeInNanos);
          syncCountHistogram.update(handlerSyncs);
        }

        @Override
        public void postAppend(final long size, final long elapsedTime, final WALKey logkey,
          final WALEdit logEdit) {
          appendMeter.mark(size);
        }
      });
    }

    return HRegion.createHRegion(regionInfo, dir, getConf(), htd, wal);
  }
Verify the content of the WAL file. Verify that the file has expected number of edits.
@param wals may not be null
@return Count of edits.
hbase-diagnostics/src/main/java/org/apache/hadoop/hbase/wal/WALPerformanceEvaluation.java