Class: Rays::Server::SolrServer

Inherits:
BaseServer show all
Defined in:
lib/rays/servers/solr.rb

Instance Attribute Summary collapse

Attributes inherited from BaseServer

#name

Instance Method Summary collapse

Methods inherited from BaseServer

#host, #java_cmd, #java_home, #remote, #remote?

Constructor Details

#initialize(name, host, remote, java_home, java_bin, port, url, application_service) ⇒ SolrServer

Returns a new instance of SolrServer.



30
31
32
33
34
35
36
# File 'lib/rays/servers/solr.rb', line 30

def initialize(name, host, remote, java_home, java_bin, port, url, application_service)
  super(name, host, remote, java_home, java_bin)
  @port = port
  @url = url
  @solr_instance = RSolr.connect(:url => solr_url)
  @service = application_service
end

Instance Attribute Details

#solr_instanceObject (readonly)

Returns the value of attribute solr_instance.



28
29
30
# File 'lib/rays/servers/solr.rb', line 28

def solr_instance
  @solr_instance
end

Instance Method Details

#alive?Boolean

Returns:

  • (Boolean)


53
54
55
56
57
58
59
60
# File 'lib/rays/servers/solr.rb', line 53

def alive?
  begin
    @solr_instance.get('select', :params => { :q => '*:*', :limit => 1})
    return true
  rescue
    return false
  end
end

#clean_allObject



62
63
64
65
66
# File 'lib/rays/servers/solr.rb', line 62

def clean_all
  solr_transaction do
    @solr_instance.delete_by_query('*:*')
  end
end

#portObject

Raises:



38
39
40
41
# File 'lib/rays/servers/solr.rb', line 38

def port
  raise RaysException.new(missing_environment_option('SOLR server', 'port')) if @port.nil?
  @port
end

#serviceObject

Raises:



48
49
50
51
# File 'lib/rays/servers/solr.rb', line 48

def service
  raise RaysException.new(missing_environment_option('SOLR service', 'service')) if @service.nil?
  @service
end

#urlObject

Raises:



43
44
45
46
# File 'lib/rays/servers/solr.rb', line 43

def url
  raise RaysException.new(missing_environment_option('SOLR server', 'instance')) if @url.nil?
  @url
end