Class AbstractLogStreamHandler

java.lang.Object
kieker.monitoring.writer.filesystem.AbstractLogStreamHandler
Direct Known Subclasses:
BinaryLogStreamHandler, TextLogStreamHandler

public abstract class AbstractLogStreamHandler extends 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 Details

    • flushLogFile

      protected final boolean flushLogFile
    • compressionFilter

      protected final ICompressionFilter compressionFilter
    • numOfEntries

      protected int numOfEntries
    • writerRegistry

      protected final WriterRegistry writerRegistry
    • charset

      protected final Charset charset
    • serializer

      protected IValueSerializer serializer
    • serializedStream

      protected OutputStream serializedStream
    • outputChannel

      protected WritableByteChannel outputChannel
    • numOfBytes

      protected int numOfBytes
    • extension

      protected String extension
  • Constructor Details

    • AbstractLogStreamHandler

      public AbstractLogStreamHandler(Boolean flushLogFile, Integer bufferSize, 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 record
      bufferSize - buffer sizer
      charset - character set used for serialization
      compressionFilter - compression filter
      writerRegistry - string registry
  • Method Details

    • initialize

      public void initialize(OutputStream serializedOutputStream, Path fileName) throws IOException
      Initialize a new stream.
      Parameters:
      serializedOutputStream - stream to be used
      fileName - file name of the stream, this is used by some compression filters
      Throws:
      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 IOException
      Close the log file.
      Throws:
      IOException - on io error
    • getFileExtension

      public String getFileExtension()
      Get the file extension for the stream.
      Returns:
      return the file extension
    • serialize

      public abstract void serialize(IMonitoringRecord record, int id) throws IOException
      Serialize a record.
      Parameters:
      record - the record itself
      id - the type id from the string registry
      Throws:
      IOException - on io errors, e.g., write errors