[Groonga-commit] droonga/droonga-engine at 20dd39e [master] Extract resposne from target node automatically

Back to archive index

YUKI Hiroshi null+****@clear*****
Wed Jul 23 16:57:20 JST 2014


YUKI Hiroshi	2014-07-23 16:57:20 +0900 (Wed, 23 Jul 2014)

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

  Message:
    Extract resposne from target node automatically

  Modified files:
    bin/droonga-engine-absorb-data
    lib/droonga/serf.rb

  Modified: bin/droonga-engine-absorb-data (+5 -6)
===================================================================
--- bin/droonga-engine-absorb-data    2014-07-23 16:50:36 +0900 (81cc12c)
+++ bin/droonga-engine-absorb-data    2014-07-23 16:57:20 +0900 (5bad542)
@@ -82,7 +82,7 @@ def run_remote_command(target, command, options)
   result = Droonga::Serf.send_query(target, command, options)
   puts result[:result]
   puts result[:error] unless result[:error].empty?
-  result[:result]
+  result[:response]
 end
 
 puts "Start to absorb data from #{options.source_host}"
@@ -102,11 +102,10 @@ if options.remote
                      "dataset" => options.dataset)
   while true
     sleep(3)
-    result = run_remote_command(destination_node, "report_status",
-                                "node" => destination_node,
-                                "key" => "absorbing")
-    response = result["Responses"][destination_node]
-    absorbing = JSON.parse(response)["value"]
+    response = run_remote_command(destination_node, "report_status",
+                                  "node" => destination_node,
+                                  "key" => "absorbing")
+    absorbing = response["value"]
     break unless absorbing
   end
 else

  Modified: lib/droonga/serf.rb (+12 -2)
===================================================================
--- lib/droonga/serf.rb    2014-07-23 16:50:36 +0900 (6be17eb)
+++ lib/droonga/serf.rb    2014-07-23 16:57:20 +0900 (5b808e1)
@@ -119,14 +119,24 @@ module Droonga
       ensure_serf
       options = ["-format", "json"] + additional_options_from_payload(payload)
       options += [event, JSON.generate(payload)]
-      run_once("event", *options)
+      result = run_once("event", *options)
+      if payload["node"]
+        responses = result[:result]["Responses"]
+        result[:response] = responses[payload["node"]]
+      end
+      result
     end
 
     def send_query(query, payload)
       ensure_serf
       options = ["-format", "json"] + additional_options_from_payload(payload)
       options += [query, JSON.generate(payload)]
-      run_once("query", *options)
+      result = run_once("query", *options)
+      if payload["node"]
+        responses = result[:result]["Responses"]
+        result[:response] = responses[payload["node"]]
+      end
+      result
     end
 
     def live_nodes
-------------- next part --------------
HTML����������������������������...
Download 



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