[Groonga-commit] droonga/droonga-engine at 9612716 [master] Don't set serf tags multiple times

Back to archive index

YUKI Hiroshi null+****@clear*****
Wed Apr 1 17:01:10 JST 2015


YUKI Hiroshi	2015-04-01 17:01:10 +0900 (Wed, 01 Apr 2015)

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

  Message:
    Don't set serf tags multiple times

  Modified files:
    lib/droonga/serf.rb

  Modified: lib/droonga/serf.rb (+10 -2)
===================================================================
--- lib/droonga/serf.rb    2015-04-01 16:14:34 +0900 (4d352cc)
+++ lib/droonga/serf.rb    2015-04-01 17:01:10 +0900 (9f45a0c)
@@ -43,6 +43,7 @@ module Droonga
       @verbose = options[:verbose] || false
       @service_installation = ServiceInstallation.new
       @node_metadata = NodeMetadata.new
+      @tags_cache = {}
     end
 
     def run_agent(loop)
@@ -131,10 +132,12 @@ module Droonga
 
     def set_tag(name, value)
       run_command("tags", "-set", "#{name}=#{value}")
+      @tags_cache[name] = value
     end
 
     def delete_tag(name)
       run_command("tags", "-delete", name)
+      @tags_cache.delete(name)
     end
 
     def update_cluster_id
@@ -142,11 +145,12 @@ module Droonga
     end
 
     def set_have_unprocessed_messages_for(node_name)
-      set_tag("have-unprocessed-messages-for-#{node_name}", true)
+      tag = have_unprocessed_messages_tag_for(node_name)
+      set_tag(tag, true) unless @tags_cache.key?(tag)
     end
 
     def reset_have_unprocessed_messages_for(node_name)
-      delete_tag("have-unprocessed-messages-for-#{node_name}")
+      delete_tag(have_unprocessed_messages_tag_for(node_name))
     end
 
     def role
@@ -233,6 +237,10 @@ module Droonga
       end
     end
 
+    def have_unprocessed_messages_tag_for(node_name)
+      "have-unprocessed-messages-for-#{node_name}"
+    end
+
     def log_tag
       "serf"
     end
-------------- next part --------------
HTML����������������������������...
下载 



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