[Groonga-commit] droonga/droonga-engine at df8c367 [master] Get last processed message timestamp via serf tag

Back to archive index

YUKI Hiroshi null+****@clear*****
Tue Apr 21 10:42:34 JST 2015


YUKI Hiroshi	2015-04-21 10:42:34 +0900 (Tue, 21 Apr 2015)

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

  Message:
    Get last processed message timestamp via serf tag

  Modified files:
    bin/droonga-engine-absorb-data
    bin/droonga-engine-join

  Modified: bin/droonga-engine-absorb-data (+13 -5)
===================================================================
--- bin/droonga-engine-absorb-data    2015-04-21 10:42:12 +0900 (88e9b32)
+++ bin/droonga-engine-absorb-data    2015-04-21 10:42:34 +0900 (238f4c1)
@@ -187,6 +187,13 @@ module Droonga
       serf.send_query(command, options)
     end
 
+    def current_member_state(target)
+      serf = Serf.new(target, :verbose => @options[:verbose])
+      serf.current_members.find do |member|
+        member["name"] == target
+      end
+    end
+
     def absorber
       @absorber ||= prepare_absorber
     end
@@ -234,15 +241,16 @@ module Droonga
 
       puts ""
 
-      response = run_remote_command(source_node.to_s, "report_metadata",
-                                    "node" => source_node.to_s,
-                                    "key" => "last_processed_message_timestamp")
-      unless response
+      timestamp = nil
+      source_state = current_member_state(source_node.to_s)
+      if source_state
+        timestamp = source_state["tags"]["last-processed-message-timestamp"]
+      end
+      unless timestamp
         $stderr.puts("Couldn't get the time stamp of " +
                        "the last processed message from the source node.")
         return false
       end
-      timestamp = response["value"]
       if timestamp and not timestamp.empty?
         puts "The timestamp of the last processed message in the source node: #{timestamp}"
         puts "Setting effective message timestamp for the destination node..."

  Modified: bin/droonga-engine-join (+13 -5)
===================================================================
--- bin/droonga-engine-join    2015-04-21 10:42:12 +0900 (16f4d9d)
+++ bin/droonga-engine-join    2015-04-21 10:42:34 +0900 (010ecc0)
@@ -184,6 +184,13 @@ module Droonga
       serf.send_query(command, options)
     end
 
+    def current_member_state(target)
+      serf = Serf.new(target, :verbose => @options[:verbose])
+      serf.current_members.find do |member|
+        member["name"] == target
+      end
+    end
+
     def absorber
       @absorber ||= prepare_absorber
     end
@@ -286,15 +293,16 @@ module Droonga
     end
 
     def set_effective_message_timestamp
-      response = run_remote_command(source_node.to_s, "report_metadata",
-                                    "node" => source_node.to_s,
-                                    "key" => "last_processed_message_timestamp")
-      unless response
+      timestamp = nil
+      source_state = current_member_state(source_node.to_s)
+      if source_state
+        timestamp = source_state["tags"]["last-processed-message-timestamp"]
+      end
+      unless timestamp
         $stderr.puts("Couldn't get the time stamp of " +
                        "the last processed message from the source node.")
         return false
       end
-      timestamp = response["value"]
       if timestamp and not timestamp.empty?
         puts "The timestamp of the last processed message in the source node: #{timestamp}"
         puts "Setting effective message timestamp for the destination node..."
-------------- next part --------------
HTML����������������������������...
Download 



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