Navigation Menu

Skip to content

Commit

Permalink
Retry to get last processed message timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 28, 2015
1 parent 0f5dcbd commit 03375b8
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
18 changes: 17 additions & 1 deletion bin/droonga-engine-absorb-data
Expand Up @@ -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..."
Expand Down
18 changes: 17 additions & 1 deletion bin/droonga-engine-join
Expand Up @@ -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..."
Expand Down
4 changes: 2 additions & 2 deletions lib/droonga/serf.rb
Expand Up @@ -203,8 +203,8 @@ def latest_last_message_timestamp
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

Expand Down

0 comments on commit 03375b8

Please sign in to comment.