[Groonga-commit] droonga/droonga-engine at f940f63 [master] Split methods to generate command line options

アーカイブの一覧に戻る

YUKI Hiroshi null+****@clear*****
Fri Nov 21 17:46:10 JST 2014


YUKI Hiroshi	2014-11-21 17:46:10 +0900 (Fri, 21 Nov 2014)

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

  Message:
    Split methods to generate command line options

  Modified files:
    lib/droonga/data_absorber.rb

  Modified: lib/droonga/data_absorber.rb (+54 -35)
===================================================================
--- lib/droonga/data_absorber.rb    2014-11-21 17:42:08 +0900 (4f9023a)
+++ lib/droonga/data_absorber.rb    2014-11-21 17:46:10 +0900 (2052b80)
@@ -45,43 +45,10 @@ module Droonga
     end
 
     def absorb
-      drndump = @params[:drndump]
-      drndump_options = []
-      drndump_options += ["--host", @params[:source_host]] if @params[:source_host]
-      drndump_options += ["--port", @params[:port].to_s] if @params[:port]
-      drndump_options += ["--tag", @params[:tag]] if @params[:tag]
-      drndump_options += ["--dataset", @params[:dataset]] if @params[:dataset]
-      drndump_options += ["--receiver-host", @params[:destination_host]]
-      drndump_options += ["--receiver-port", @params[:receiver_port].to_s] if @params[:receiver_port]
+      drndump_command_line = [@params[:drndump]] + drndump_options
 
       client = @params[:client]
-      client_options = []
-      if client.include?("droonga-request")
-        client_options += ["--host", @params[:destination_host]]
-        client_options += ["--port", @params[:port].to_s] if @params[:port]
-        client_options += ["--tag", @params[:tag]] if @params[:tag]
-        client_options += ["--receiver-host", @params[:destination_host]]
-        client_options += ["--receiver-port", @params[:receiver_port].to_s] if @params[:receiver_port]
-      elsif client.include?("droonga-send")
-        #XXX Don't use round-robin with multiple endpoints
-        #    even if there are too much data.
-        #    Schema and indexes must be sent to just one endpoint
-        #    to keep their order, but currently there is no way to
-        #    extract only schema and indexes via drndump.
-        #    So, we always use just one endpoint for now,
-        #    even if there are too much data.
-        server = "droonga:#{params[:destination_host]}"
-        server = "#{server}:#{params[:port].to_s}" if @params[:port]
-        server = "#{server}/#{params[:tag].to_s}" if @params[:tag]
-        client_options += ["--server", server]
-        #XXX We should restrict the traffic to avoid overflowing!
-        client_options += ["--messages-per-second", @params[:messages_per_second]]
-      else
-        raise ArgumentError.new("Unknwon type client: #{client}")
-      end
-
-      drndump_command_line = [drndump] + drndump_options
-      client_command_line = [client] + client_options
+      client_command_line = [client] + client_options(client)
 
       calculated_required_time = required_time_in_seconds
       unless calculated_required_time == TIME_UNKNOWN
@@ -109,6 +76,58 @@ module Droonga
       end
     end
 
+    def drndump_options
+      options = []
+      options += ["--host", @params[:source_host]] if @params[:source_host]
+      options += ["--port", @params[:port].to_s] if @params[:port]
+      options += ["--tag", @params[:tag]] if @params[:tag]
+      options += ["--dataset", @params[:dataset]] if @params[:dataset]
+      options += ["--receiver-host", @params[:destination_host]]
+      options += ["--receiver-port", @params[:receiver_port].to_s] if @params[:receiver_port]
+      options
+    end
+
+    def droonga_request_options
+      options = []
+      options += ["--host", @params[:destination_host]]
+      options += ["--port", @params[:port].to_s] if @params[:port]
+      options += ["--tag", @params[:tag]] if @params[:tag]
+      options += ["--receiver-host", @params[:destination_host]]
+      options += ["--receiver-port", @params[:receiver_port].to_s] if @params[:receiver_port]
+      options
+    end
+
+    def droonga_send_options
+      options = []
+  
+      #XXX Don't use round-robin with multiple endpoints
+      #    even if there are too much data.
+      #    Schema and indexes must be sent to just one endpoint
+      #    to keep their order, but currently there is no way to
+      #    extract only schema and indexes via drndump.
+      #    So, we always use just one endpoint for now,
+      #    even if there are too much data.
+      server = "droonga:#{params[:destination_host]}"
+      server = "#{server}:#{params[:port].to_s}" if @params[:port]
+      server = "#{server}/#{params[:tag].to_s}" if @params[:tag]
+      options += ["--server", server]
+  
+      #XXX We should restrict the traffic to avoid overflowing!
+      options += ["--messages-per-second", @params[:messages_per_second]]
+  
+      options
+    end
+
+    def client_options(client)
+      if client.include?("droonga-request")
+        droonga_request_options
+      elsif client.include?("droonga-send")
+        droonga_send_options
+      else
+        raise ArgumentError.new("Unknwon type client: #{client}")
+      end
+    end
+
     def required_time_in_seconds
       @params[:client].include?("droonga-send")
         total_n_source_records / @params[:messages_per_second]
-------------- next part --------------
HTML����������������������������...
ダウンロード 



More information about the Groonga-commit mailing list
アーカイブの一覧に戻る