public void krfFileCreate() throws IOException {
    // this method is only used by offline compaction. validating will not
    // create krf
    assert (!getParent().isValidating());

    krf.f = new File(diskFile.getPath() + KRF_FILE_EXT);
    if (krf.f.exists()) {
      throw new IllegalStateException("krf file " + krf.f + " already exists.");
    }
    krf.fos = new FileOutputStream(krf.f);
    krf.bos = new BufferedOutputStream(krf.fos, 32768);
    krf.dos = new DataOutputStream(krf.bos);

    // write oplog magic seq
    krf.dos.writeByte(OPLOG_MAGIC_SEQ_ID);
    krf.dos.write(Oplog.OPLOG_TYPE.KRF.getBytes(), 0, Oplog.OPLOG_TYPE.getLen());
    krf.dos.writeByte(END_OF_RECORD_ID);

    // write the disk store id to the krf
    krf.dos.writeByte(OPLOG_DISK_STORE_ID);
    krf.dos.writeLong(getParent().getDiskStoreID().getLeastSignificantBits());
    krf.dos.writeLong(getParent().getDiskStoreID().getMostSignificantBits());
    krf.dos.writeByte(END_OF_RECORD_ID);

    // write product versions
    assert gfversion != null;
    // write both gemfire and data versions if the two are different else write
    // only gemfire version; a token distinguishes the two cases while reading
    // like in writeGemFireVersionRecord
    KnownVersion dataVersion = getDataVersionIfOld();
    if (dataVersion == null) {
      dataVersion = KnownVersion.CURRENT;
    }
    if (gfversion == dataVersion) {
      VersioningIO.writeOrdinal(krf.dos, gfversion.ordinal(), false);
    } else {
      VersioningIO.writeOrdinal(krf.dos, KnownVersion.TOKEN.ordinal(), false);
      krf.dos.writeByte(END_OF_RECORD_ID);
      krf.dos.writeByte(OPLOG_GEMFIRE_VERSION);
      VersioningIO.writeOrdinal(krf.dos, gfversion.ordinal(), false);
      krf.dos.writeByte(END_OF_RECORD_ID);
      krf.dos.writeByte(OPLOG_GEMFIRE_VERSION);
      VersioningIO.writeOrdinal(krf.dos, dataVersion.ordinal(), false);
    }
    krf.dos.writeByte(END_OF_RECORD_ID);

    // Write the total entry count to the krf so that when we recover,
    // our compaction statistics will be accurate
    InternalDataSerializer.writeUnsignedVL(totalCount.get(), krf.dos);
    krf.dos.writeByte(END_OF_RECORD_ID);

    // Write the RVV to the krf.
    Map<Long, AbstractDiskRegion> drMap = getParent().getAllDiskRegions();
    byte[] rvvBytes = serializeRVVs(drMap, false);
    krf.dos.write(rvvBytes);
    krf.dos.writeByte(END_OF_RECORD_ID);
  }
Schedule a task to create a krf asynchronously
geode-core/src/main/java/org/apache/geode/internal/cache/Oplog.java