[Groonga-commit] droonga/droonga-engine at 03375b8 [master] Retry to get last processed message timestamp

Back to archive index

YUKI Hiroshi null+****@clear*****
Tue Apr 28 21:54:53 JST 2015


YUKI Hiroshi	2015-04-28 21:54:53 +0900 (Tue, 28 Apr 2015)

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

  Message:
    Retry to get last processed message timestamp

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

  Modified: bin/droonga-engine-absorb-data (+17 -1)
===================================================================
--- bin/droonga-engine-absorb-data    2015-04-28 21:47:43 +0900 (f32a2d7)
+++ bin/droonga-engine-absorb-data    2015-04-28 21:54:53 +0900 (de64844)
@@ -245,8 +245,24 @@ module Droonga
       true
     end
 
-    def update_accept_messages_newer_than_timestamp
+    GETTING_LAST_MESSAGE_TIMESTAMP_MAX_RETRY_COUNT = 10
+    GETTING_LAST_MESSAGE_TIMESTAMP_RETRY_INTERVAL_SECONDS = 10
+
+    def try_get_last_message_timestamp(retry_count=0)
+      puts "Getting the timestamp of the last processed message in the source node..."
       timestamp = source_node_serf.latest_last_message_timestamp
+      unless timestamp
+        if retry_count < GETTING_LAST_MESSAGE_TIMESTAMP_MAX_RETRY_COUNT
+          puts "Failed. Retrying..."
+          sleep(GETTING_LAST_MESSAGE_TIMESTAMP_RETRY_INTERVAL_SECONDS)
+          timestamp = try_get_last_message_timestamp(retry_count + 1)
+        end
+      end
+      timestamp
+    end
+
+    def update_accept_messages_newer_than_timestamp
+      timestamp = try_get_last_message_timestamp
       if timestamp and not timestamp.empty?
         puts "The timestamp of the last processed message in the source node: #{timestamp}"
         puts "Setting the destination node to ignore messages older than the timestamp..."

  Modified: bin/droonga-engine-join (+17 -1)
===================================================================
--- bin/droonga-engine-join    2015-04-28 21:47:43 +0900 (c4e9f57)
+++ bin/droonga-engine-join    2015-04-28 21:54:53 +0900 (da3a254)
@@ -320,8 +320,24 @@ module Droonga
       true
     end
 
-    def update_accept_messages_newer_than_timestamp
+    GETTING_LAST_MESSAGE_TIMESTAMP_MAX_RETRY_COUNT = 10
+    GETTING_LAST_MESSAGE_TIMESTAMP_RETRY_INTERVAL_SECONDS = 10
+
+    def try_get_last_message_timestamp(retry_count=0)
+      puts "Getting the timestamp of the last processed message in the source node..."
       timestamp = source_node_serf.latest_last_message_timestamp
+      unless timestamp
+        if retry_count < GETTING_LAST_MESSAGE_TIMESTAMP_MAX_RETRY_COUNT
+          puts "Failed. Retrying..."
+          sleep(GETTING_LAST_MESSAGE_TIMESTAMP_RETRY_INTERVAL_SECONDS)
+          timestamp = try_get_last_message_timestamp(retry_count + 1)
+        end
+      end
+      timestamp
+    end
+
+    def update_accept_messages_newer_than_timestamp
+      timestamp = try_get_last_message_timestamp
       if timestamp and not timestamp.empty?
         puts "The timestamp of the last processed message at the source node: #{timestamp}"
         puts "Setting new node to ignore messages older than the timestamp..."

  Modified: lib/droonga/serf.rb (+2 -2)
===================================================================
--- lib/droonga/serf.rb    2015-04-28 21:47:43 +0900 (e5f942d)
+++ lib/droonga/serf.rb    2015-04-28 21:54:53 +0900 (40a4dec)
@@ -203,8 +203,8 @@ module Droonga
       send_query("export_last_message_timestamp",
                  "node" => @name.to_s)
       # Wait until the query is completely processed by the node
-      # and and the timestamp is correctly exported to its tag.
-      sleep(30)
+      # and the timestamp is correctly exported to its tag.
+      sleep(5)
       last_message_timestamp
     end
 
-------------- next part --------------
HTML����������������������������...
Download 



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