Permalink
Browse files

add zookeeper and solrcloud options

  • Loading branch information...
1 parent 660bcb4 commit ad82e8a1cf6e322a250e1902a48bc0b0029561d3 @bru bru committed Mar 27, 2013
@@ -276,6 +276,16 @@ def disabled?
@disabled ||= (user_configuration_from_key('disabled') || false)
end
+ # Solr Cloud number of shards
+ def shards
+ @shards ||= (user_configuration_from_key('solr', 'shards') || nil)
+ end
+
+ # Zookeeper config
+ def zookeepers
+ @zookeepers ||= (user_configuration_from_key('solr', 'zookeepers') || nil)
+ end
+
private
#
@@ -80,6 +80,20 @@ def max_memory
configuration.max_memory
end
+
+ # Zookeeper
+ def zookeeper_run
+ configuration.zookeepers && configuration.zookeepers.any? ? true : false
+ end
+
+ def zookeeper_hosts
+ configuration.zookeepers if configuration.zookeepers
+ end
+
+ # SolrCloud
+ def solr_shards
+ configuration.shards
+ end
private
#
@@ -57,6 +57,17 @@ opts = OptionParser.new do |opts|
opts.on '--min-memory=MEMORY', 'Specify the initial size of the memory allocation pool' do |mm|
server.min_memory = mm
end
+
+ # Zookeeper flag and hosts
+ opts.on '--zookeepers=HOSTS', 'Specify the zookeeper hosts for this cluster' do |zk|
+ server.zookeeper_run = true
+ server.zookeeper_hosts = zk
+ end
+
+ # SolrCloud shards
+ opts.on '--shards=SHARDS', 'Specify the number of shards in this cluster' do |shards|
+ server.solr_shards = shards
+ end
end
opts.parse!
@@ -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
+ attr_accessor :min_memory, :max_memory, :bind_address, :port, :log_file, :zookeeper_run, :zookeeper_hosts, :solr_shards
attr_writer :pid_dir, :pid_file, :solr_data_dir, :solr_home, :solr_jar
@@ -99,6 +99,11 @@ def run
command << "-Dsolr.data.dir=#{solr_data_dir}" if solr_data_dir
command << "-Dsolr.solr.home=#{solr_home}" if solr_home
command << "-Djava.util.logging.config.file=#{logging_config_path}" if logging_config_path
+ # SolrCloud
+ command << "-DnumShards=#{solr_shards}" if solr_shards
+ # Zookeeper
+ command << "-DzkRun" if zookeeper_run
+ command << "-DzkHost=#{zookeeper_hosts}" if zookeeper_hosts
command << '-jar' << File.basename(solr_jar)
FileUtils.cd(File.dirname(solr_jar)) do
exec(*command)

0 comments on commit ad82e8a

Please sign in to comment.