Class: LogStash::Outputs::Gemfire

Inherits:
Base
  • Object
show all
Defined in:
lib/logstash/outputs/gemfire.rb

Overview

Push events to a GemFire region.

GemFire is an object database.

To use this plugin you need to add gemfire.jar to your CLASSPATH; using format=json requires jackson.jar too.

Note: this plugin has only been tested with GemFire 7.0.

Instance Method Summary collapse

Instance Method Details

#closeObject



94
95
96
97
# File 'lib/logstash/outputs/gemfire.rb', line 94

def close
  @cache.close if @cache
  @cache = nil
end

#connectObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/logstash/outputs/gemfire.rb', line 54

def connect
  begin
    @logger.debug("Connecting to GemFire #{@cache_name}")

    @cache = ClientCacheFactory.new.
      set("name", @cache_name).
      set("cache-xml-file", @cache_xml_file).create
    @logger.debug("Created cache #{@cache.inspect}")

  rescue => e
    @logger.error("Gemfire connection error (during connect), will reconnect",
            :exception => e, :backtrace => e.backtrace)
    Stud.stoppable_sleep(1) { stop? }
    retry if !stop?
  end

  @region = @cache.getRegion(@region_name);
  @logger.debug("Created region #{@region.inspect}")
end

#receive(event) ⇒ Object



75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/logstash/outputs/gemfire.rb', line 75

def receive(event)
  

  @logger.debug("Sending event", :destination => to_s, :event => event)

  key = event.sprintf @key_format

  message = JSONFormatter.fromJSON(event.to_json)

  @logger.debug("Publishing message", { :destination => to_s, :message => message, :key => key })
  @region.put(key, message)
end

#registerObject



45
46
47
48
49
50
51
# File 'lib/logstash/outputs/gemfire.rb', line 45

def register
  import com.gemstone.gemfire.cache.client.ClientCacheFactory
  import com.gemstone.gemfire.pdx.JSONFormatter

  @logger.info("Registering output", :plugin => self)
  connect
end

#to_sObject



89
90
91
# File 'lib/logstash/outputs/gemfire.rb', line 89

def to_s
  return "gemfire://#{cache_name}"
end