[Groonga-commit] droonga/droonga-engine at 614b9ee [master] Add utility method to get serf tag value

Back to archive index

YUKI Hiroshi null+****@clear*****
Tue Apr 21 11:14:56 JST 2015


YUKI Hiroshi	2015-04-21 11:14:56 +0900 (Tue, 21 Apr 2015)

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

  Message:
    Add utility method to get serf tag value

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

  Modified: bin/droonga-engine-absorb-data (+3 -9)
===================================================================
--- bin/droonga-engine-absorb-data    2015-04-21 11:05:00 +0900 (238f4c1)
+++ bin/droonga-engine-absorb-data    2015-04-21 11:14:56 +0900 (84a327a)
@@ -187,11 +187,9 @@ module Droonga
       serf.send_query(command, options)
     end
 
-    def current_member_state(target)
+    def tag_value(target, tag)
       serf = Serf.new(target, :verbose => @options[:verbose])
-      serf.current_members.find do |member|
-        member["name"] == target
-      end
+      serf.get_tag(tag)
     end
 
     def absorber
@@ -241,11 +239,7 @@ module Droonga
 
       puts ""
 
-      timestamp = nil
-      source_state = current_member_state(source_node.to_s)
-      if source_state
-        timestamp = source_state["tags"]["last-processed-message-timestamp"]
-      end
+      timestamp = tag_value(source_node.to_s, "last-processed-message-timestamp")
       unless timestamp
         $stderr.puts("Couldn't get the time stamp of " +
                        "the last processed message from the source node.")

  Modified: bin/droonga-engine-join (+3 -9)
===================================================================
--- bin/droonga-engine-join    2015-04-21 11:05:00 +0900 (010ecc0)
+++ bin/droonga-engine-join    2015-04-21 11:14:56 +0900 (175a3ab)
@@ -184,11 +184,9 @@ module Droonga
       serf.send_query(command, options)
     end
 
-    def current_member_state(target)
+    def tag_value(target, tag)
       serf = Serf.new(target, :verbose => @options[:verbose])
-      serf.current_members.find do |member|
-        member["name"] == target
-      end
+      serf.get_tag(tag)
     end
 
     def absorber
@@ -293,11 +291,7 @@ module Droonga
     end
 
     def set_effective_message_timestamp
-      timestamp = nil
-      source_state = current_member_state(source_node.to_s)
-      if source_state
-        timestamp = source_state["tags"]["last-processed-message-timestamp"]
-      end
+      timestamp = tag_value(source_node.to_s, "last-processed-message-timestamp")
       unless timestamp
         $stderr.puts("Couldn't get the time stamp of " +
                        "the last processed message from the source node.")

  Modified: lib/droonga/serf.rb (+11 -0)
===================================================================
--- lib/droonga/serf.rb    2015-04-21 11:05:00 +0900 (20542ac)
+++ lib/droonga/serf.rb    2015-04-21 11:14:56 +0900 (188618f)
@@ -157,6 +157,17 @@ module Droonga
       sorted_nodes
     end
 
+    def get_tag(name)
+      myself = current_members.find do |member|
+        member["name"] ==****@name*****_s
+      end
+      if myself
+        myself["tags"]["name"]
+      else
+        nil
+      end
+    end
+
     def set_tag(name, value)
       run_command("tags", "-set", "#{name}=#{value}")
       @tags_cache[name] = value
-------------- next part --------------
HTML����������������������������...
다운로드 



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