class LogStash::Outputs::Gemfire

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.

Public Instance Methods

connect() click to toggle source
# 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
    if terminating?
      return
    else
      @logger.error("Gemfire connection error (during connect), will reconnect",
                    :exception => e, :backtrace => e.backtrace)
      sleep(1)
      retry
    end
  end

  @region = @cache.getRegion(@region_name);
  @logger.debug("Created region #{@region.inspect}")
end
receive(event) click to toggle source
# File lib/logstash/outputs/gemfire.rb, line 79
def receive(event)
  return unless output?(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
register() click to toggle source
# 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
teardown() click to toggle source
# File lib/logstash/outputs/gemfire.rb, line 98
def teardown
  @cache.close if @cache
  @cache = nil
  finished
end
to_s() click to toggle source
# File lib/logstash/outputs/gemfire.rb, line 93
def to_s
  return "gemfire://#{cache_name}"
end