[Groonga-commit] droonga/droonga-engine at c3c9f0a [master] Use self host name as the receiver by default.

Back to archive index

YUKI Hiroshi null+****@clear*****
Sat Nov 29 16:02:06 JST 2014


YUKI Hiroshi	2014-11-29 16:02:06 +0900 (Sat, 29 Nov 2014)

  New Revision: c3c9f0a2991c2184e6d90129ec405c4f22220efb
  https://github.com/droonga/droonga-engine/commit/c3c9f0a2991c2184e6d90129ec405c4f22220efb

  Message:
    Use self host name as the receiver by default.
    
    This allows you to run absorb-data and join commands on a host differnt from the host given via "--host" option

  Modified files:
    bin/droonga-engine-absorb-data
    bin/droonga-engine-join
    lib/droonga/catalog_fetcher.rb
    lib/droonga/data_absorber.rb

  Modified: bin/droonga-engine-absorb-data (+8 -0)
===================================================================
--- bin/droonga-engine-absorb-data    2014-11-29 02:18:20 +0900 (9e70138)
+++ bin/droonga-engine-absorb-data    2014-11-29 16:02:06 +0900 (159d2d3)
@@ -18,6 +18,7 @@
 require "ostruct"
 require "optparse"
 require "open3"
+require "socket"
 
 require "droonga/engine/version"
 require "droonga/catalog_generator"
@@ -57,6 +58,7 @@ class AbsorbDataCommand
     options.tag     = Droonga::CatalogGenerator::DEFAULT_TAG
     options.dataset = Droonga::CatalogGenerator::DEFAULT_DATASET
     options.remote  = true
+    options.receiver_host = Socket.gethostname
     options.messages_per_second = Droonga::DataAbsorber::DEFAULT_MESSAGES_PER_SECOND
     parser = OptionParser.new
     parser.version = Droonga::Engine::VERSION
@@ -71,6 +73,11 @@ class AbsorbDataCommand
               "Host name of this cluster to be connected.") do |host|
       options.destination_host = host
     end
+    parser.on("--receiver-host=HOST",
+              "Host name of this computer.",
+              "(#{options.receiver_host})") do |host|
+      options.receiver_host = host
+    end
     parser.on("--port=PORT", Integer,
               "Port number of the source cluster to be connected.",
               "(#{options.port})") do |port|
@@ -139,6 +146,7 @@ class AbsorbDataCommand
       :dataset          => @options.dataset,
       :source_host      => @options.source_host,
       :destination_host => @options.destination_host,
+      :receiver_host    => @options.receiver_host,
       :port             => @options.port,
       :tag              => @options.tag,
       :messages_per_second => @options.messages_per_second,

  Modified: bin/droonga-engine-join (+5 -0)
===================================================================
--- bin/droonga-engine-join    2014-11-29 02:18:20 +0900 (c4fcff3)
+++ bin/droonga-engine-join    2014-11-29 16:02:06 +0900 (31e4b7b)
@@ -18,6 +18,7 @@
 require "slop"
 require "json"
 require "pathname"
+require "socket"
 
 require "droonga/engine/version"
 require "droonga/path"
@@ -54,6 +55,9 @@ class JoinCommand
       option.on("replica-source-host=",
                 "Host name of the soruce node in the cluster to be connected.",
                 :required => true)
+      option.on("receiver-host=",
+                "Host name of this host.",
+                :default => Socket.gethostname)
       option.on(:dataset=,
                 "Dataset name of for the node to be joined.",
                 :default => Droonga::CatalogGenerator::DEFAULT_DATASET)
@@ -101,6 +105,7 @@ class JoinCommand
       :dataset          => @options[:dataset],
       :source_host      => @options["replica-source-host"],
       :destination_host => @options[:host],
+      :receiver_host    => @options["receiver-host"],
       :port             => @options[:port],
       :tag              => @options[:tag],
       :messages_per_second => @options["records-per-second"],

  Modified: lib/droonga/catalog_fetcher.rb (+3 -1)
===================================================================
--- lib/droonga/catalog_fetcher.rb    2014-11-29 02:18:20 +0900 (2ee0183)
+++ lib/droonga/catalog_fetcher.rb    2014-11-29 16:02:06 +0900 (6bf0694)
@@ -13,6 +13,8 @@
 # License along with this library; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
+require "socket"
+
 require "droonga/client"
 
 require "droonga/address"
@@ -43,7 +45,7 @@ module Droonga
         :tag           => Address::DEFAULT_TAG,
         :protocol      => :droonga,
         :timeout       => 1,
-        :receiver_host => "127.0.0.1",
+        :receiver_host => Socket.gethostname,
         :receiver_port => 0,
       }
     end

  Modified: lib/droonga/data_absorber.rb (+6 -5)
===================================================================
--- lib/droonga/data_absorber.rb    2014-11-29 02:18:20 +0900 (66de7f7)
+++ lib/droonga/data_absorber.rb    2014-11-29 16:02:06 +0900 (fd7d640)
@@ -52,6 +52,7 @@ module Droonga
 
       @source_host      = @params[:source_host]
       @destination_host = @params[:destination_host]
+      @receiver_host    = @params[:receiver_host] || @destination_host
 
       @receiver_port = @params[:receiver_port]
     end
@@ -115,7 +116,7 @@ module Droonga
         :port          => @port,
         :tag           => @tag,
         :progocol      => :droonga,
-        :receiver_host => @destination_host,
+        :receiver_host => @receiver_host,
         :receiver_port => 0,
       }
       @source_client ||= Droonga::Client.new(options)
@@ -127,7 +128,7 @@ module Droonga
         :port          => @port,
         :tag           => @tag,
         :progocol      => :droonga,
-        :receiver_host => @destination_host,
+        :receiver_host => @receiver_host,
         :receiver_port => 0,
       }
       @destination_client ||= Droonga::Client.new(options)
@@ -152,7 +153,7 @@ module Droonga
       options += ["--port", @port]
       options += ["--tag", @tag]
       options += ["--dataset", @dataset]
-      options += ["--receiver-host", @destination_host]
+      options += ["--receiver-host", @receiver_host]
       options += ["--receiver-port", @receiver_port] if @receiver_port
       options.collect(&:to_s)
     end
@@ -162,7 +163,7 @@ module Droonga
       options += ["--host", @destination_host]
       options += ["--port", @port]
       options += ["--tag", @tag]
-      options += ["--receiver-host", @destination_host]
+      options += ["--receiver-host", @receiver_host]
       options += ["--receiver-port", @receiver_port] if @receiver_port
       options.collect(&:to_s)
     end
@@ -252,7 +253,7 @@ module Droonga
       fetcher = CatalogFetcher.new(:host          => @source_host,
                                    :port          => @port,
                                    :tag           => @tag,
-                                   :receiver_host => @destination_host)
+                                   :receiver_host => @receiver_host)
       fetcher.fetch(:dataset => @dataset)
     end
 
-------------- next part --------------
HTML����������������������������...
下載 



More information about the Groonga-commit mailing list
Back to archive index