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)



539
540
541
542
543
544
545
546
547
548
549
550
# File 'lib/logstash/codecs/netflow.rb', line 539

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)


580
581
582
583
584
# File 'lib/logstash/codecs/netflow.rb', line 580

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



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

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)


567
568
569
570
571
# File 'lib/logstash/codecs/netflow.rb', line 567

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