Class NewtsWriter

  • All Implemented Interfaces:
    com.lmax.disruptor.WorkHandler<SampleBatchEvent>, org.springframework.beans.factory.DisposableBean

    public class NewtsWriter
    extends java.lang.Object
    implements com.lmax.disruptor.WorkHandler<SampleBatchEvent>, org.springframework.beans.factory.DisposableBean
    Used to write samples to the SampleRepository. Calls to #insert() publish the samples to a ring buffer so that they don't block while the data is being persisted.
    Author:
    jwhite
    • Constructor Summary

      Constructors 
      Constructor Description
      NewtsWriter​(java.lang.Integer maxBatchSize, java.lang.Integer ringBufferSize, java.lang.Integer numWriterThreads, com.codahale.metrics.MetricRegistry registry)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void destroy()  
      void index​(java.util.List<org.opennms.newts.api.Sample> samples)  
      void insert​(java.util.List<org.opennms.newts.api.Sample> samples)  
      void onEvent​(SampleBatchEvent event)  
      void setIndexer​(org.opennms.newts.api.search.Indexer indexer)  
      void setSampleRepository​(org.opennms.newts.api.SampleRepository sampleRepository)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • NewtsWriter

        @Inject
        public NewtsWriter​(@Named("newts.max_batch_size")
                           java.lang.Integer maxBatchSize,
                           @Named("newts.ring_buffer_size")
                           java.lang.Integer ringBufferSize,
                           @Named("newts.writer_threads")
                           java.lang.Integer numWriterThreads,
                           @Named("newtsMetricRegistry")
                           com.codahale.metrics.MetricRegistry registry)
    • Method Detail

      • destroy

        public void destroy()
                     throws java.lang.Exception
        Specified by:
        destroy in interface org.springframework.beans.factory.DisposableBean
        Throws:
        java.lang.Exception
      • insert

        public void insert​(java.util.List<org.opennms.newts.api.Sample> samples)
      • index

        public void index​(java.util.List<org.opennms.newts.api.Sample> samples)
      • onEvent

        public void onEvent​(SampleBatchEvent event)
                     throws java.lang.Exception
        Specified by:
        onEvent in interface com.lmax.disruptor.WorkHandler<SampleBatchEvent>
        Throws:
        java.lang.Exception
      • setSampleRepository

        public void setSampleRepository​(org.opennms.newts.api.SampleRepository sampleRepository)
      • setIndexer

        public void setIndexer​(org.opennms.newts.api.search.Indexer indexer)