lib/fluent/plugin/out_datacounter.rb
# Load internal status from a storage
#
# @param [Interger] tick The count interval
Load internal status from a storage
Load internal status from a storage
def load_status(tick)
    stored = @storage.get(:stored_value)
    return unless stored
    begin
      patterns = stored["patterns"].map{|idx, label, regexp|
        if regexp
          [idx, label, Regexp.compile(regexp)]
        else
          [idx, label, regexp]
        end
      }
      if stored["aggregate"] == @aggregate.to_s and
        stored["count_key"] == @count_key and
        patterns == @patterns
        if Fluent::Engine.now <= stored["saved_at"] + tick
          @mutex.synchronize {
            @counts = stored["counts"]
            @saved_at = stored["saved_at"]
            @saved_duration = stored["saved_duration"]
            @last_checked = Fluent::Engine.now - @saved_duration
          }
        else
          log.warn "stored data is outdated. ignore stored data"
        end
      else
        log.warn "configuration param was changed. ignore stored data"
      end
    rescue => e
      log.warn "Can't load store_storage", error: e
    end
  end
def load_status ( tick ) stored = @storage . get ( :stored_value ) return unless stored begin patterns = stored [ "patterns" ] . map { | idx , label , regexp | if regexp [ idx , label , Regexp . compile ( regexp ) ] else [ idx , label , regexp ] end } if stored [ "aggregate" ] == @aggregate . to_s and stored [ "count_key" ] == @count_key and patterns == @patterns if Fluent :: Engine . now <= stored [ "saved_at" ] + tick @mutex . synchronize { @counts = stored [ "counts" ] @saved_at = stored [ "saved_at" ] @saved_duration = stored [ "saved_duration" ] @last_checked = Fluent :: Engine . now - @saved_duration } else log . warn "stored data is outdated. ignore stored data" end else log . warn "configuration param was changed. ignore stored data" end rescue => e log . warn "Can't load store_storage" , error : e end end
Load internal status from a storage
Load internal status from a storage
# skip the saved duration to continue counting
tick
<not_specific>
<not_specific>
tick The count interval
tick The count interval