Skip to content

Commit

Permalink
Add support for configuration uploading to zookeeper
Browse files Browse the repository at this point in the history
  • Loading branch information
bru committed Mar 28, 2013
1 parent 8bb5d9f commit 2f268d8
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
8 changes: 8 additions & 0 deletions sunspot_rails/lib/sunspot/rails/configuration.rb
Expand Up @@ -286,6 +286,14 @@ def zookeepers
@zookeepers ||= (user_configuration_from_key('solr', 'zookeepers') || nil)
end

def conf_dir
@conf_dir ||= (user_configuration_from_key('solr', 'conf_dir') || nil)
end

def collection
@collection ||= (user_configuration_from_key('solr', 'collection') || nil)
end

private

#
Expand Down
8 changes: 8 additions & 0 deletions sunspot_rails/lib/sunspot/rails/server.rb
Expand Up @@ -94,6 +94,14 @@ def zookeeper_hosts
def solr_shards
configuration.shards
end

def conf_dir
configuration.conf_dir
end

def collection
configuration.collection
end
private

#
Expand Down
8 changes: 8 additions & 0 deletions sunspot_solr/bin/sunspot-solr
Expand Up @@ -64,6 +64,14 @@ opts = OptionParser.new do |opts|
server.zookeeper_hosts = zk
end

opts.on '--conf-dir=CONF_DIR', 'Directory to configuration to be uploaded to Zookeeper' do |cd|
server.conf_dir = cd
end

opts.on '--collection=COLLECTION_NAME', 'The name of this collection in Zookeeper' do |coll|
server.collection = coll
end

# SolrCloud shards
opts.on '--shards=SHARDS', 'Specify the number of shards in this cluster' do |shards|
server.solr_shards = shards
Expand Down
6 changes: 4 additions & 2 deletions sunspot_solr/lib/sunspot/solr/server.rb
Expand Up @@ -19,7 +19,7 @@ class Server #:nodoc:

LOG_LEVELS = Set['SEVERE', 'WARNING', 'INFO', 'CONFIG', 'FINE', 'FINER', 'FINEST']

attr_accessor :min_memory, :max_memory, :bind_address, :port, :log_file, :zookeeper_run, :zookeeper_hosts, :solr_shards
attr_accessor :min_memory, :max_memory, :bind_address, :port, :log_file, :zookeeper_run, :zookeeper_hosts, :solr_shards, :conf_dir, :collection

attr_writer :pid_dir, :pid_file, :solr_data_dir, :solr_home, :solr_jar

Expand Down Expand Up @@ -102,8 +102,10 @@ def run
# SolrCloud
command << "-DnumShards=#{solr_shards}" if solr_shards
# Zookeeper
command << "-DzkRun" if zookeeper_run
command << "-DzkRun=#{bind_address}:#{port.to_i + 1000}" if zookeeper_run
command << "-DzkHost=#{zookeeper_hosts}" if zookeeper_hosts
command << "-Dbootstrap_confdir=#{conf_dir}" if conf_dir
command << "-Dcollection.configName=#{collection}" if collection
command << '-jar' << File.basename(solr_jar)
FileUtils.cd(File.dirname(solr_jar)) do
exec(*command)
Expand Down

0 comments on commit 2f268d8

Please sign in to comment.