private void fsyncImpl(Result<Boolean> result,FsyncType fsyncType){
  try {
    flushData();
    ArrayList<SegmentFsyncCallback> fsyncListeners=new ArrayList<>(_fsyncListeners);
    _fsyncListeners.clear();
    Result<Boolean> resultNext=result.then(null);
    if (_isDirty || !fsyncType.isSchedule()) {
      _isDirty=false;
      try (OutStore sOut=_readWrite.openWrite(_segment.extent())){
        if (fsyncType.isSchedule()) {
          sOut.fsyncSchedule(resultNext);
        }
 else {
          sOut.fsync(resultNext);
        }
      }
     }
 else {
      resultNext.ok(true);
    }
  }
 catch (  Throwable e) {
    e.printStackTrace();
    result.fail(e);
  }
}

private void fsyncImpl ( Result < Boolean > result , FsyncType fsyncType ) { try { flushData ( ) ; ArrayList < SegmentFsyncCallback > fsyncListeners = new ArrayList < > ( _fsyncListeners ) ; _fsyncListeners . clear ( ) ; Result < Boolean > resultNext = result . then ( null ) ; if ( _isDirty || ! fsyncType . isSchedule ( ) ) { _isDirty = false ; try ( OutStore sOut = _readWrite . openWrite ( _segment . extent ( ) ) ) { if ( fsyncType . isSchedule ( ) ) { sOut . fsyncSchedule ( resultNext ) ; } else { sOut . fsync ( resultNext ) ; } } } else { resultNext . ok ( true ) ; } } catch ( Throwable e ) { e . printStackTrace ( ) ; result . fail ( e ) ; } }
syncs the segment to the disk . after the segment ' s data is synced , the headers can be written . a second sync is needed to complete the header writes .
