示例#1
0
文件: Log.java 项目: AbacusHu/OpenDJ
 private boolean mustRotate(LogFile<K, V> headLogFile) {
   if (lastAppendedKey == null) {
     // never rotate an empty file
     return false;
   }
   if (headLogFile.getSizeInBytes() > sizeLimitPerLogFileInBytes) {
     // rotate because file size exceeded threshold
     logger.trace(
         "Rotate log %s due to size: %s", logPath.getPath(), headLogFile.getSizeInBytes());
     return true;
   }
   if (rotationIntervalInMillis > 0) {
     // rotate if time limit is reached
     final long timeElapsed = timeService.since(lastRotationTime);
     boolean shouldRotate = timeElapsed > rotationIntervalInMillis;
     if (shouldRotate) {
       logger.trace(
           "Rotate log %s due to time: time elapsed %s, rotation interval: %s",
           logPath.getPath(), timeElapsed, rotationIntervalInMillis);
     }
     return shouldRotate;
   }
   return false;
 }