class SolrWrapper::Settings
Configuraton that comes from static and dynamic sources.
Public Class Methods
new(static_config)
click to toggle source
Calls superclass method
# File lib/solr_wrapper/settings.rb, line 17 def initialize(static_config) super @static_config = static_config end
Public Instance Methods
__getobj__()
click to toggle source
# File lib/solr_wrapper/settings.rb, line 7 def __getobj__ @static_config # return object we are delegating to, required end
Also aliased as: static_config
__setobj__(obj)
click to toggle source
# File lib/solr_wrapper/settings.rb, line 13 def __setobj__(obj) @static_config = obj end
default_download_url()
click to toggle source
# File lib/solr_wrapper/settings.rb, line 82 def default_download_url static_config.mirror_url end
download_url()
click to toggle source
# File lib/solr_wrapper/settings.rb, line 60 def download_url @download_url ||= static_config.url @download_url ||= default_download_url end
host()
click to toggle source
Get the host this Solr instance is bound to
# File lib/solr_wrapper/settings.rb, line 24 def host '127.0.0.1' end
instance_dir()
click to toggle source
# File lib/solr_wrapper/settings.rb, line 51 def instance_dir @instance_dir ||= static_config.instance_dir @instance_dir ||= File.join(tmpdir, File.basename(download_url, ".zip")) end
managed?()
click to toggle source
# File lib/solr_wrapper/settings.rb, line 56 def managed? File.exist?(instance_dir) end
port()
click to toggle source
Get the port this Solr instance is running at
# File lib/solr_wrapper/settings.rb, line 35 def port @port ||= static_config.port @port ||= random_open_port.to_s end
solr_binary()
click to toggle source
# File lib/solr_wrapper/settings.rb, line 74 def solr_binary File.join(instance_dir, "bin", "solr") end
solr_zip_path()
click to toggle source
# File lib/solr_wrapper/settings.rb, line 65 def solr_zip_path @solr_zip_path ||= static_config.solr_zip_path @solr_zip_path ||= default_solr_zip_path end
tmp_save_dir()
click to toggle source
# File lib/solr_wrapper/settings.rb, line 78 def tmp_save_dir @tmp_save_dir ||= Dir.mktmpdir end
url()
click to toggle source
Get a (likely) URL to the solr instance
# File lib/solr_wrapper/settings.rb, line 47 def url "http://#{host}:#{port}/solr/" end
version_file()
click to toggle source
# File lib/solr_wrapper/settings.rb, line 70 def version_file static_config.version_file || File.join(instance_dir, "VERSION") end
zookeeper_host()
click to toggle source
# File lib/solr_wrapper/settings.rb, line 28 def zookeeper_host @zookeeper_host ||= static_config.zookeeper_port @zookeeper_host ||= host end
zookeeper_port()
click to toggle source
# File lib/solr_wrapper/settings.rb, line 40 def zookeeper_port @zookeeper_port ||= static_config.zookeeper_port @zookeeper_port ||= "#{port.to_i + 1000}" end
Private Instance Methods
default_solr_zip_path()
click to toggle source
# File lib/solr_wrapper/settings.rb, line 96 def default_solr_zip_path File.join(download_dir, File.basename(download_url)) end
download_dir()
click to toggle source
# File lib/solr_wrapper/settings.rb, line 100 def download_dir @download_dir ||= static_config.download_dir FileUtils.mkdir_p @download_dir @download_dir end
random_open_port()
click to toggle source
# File lib/solr_wrapper/settings.rb, line 106 def random_open_port socket = Socket.new(:INET, :STREAM, 0) begin socket.bind(Addrinfo.tcp('127.0.0.1', 0)) socket.local_address.ip_port ensure socket.close end end
tmpdir()
click to toggle source
# File lib/solr_wrapper/settings.rb, line 88 def tmpdir if defined?(Rails) && Rails.root File.join(Rails.root, 'tmp') else Dir.tmpdir end end