Class: IsItWorking::RsolrCheck

Inherits:
Object
  • Object
show all
Defined in:
lib/is_it_working/checks/rsolr_check.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ RsolrCheck

Returns a new instance of RsolrCheck.

Raises:

  • (ArgumentError)


3
4
5
6
7
8
# File 'lib/is_it_working/checks/rsolr_check.rb', line 3

def initialize(options={})
  @client = options[:client]
  raise ArgumentError.new(":client not specified") unless @client
  @host = @client.uri
  @alias = options[:alias] || @host
end

Instance Method Details

#call(status) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/is_it_working/checks/rsolr_check.rb', line 10

def call(status)
  if ping
    status.ok("service active")
    unless luke.empty?
      status.info("numDocs: #{luke['numDocs']}")
      status.info("lastModified: #{luke['lastModified']}")
    end
    registry.each do |name, text|
      status.info("#{name} - #{text}")
    end
  else
    status.fail("service down")
  end
end

#lukeObject



25
26
27
28
29
30
31
# File 'lib/is_it_working/checks/rsolr_check.rb', line 25

def luke
  @luke ||= begin
              @client.luke(:show => 'schema', :numTerms => 0)['index'] 
            rescue
              {}
            end
end

#pingObject



48
49
50
51
52
# File 'lib/is_it_working/checks/rsolr_check.rb', line 48

def ping
  @client.head("admin/ping").response[:status] == 200
rescue
  false
end

#registryObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/is_it_working/checks/rsolr_check.rb', line 33

def registry
  @registry ||= begin
                  resp = @client.get 'admin/registry.jsp', :params => { :wt => 'xml' }
                  doc = Nokogiri::XML resp
                  h = {}
                  doc.xpath('/solr/*').each do |node|
                    next if node.name == "solr-info"
                    h[node.name] = node.text
                  end
                  h
                rescue
                  {}
                end
end