fn rotate_imp(&self, active_file: &mut MutexGuard<ActiveFile<F>>) -> Result<()> {
        let _t = StopWatch::new(&LOG_ROTATE_DURATION_HISTOGRAM);
        let seq = active_file.seq + 1;
        debug_assert!(seq > 1);

        active_file.writer.close()?;

        let file_id = FileId {
            queue: self.queue,
            seq,
        };
        let path = file_id.build_file_path(&self.dir);
        let fd = Arc::new(self.file_system.create(&path)?);
        let mut new_file = ActiveFile {
            seq,
            writer: build_file_writer(self.file_system.as_ref(), fd.clone(), self.format_version)?,
        };
        // File header must be persisted. This way we can recover gracefully if power
        // loss before a new entry is written.
        new_file.writer.sync()?;
        self.sync_dir()?;
        let active_file_version = new_file.writer.header.version();
        **active_file = new_file;

        let len = {
            let mut files = self.files.write();
            debug_assert!(files.active_seq + 1 == seq);
            files.active_seq = seq;
            files.fds.push_back(FileHandler {
                handle: fd,
                version: active_file_version,
            });
            for listener in &self.listeners {
                listener.post_new_log_file(FileId {
                    queue: self.queue,
                    seq,
                });
            }
            files.fds.len()
        };
        self.flush_metrics(len);
        Ok(())
    }
/// Creates a new file for write, and rotates the active log file.
///
/// This operation is atomic in face of errors.
Creates a new file for write, and rotates the active log file.
This operation is atomic in face of errors.
Creates a new file for write and rotates the active log file . This operation is atomic in face of errors .
fn rotate_imp(&self, active_file: &mut MutexGuard<ActiveFile<F>>) -> Result<()> {
        let _t = StopWatch::new(&LOG_ROTATE_DURATION_HISTOGRAM);
        let seq = active_file.seq + 1;
        debug_assert!(seq > 1);
        active_file.writer.close()?;
        let file_id = FileId {
            queue: self.queue,
            seq,
        };
        let path = file_id.build_file_path(&self.dir);
        let fd = Arc::new(self.file_system.create(&path)?);
        let mut new_file = ActiveFile {
            seq,
            writer: build_file_writer(self.file_system.as_ref(), fd.clone(), self.format_version)?,
        };
        // File header must be persisted. This way we can recover gracefully if power
        // loss before a new entry is written.
        new_file.writer.sync()?;
        self.sync_dir()?;
        let active_file_version = new_file.writer.header.version();
        **active_file = new_file;
        let len = {
            let mut files = self.files.write();
            debug_assert!(files.active_seq + 1 == seq);
            files.active_seq = seq;
            files.fds.push_back(FileHandler {
                handle: fd,
                version: active_file_version,
            });
            for listener in &self.listeners {
                listener.post_new_log_file(FileId {
                    queue: self.queue,
                    seq,
                });
            }
            files.fds.len()
        };
        self.flush_metrics(len);
        Ok(())
    }
fn rotate_imp ( & self , active_file : & mut MutexGuard < ActiveFile < F > > ) -> Result < ( ) > { let _t = StopWatch :: new ( & LOG_ROTATE_DURATION_HISTOGRAM ) ; let seq = active_file . seq + 1 ; debug_assert ! ( seq 1 ) ; active_file . writer . close ( ) ? ; let file_id = FileId { queue : self . queue , seq , } ; let path = file_id . build_file_path ( & self . dir ) ; let fd = Arc :: new ( self . file_system . create ( & path ) ? ) ; let mut new_file = ActiveFile { seq , writer : build_file_writer ( self . file_system . as_ref ( ) , fd . clone ( ) , self . format_version ) ? , } ; // File header must be persisted. This way we can recover gracefully if power // loss before a new entry is written. new_file . writer . sync ( ) ? ; self . sync_dir ( ) ? ; let active_file_version = new_file . writer . header . version ( ) ; * * active_file = new_file ; let len = { let mut files = self . files . write ( ) ; debug_assert ! ( files active_seq 1 seq ) ; files . active_seq = seq ; files . fds . push_back ( FileHandler { handle : fd , version : active_file_version , } ) ; for listener in & self . listeners { listener . post_new_log_file ( FileId { queue : self . queue , seq , } ) ; } files . fds . len ( ) } ; self . flush_metrics ( len ) ; Ok ( ( ) ) }
Creates a new file for write, and rotates the active log file.
Creates a new file for write and rotates the active log file .
&self
active_file
&mut MutexGuard<ActiveFile<F>>