class OkComputer::SolrCheck

This class performs a health check on Solr instance using the admin/ping handler.

Attributes

host[R]

Public Class Methods

new(host, request_timeout = 5) click to toggle source

Public: Initialize a new Solr check.

host - The hostname of Solr request_timeout - How long to wait to connect before timing out. Defaults to 5 seconds.

Calls superclass method OkComputer::HttpCheck::new
# File lib/ok_computer/built_in_checks/solr_check.rb, line 11
def initialize(host, request_timeout = 5)
  @host = URI(host)
  super("#{host}/admin/ping", request_timeout)
end

Public Instance Methods

check() click to toggle source

Public: Return the status of Solr

# File lib/ok_computer/built_in_checks/solr_check.rb, line 17
def check
  if ping?
    mark_message "Solr ping reported success"
  else
    mark_failure
    mark_message "Solr ping reported failure"
  end
rescue => e
  mark_failure
  mark_message "Error: '#{e}'"
end
ping?() click to toggle source

Public: Returns true if Solr's ping returned OK, otherwise false

# File lib/ok_computer/built_in_checks/solr_check.rb, line 30
def ping?
  response = perform_request
  !!(response =~ Regexp.union(%r(<str name="status">OK</str>), %r("status":"OK")))
end