Class: LogStash::Codecs::Netflow::TemplateRegistry

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/codecs/netflow.rb

Instance Method Summary collapse

Constructor Details

#initialize(logger, ttl, file_path = nil) ⇒ TemplateRegistry

Returns a new instance of TemplateRegistry.

Parameters:

  • logger (Logger)
  • ttl (Integer)
  • file_path (String) (defaults to: nil)

    (optional)



548
549
550
551
552
553
554
555
556
557
558
559
# File 'lib/logstash/codecs/netflow.rb', line 548

def initialize(logger, ttl, file_path=nil)
  @logger = logger
  @ttl = Integer(ttl)
  @file_path = file_path

  @mutex = Mutex.new

  @bindata_struct_cache = Vash.new
  @bindata_spec_cache = Vash.new

  do_load unless file_path.nil?
end

Instance Method Details

#fetch(key) ⇒ BinData::Struct

Fetch a Template by name

Parameters:

  • key (String)

Returns:

  • (BinData::Struct)


589
590
591
592
593
# File 'lib/logstash/codecs/netflow.rb', line 589

def fetch(key)
  @mutex.synchronize do
    do_fetch(key)
  end
end

#persistObject

Force persist, potentially cleaning up elements from the file-based cache that have already been evicted from the memory-based cache



598
599
600
601
602
# File 'lib/logstash/codecs/netflow.rb', line 598

def persist()
  @mutex.synchronize do
    do_persist
  end
end

#register(key, field_tuples) {|| ... } ⇒ BinData::Struct

Register a Template by name using an array of type/name tuples.

If a block is given, the template is yielded to the block before being saved in the cache.

Parameters:

  • key (String)

    : the key under which to save this template

  • field_tuples (Array<Array<String>>)

    : an array of [type,name] tuples, e.g., [“uint32”,“fieldName”]

Yield Parameters:

  • (BinData::Struct)

Yield Returns:

  • (void)

Returns:

  • (BinData::Struct)


576
577
578
579
580
# File 'lib/logstash/codecs/netflow.rb', line 576

def register(key, field_tuples, &block)
  @mutex.synchronize do
    do_register(key, field_tuples, &block)
  end
end