Class YarnCentralTaskRollingLogAppender

  • All Implemented Interfaces:
    java.io.Flushable, org.apache.hadoop.fs.Syncable, org.apache.log4j.Appender, org.apache.log4j.spi.OptionHandler

    public class YarnCentralTaskRollingLogAppender
    extends YarnCentralTaskLogAppender
    RollingLogAppender for YARN tasks. This code is copied from MaprfsRollingLogAppender. In order to make it work for Hadoop, we need to reuse the logic in YarnCentralTaskLogAppender#activateOptions. Since we cannot inherit from 2 classes, and the code is fairly small, we did not refactor.
    • Field Detail

      • maxFileSize

        protected long maxFileSize
        The default maximum file size is 10MB.
      • maxBackupIndex

        protected int maxBackupIndex
        There is one backup file by default.
    • Constructor Detail

      • YarnCentralTaskRollingLogAppender

        public YarnCentralTaskRollingLogAppender()
    • Method Detail

      • getFileSizeLimit

        protected java.lang.Long getFileSizeLimit()
        This method is overridden to disable the max event based log file truncation in CentralTaskLogAppender. The file size limit is taken care by this rolling appender.
        Overrides:
        getFileSizeLimit in class YarnCentralTaskLogAppender
      • getMaxBackupIndex

        public int getMaxBackupIndex()
        Returns the value of the MaxBackupIndex option.
      • getMaximumFileSize

        public long getMaximumFileSize()
        Get the maximum size that the output file is allowed to reach before being rolled over to backup files.
      • setMaxBackupIndex

        public void setMaxBackupIndex​(int maxBackups)
        Set the maximum number of backup files to keep around.

        The MaxBackupIndex option determines how many backup files are kept before the oldest is erased. This option takes a positive integer value. If set to zero, then there will be no backup files and the log file will be truncated when it reaches MaxFileSize.

      • setMaximumFileSize

        public void setMaximumFileSize​(long maxFileSize)
        Set the maximum size that the output file is allowed to reach before being rolled over to backup files.

        This method is equivalent to setMaxFileSize(java.lang.String) except that it is required for differentiating the setter taking a long argument from the setter taking a String argument by the JavaBeans Introspector.

        See Also:
        setMaxFileSize(String)
      • setMaxFileSize

        public void setMaxFileSize​(java.lang.String value)
        Set the maximum size that the output file is allowed to reach before being rolled over to backup files.

        In configuration files, the MaxFileSize option takes an long integer in the range 0 - 2^63. You can specify the value with the suffixes "KB", "MB" or "GB" so that the integer is interpreted being expressed respectively in kilobytes, megabytes or gigabytes. For example, the value "10KB" will be interpreted as 10240.