public void write(byte[] data) throws IOException {
    if (data.length > maxFileSize) {
      throw new IOException(
        "Data size " + data.length + " is greater than max allowed size " + maxFileSize);
    }
    long timestamp = Math.max(prevTimestamp + 1, EnvironmentEdgeManager.currentTime());
    write(fs, files[nextFile], timestamp, data);
    prevTimestamp = timestamp;
    nextFile = 1 - nextFile;
    try {
      fs.delete(files[nextFile], false);
    } catch (IOException e) {
      // we will create new file with overwrite = true, so not a big deal here, only for speed up
      // loading as we do not need to read this file when loading
      LOG.debug("Failed to delete old file {}, ignoring the exception", files[nextFile], e);
    }
  }
Writes the given data to the next file in the rotation, with a timestamp calculated based on
the previous timestamp and the current time to make sure it is greater than the previous
timestamp. The method also deletes the previous file, which is no longer needed.
<p/>
Notice that, for a newly created {@link RotateFile} instance, you need to call {@link #read()}
first to initialize the nextFile index, before calling this method.
@param data the data to be written to the file
@throws IOException if an I/O error occurs while writing the data to the file
hbase-client/src/main/java/org/apache/hadoop/hbase/util/RotateFile.java