Class AbstractLogStreamHandler
java.lang.Object
kieker.monitoring.writer.filesystem.AbstractLogStreamHandler
- Direct Known Subclasses:
BinaryLogStreamHandler
,TextLogStreamHandler
public abstract class AbstractLogStreamHandler
extends java.lang.Object
Abstract class for log stream handler. As log stream handler share a lot of functionality,
we use an abstract class instead of an interface to define the API and
implement common functionality.
- Since:
- 1.14
- Author:
- Reiner Jung
-
Field Summary
Fields Modifier and Type Field Description protected java.nio.charset.Charset
charset
protected ICompressionFilter
compressionFilter
protected java.lang.String
extension
protected boolean
flushLogFile
protected int
numOfBytes
protected int
numOfEntries
protected java.nio.channels.WritableByteChannel
outputChannel
protected java.io.OutputStream
serializedStream
protected IValueSerializer
serializer
protected WriterRegistry
writerRegistry
-
Constructor Summary
Constructors Constructor Description AbstractLogStreamHandler(java.lang.Boolean flushLogFile, java.lang.Integer bufferSize, java.nio.charset.Charset charset, ICompressionFilter compressionFilter, WriterRegistry writerRegistry)
Create an abstract log stream handler. -
Method Summary
Modifier and Type Method Description void
close()
Close the log file.java.lang.String
getFileExtension()
Get the file extension for the stream.long
getNumOfBytes()
Return the number of written bytes.int
getNumOfEntries()
Return the number of written entries.void
initialize(java.io.OutputStream serializedOutputStream, java.nio.file.Path fileName)
Initialize a new stream.abstract void
serialize(IMonitoringRecord record, int id)
Serialize a record.
-
Field Details
-
flushLogFile
protected final boolean flushLogFile -
compressionFilter
-
numOfEntries
protected int numOfEntries -
writerRegistry
-
charset
protected final java.nio.charset.Charset charset -
serializer
-
serializedStream
protected java.io.OutputStream serializedStream -
outputChannel
protected java.nio.channels.WritableByteChannel outputChannel -
numOfBytes
protected int numOfBytes -
extension
protected java.lang.String extension
-
-
Constructor Details
-
AbstractLogStreamHandler
public AbstractLogStreamHandler(java.lang.Boolean flushLogFile, java.lang.Integer bufferSize, java.nio.charset.Charset charset, ICompressionFilter compressionFilter, WriterRegistry writerRegistry)Create an abstract log stream handler.- Parameters:
flushLogFile
- flag indicating whether the file should be flushed after every written recordbufferSize
- buffer sizercharset
- character set used for serializationcompressionFilter
- compression filterwriterRegistry
- string registry
-
-
Method Details
-
initialize
public void initialize(java.io.OutputStream serializedOutputStream, java.nio.file.Path fileName) throws java.io.IOExceptionInitialize a new stream.- Parameters:
serializedOutputStream
- stream to be usedfileName
- file name of the stream, this is used by some compression filters- Throws:
java.io.IOException
- when the creation of the channel fails
-
getNumOfEntries
public int getNumOfEntries()Return the number of written entries.- Returns:
- number of entries
-
getNumOfBytes
public long getNumOfBytes()Return the number of written bytes.- Returns:
- number of bytes
-
close
public void close() throws java.io.IOExceptionClose the log file.- Throws:
java.io.IOException
- on io error
-
getFileExtension
public java.lang.String getFileExtension()Get the file extension for the stream.- Returns:
- return the file extension
-
serialize
Serialize a record.- Parameters:
record
- the record itselfid
- the type id from the string registry- Throws:
java.io.IOException
- on io errors, e.g., write errors
-