@Test
  public void testLogRollAfterSplitStart() throws IOException {
    LOG.info("Verify wal roll after split starts will fail.");
    String logName =
      ServerName.valueOf("testLogRollAfterSplitStart", 16010, EnvironmentEdgeManager.currentTime())
        .toString();
    Path thisTestsDir = new Path(HBASELOGDIR, AbstractFSWALProvider.getWALDirectoryName(logName));
    final WALFactory wals = new WALFactory(conf, logName);

    try {
      // put some entries in an WAL
      TableName tableName = TableName.valueOf(this.getClass().getName());
      RegionInfo regionInfo = RegionInfoBuilder.newBuilder(tableName).build();
      WAL log = wals.getWAL(regionInfo);
      MultiVersionConcurrencyControl mvcc = new MultiVersionConcurrencyControl(1);

      int total = 20;
      for (int i = 0; i < total; i++) {
        WALEdit kvs = new WALEdit();
        WALEditInternalHelper.addExtendedCell(kvs,
          new KeyValue(Bytes.toBytes(i), tableName.getName(), tableName.getName()));
        NavigableMap<byte[], Integer> scopes = new TreeMap<>(Bytes.BYTES_COMPARATOR);
        scopes.put(Bytes.toBytes("column"), 0);
        log.appendData(regionInfo, new WALKeyImpl(regionInfo.getEncodedNameAsBytes(), tableName,
          EnvironmentEdgeManager.currentTime(), mvcc, scopes), kvs);
      }
      // Send the data to HDFS datanodes and close the HDFS writer
      log.sync();
      closeWriter((AbstractFSWAL<?>) log);

      // code taken from MasterFileSystem.getLogDirs(), which is called from
      // MasterFileSystem.splitLog() handles RS shutdowns (as observed by the splitting process)
      // rename the directory so a rogue RS doesn't create more WALs
      Path rsSplitDir = thisTestsDir.suffix(AbstractFSWALProvider.SPLITTING_EXT);
      if (!fs.rename(thisTestsDir, rsSplitDir)) {
        throw new IOException("Failed fs.rename for log split: " + thisTestsDir);
      }
      LOG.debug("Renamed region directory: " + rsSplitDir);

      LOG.debug("Processing the old log files.");
      WALSplitter.split(HBASELOGDIR, rsSplitDir, OLDLOGDIR, fs, conf, wals);

      LOG.debug("Trying to roll the WAL.");
      IOException error = assertThrows(IOException.class, () -> log.rollWriter());
      if (error instanceof RemoteException) {
        error = ((RemoteException) error).unwrapRemoteException();
      }
      assertTrue("unexpected error: " + Throwables.getStackTraceAsString(error),
        error instanceof FileNotFoundException
          || error.getCause() instanceof FileNotFoundException);
    } finally {
      wals.close();
      if (fs.exists(thisTestsDir)) {
        fs.delete(thisTestsDir, true);
      }
    }
  }
Tests the case where a RegionServer enters a GC pause, comes back online after the master
declared it dead and started to split. Want log rolling after a master split to fail. See
HBASE-2312.
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestLogRollAbort.java