private void rolloverLogTask ( ) { try { if ( _isInit ) { flush ( ) ; } } catch ( Exception e ) { log . log ( Level . WARNING , e . toString ( ) , e ) ; } _isRollingOver = true ; try { if ( ! _isInit ) return ; Path savedPath = null ; long now = CurrentTime . currentTime ( ) ; long lastPeriodEnd = _nextPeriodEnd ; _nextPeriodEnd = nextRolloverTime ( now ) ; Path path = getPath ( ) ; synchronized ( _logLock ) { flushTempStream ( ) ; long length = Files . size ( path ) ; if ( lastPeriodEnd <= now && lastPeriodEnd > 0 ) { closeLogStream ( ) ; savedPath = getSavedPath ( lastPeriodEnd - 1 ) ; } else if ( path != null && getRolloverSize ( ) <= length ) { closeLogStream ( ) ; savedPath = getSavedPath ( now ) ; } } // archiving of path is outside of the synchronized block to // avoid freezing during archive if ( savedPath != null ) { movePathToArchive ( savedPath ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } finally { synchronized ( _logLock ) { _isRollingOver = false ; flushTempStream ( ) ; } _rolloverListener . requeue ( _rolloverAlarm ) ; } }
Called from rollover worker