Package org.spf4j.log
Class AvroDataFileAppender
- java.lang.Object
-
- ch.qos.logback.core.spi.ContextAwareBase
-
- ch.qos.logback.core.UnsynchronizedAppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
-
- org.spf4j.log.AvroDataFileAppender
-
- All Implemented Interfaces:
ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.ILoggingEvent>,ch.qos.logback.core.spi.ContextAware,ch.qos.logback.core.spi.FilterAttachable<ch.qos.logback.classic.spi.ILoggingEvent>,ch.qos.logback.core.spi.LifeCycle
public final class AvroDataFileAppender extends ch.qos.logback.core.UnsynchronizedAppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>an Appender that will log into binary avro data files. Files will be be partition by day. Day boundaries are determined by the provided zone id.- Author:
- Zoltan Farkas
-
-
Constructor Summary
Constructors Constructor Description AvroDataFileAppender()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidappend(ch.qos.logback.classic.spi.ILoggingEvent eventObject)voidcleanup()longflush()PathgetCurrentFile()longgetCurrentFileNrLogs()org.apache.avro.file.FileReader<org.spf4j.base.avro.LogRecord>getCurrentLogs()PathgetDestinationPath()voidgetFilteredLogs(String originPrefix, long ptailOffset, long limit, Predicate<org.spf4j.base.avro.LogRecord> pred, Consumer<org.spf4j.base.avro.LogRecord> records)List<Path>getLogFiles()voidgetLogs(String originPrefix, long ptailOffset, long limit, Consumer<org.spf4j.base.avro.LogRecord> records)longgetNrLogs()static longgetNrLogs(Path file)List<Path>getOldLogFiles()static booleanisValidFile(Path file)static voidreadLogs(org.spf4j.log.AvroDataFileAppender.LogFileRange fileRange, org.apache.avro.io.DatumReader<org.spf4j.base.avro.LogRecord> reader, String originPrefix, Consumer<org.spf4j.base.avro.LogRecord> records)voidsetAppendRetries(int appendRetries)When serializing a object a ConcurrentModificationEnception can be thrown if this is mutated by another thread.voidsetCodec(String codec)voidsetDestinationPath(String destinationPath)voidsetFileNameBase(String fileNameBase)voidsetMaxLogsBytes(long maxLogsBytes)voidsetMaxNrFiles(int maxNrFiles)voidsetPartitionZoneID(String zoneIdStr)static voidskip(org.apache.avro.file.DataFileStream<org.spf4j.base.avro.LogRecord> it, long count)voidstart()voidstop()StringtoString()-
Methods inherited from class ch.qos.logback.core.UnsynchronizedAppenderBase
addFilter, clearAllFilters, doAppend, getCopyOfAttachedFiltersList, getFilterChainDecision, getName, isStarted, setName
-
Methods inherited from class ch.qos.logback.core.spi.ContextAwareBase
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext
-
-
-
-
Method Detail
-
setAppendRetries
public void setAppendRetries(int appendRetries)
When serializing a object a ConcurrentModificationEnception can be thrown if this is mutated by another thread. (async logging) this can re-tried, a few times, and hopefully log this successfully.- Parameters:
appendRetries-
-
setMaxNrFiles
public void setMaxNrFiles(int maxNrFiles)
-
setMaxLogsBytes
public void setMaxLogsBytes(long maxLogsBytes)
-
setCodec
public void setCodec(String codec)
-
setFileNameBase
public void setFileNameBase(String fileNameBase)
-
setDestinationPath
public void setDestinationPath(String destinationPath)
-
setPartitionZoneID
public void setPartitionZoneID(String zoneIdStr)
-
getDestinationPath
public Path getDestinationPath()
-
cleanup
public void cleanup() throws IOException- Throws:
IOException
-
getLogFiles
public List<Path> getLogFiles() throws IOException
- Returns:
- all log files in chronological order.
- Throws:
IOException
-
getOldLogFiles
public List<Path> getOldLogFiles() throws IOException
- Throws:
IOException
-
getCurrentFile
public Path getCurrentFile()
-
flush
public long flush() throws IOException- Throws:
IOException
-
getCurrentFileNrLogs
public long getCurrentFileNrLogs() throws IOException- Throws:
IOException
-
getNrLogs
public long getNrLogs() throws IOException- Throws:
IOException
-
getCurrentLogs
public org.apache.avro.file.FileReader<org.spf4j.base.avro.LogRecord> getCurrentLogs() throws IOException- Throws:
IOException
-
getLogs
public void getLogs(String originPrefix, long ptailOffset, long limit, Consumer<org.spf4j.base.avro.LogRecord> records) throws IOException
- Throws:
IOException
-
readLogs
public static void readLogs(org.spf4j.log.AvroDataFileAppender.LogFileRange fileRange, org.apache.avro.io.DatumReader<org.spf4j.base.avro.LogRecord> reader, String originPrefix, Consumer<org.spf4j.base.avro.LogRecord> records) throws IOException- Throws:
IOException
-
getFilteredLogs
public void getFilteredLogs(String originPrefix, long ptailOffset, long limit, Predicate<org.spf4j.base.avro.LogRecord> pred, Consumer<org.spf4j.base.avro.LogRecord> records) throws IOException
- Throws:
IOException
-
skip
public static void skip(org.apache.avro.file.DataFileStream<org.spf4j.base.avro.LogRecord> it, long count) throws IOException- Throws:
IOException
-
getNrLogs
public static long getNrLogs(Path file) throws IOException
- Throws:
IOException
-
stop
public void stop()
- Specified by:
stopin interfacech.qos.logback.core.spi.LifeCycle- Overrides:
stopin classch.qos.logback.core.UnsynchronizedAppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
-
start
public void start()
- Specified by:
startin interfacech.qos.logback.core.spi.LifeCycle- Overrides:
startin classch.qos.logback.core.UnsynchronizedAppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
-
isValidFile
public static boolean isValidFile(Path file) throws IOException
- Throws:
IOException
-
append
protected void append(ch.qos.logback.classic.spi.ILoggingEvent eventObject)
- Specified by:
appendin classch.qos.logback.core.UnsynchronizedAppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
-
toString
public String toString()
- Overrides:
toStringin classch.qos.logback.core.UnsynchronizedAppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
-
-