public void krfClose() {
    boolean allClosed = false;
    try {
      if (krf.fos != null) {
        DataSerializer.writeByteArray(null, krf.dos);
      } else {
        return;
      }

      krf.dos.flush();
      krf.fos.getChannel().force(true);

      krf.dos.close();
      krf.dos = null;
      krf.bos.close();
      krf.bos = null;
      krf.fos.close();
      krf.fos = null;

      if (krf.keyNum == 0) {
        // this is an empty krf file
        krf.f.delete();
        assert !krf.f.exists();
      } else {
        // Mark that this krf is complete.
        getParent().getDiskInitFile().krfCreate(oplogId);
        logger.info("Created {} {} for disk store {}.",
            new Object[] {toString(), "krf", getParent().getName()});
      }

      allClosed = true;
    } catch (IOException e) {
      if (getParent().getDiskAccessException() == null) {
        throw new DiskAccessException("Fail to close krf file " + krf.f, e, getParent());
      } else {
        logger.info(
            "Fail to close krf file " + krf.f + ", but a DiskAccessException happened ealier",
            getParent().getDiskAccessException());
      }
    } finally {
      if (!allClosed) {
        // IOException happened during close, delete this krf
        closeAndDeleteKrf();
      }
    }
  }
Schedule a task to create a krf asynchronously
geode-core/src/main/java/org/apache/geode/internal/cache/Oplog.java