Class WriterRunnable

  • All Implemented Interfaces:
    Runnable

    public class WriterRunnable
    extends Object
    implements Runnable
    WriterRunnable is scheduled by the executor in the engine context every writing period.
    Author:
    Luofeng Li
    • Constructor Detail

      • WriterRunnable

        public WriterRunnable​(ConfigService configservice)
        the constructor
        Parameters:
        configservice - the configservice used by this WriterRunnable
    • Method Detail

      • addChannel

        public void addChannel​(ArchiveChannel channel)
        Add a channel's buffer that this thread reads
        Parameters:
        channel - ArchiveChannel
      • removeChannel

        public void removeChannel​(String channelName)
        remove one sample buffer from the buffer hash map. At the same time. it also removes the channel from the channel hash map in the engine context
        Parameters:
        channelName - the name of the channel who and whose sample buffer are removed
      • setWritingPeriod

        public double setWritingPeriod​(double write_period)
        set the writing period. when the writing period is at least 10 seonds. When write_period < 10 , the writing period is 10 seconds actually.
        Parameters:
        write_period - the writing period in second
        Returns:
        the actual writing period in second
      • run

        public void run()
        Specified by:
        run in interface Runnable
      • flushBuffer

        public void flushBuffer()
                         throws Exception
        flush out the sample buffer to the short term storage before shutting down the engine
        Throws:
        Exception - error occurs during writing the sample buffer to the short term storage