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
# File 'lib/is_it_working/checks/rsolr_check.rb', line 10

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

#lukeObject



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

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

#pingObject



46
47
48
49
50
# File 'lib/is_it_working/checks/rsolr_check.rb', line 46

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

#registryObject



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

def registry
  @registry ||= begin
                  resp = Blacklight.solr.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