long-long-float
null+****@clear*****
Mon Aug 25 19:35:19 JST 2014
long-long-float 2014-08-25 19:35:19 +0900 (Mon, 25 Aug 2014) New Revision: 90b874b621d49aab3a1fbfed0c63bbf28570a77e https://github.com/long-long-float/droonga-engine/commit/90b874b621d49aab3a1fbfed0c63bbf28570a77e Merged 7fb2af2: Merge pull request #12 from long-long-float/share-catalog-automatically Message: refactor Modified files: bin/droonga-engine-join lib/droonga/command/serf_event_handler.rb Modified: bin/droonga-engine-join (+1 -34) =================================================================== --- bin/droonga-engine-join 2014-08-25 19:20:34 +0900 (5fbf772) +++ bin/droonga-engine-join 2014-08-25 19:35:19 +0900 (ebd58b1) @@ -39,14 +39,6 @@ options.tag = Droonga::CatalogGenerator::DEFAULT_TAG parser = OptionParser.new parser.version = Droonga::Engine::VERSION -=begin -parser.on("--base-dir=PATH", - "Path to the base directory the catalog.json is located in.", - "(#{options.base_dir})") do |path| - options.base_dir = path -end -=end - parser.on("--[no-]copy", "Do or don't copy data from the source cluster.", "(#{options.copy})") do |copy| @@ -85,15 +77,6 @@ parser.parse!(ARGV) base_dir = Pathname(options.base_dir).expand_path ENV[Droonga::Path::BASE_DIR_ENV_NAME] = base_dir.to_s -=begin -catalog_path = Droonga::Path.catalog -unless catalog_path.exist? - raise "Cannot load 'catalog.json'. You must specify correct path " + - "to the base directory via --base-dir option." -end -source_catalog = JSON.parse(catalog_path.read) -=end - unless options.joining_host raise "You must specify the host name or the IP address of the node " + "to be joined via --host option." @@ -103,23 +86,6 @@ unless options.replica_source_host "of an existing cluster via --replica-source-host option." end -=begin -generator = Droonga::CatalogGenerator.new -generator.load(source_catalog) - -dataset = generator.dataset_for_host(options.replica_source_host) -if dataset - if generator.dataset_for_host(options.joining_host) - raise "The joining node is already a member of the cluster. " + - "You cannot join a member twice." - end - - options.dataset = dataset.name - options.tag = dataset.replicas.tag - options.port = dataset.replicas.port -end -=end - options.joining_node = "#{options.joining_host}:#{options.port}/#{options.tag}" options.source_node = "#{options.replica_source_host}:#{options.port}/#{options.tag}" @@ -137,6 +103,7 @@ run_remote_command(options.joining_node, "join", "source" => options.source_node, "port" => options.port, "dataset" => options.dataset, + "tag" => options.tag, "copy" => options.copy) sleep(5) #TODO: wait for restarting of the joining node. this should be done more safely. Modified: lib/droonga/command/serf_event_handler.rb (+9 -3) =================================================================== --- lib/droonga/command/serf_event_handler.rb 2014-08-25 19:20:34 +0900 (46b8ed8) +++ lib/droonga/command/serf_event_handler.rb 2014-08-25 19:35:19 +0900 (ce86e3d) @@ -135,16 +135,22 @@ module Droonga source_node_port = @payload["port"] source_node_dataset = @payload["dataset"] joining_node = @payload["node"] + tag = @payload["tag"] dataset = @payload["dataset"] return unless [source_node, source_node_port, source_node_dataset, joining_node, dataset].all? log("source_node = #{source_node}") + source_host = source_node.split(":").first - joining_host = joining_node.split(":").first + catalog = nil - Droonga::Client.open(:host => source_host, :port => source_node_port, :tag => "droonga", :protocol => :droonga, :timeout => 1, :receiver_host => joining_host, :receiver_port => 0) do |client| - request = client.request(:dataset => source_node_dataset , :type => "catalog.fetch") do |responce| + Droonga::Client.open(:host => source_host, :port => source_node_port, + :tag => tag, :protocol => :droonga, :timeout => 1, + :receiver_host => joining_host, + :receiver_port => 0) do |client| + request = client.request(:dataset => source_node_dataset , + :type => "catalog.fetch") do |responce| File.write(Path.catalog, JSON.generate(responce["body"])) catalog = responce["body"] end -------------- next part -------------- HTML����������������������������...Download