Navigation Menu

Skip to content

Commit

Permalink
Use last processed message timestamp which is possibly updated after …
Browse files Browse the repository at this point in the history
…graceful stop
  • Loading branch information
piroor committed Apr 23, 2015
1 parent 6d4053f commit 1523d80
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
10 changes: 2 additions & 8 deletions bin/droonga-engine-absorb-data
Expand Up @@ -43,15 +43,10 @@ module Droonga
puts ""
puts "Absorbing..."

succeeded = update_accept_messages_newer_than_timestamp
unless succeeded
do_cancel
return false
end

succeeded = absorb

if succeeded
update_accept_messages_newer_than_timestamp
puts "Done."
else
do_cancel
Expand Down Expand Up @@ -247,7 +242,7 @@ module Droonga
end

def update_accept_messages_newer_than_timestamp
timestamp = source_node_serf.last_processed_message_timestamp
timestamp = source_node_serf.latest_last_processed_message_timestamp
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..."
Expand All @@ -261,7 +256,6 @@ module Droonga
"the last processed message from the source node. " +
"Any message will be forwarded to the joining node.")
end
true
end

def trap_signals
Expand Down
9 changes: 2 additions & 7 deletions bin/droonga-engine-join
Expand Up @@ -66,17 +66,13 @@ module Droonga
do_join
register_to_existing_nodes
set_source_node_role
successed = update_accept_messages_newer_than_timestamp
unless successed
do_cancel
return false
end
if should_copy?
successed = copy_data
unless successed
do_cancel
return false
end
update_accept_messages_newer_than_timestamp
end
reset_source_node_role
reset_joining_node_role
Expand Down Expand Up @@ -322,7 +318,7 @@ module Droonga
end

def update_accept_messages_newer_than_timestamp
timestamp = source_node_serf.last_processed_message_timestamp
timestamp = source_node_serf.latest_last_processed_message_timestamp
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..."
Expand All @@ -336,7 +332,6 @@ module Droonga
"the last processed message from the source node. " +
"Any message will be forwarded to the joining node.")
end
true
end

def register_to_existing_nodes
Expand Down
6 changes: 6 additions & 0 deletions lib/droonga/serf.rb
Expand Up @@ -199,6 +199,12 @@ def last_processed_message_timestamp
get_tag(Tag.last_processed_message_timestamp)
end

def latest_last_processed_message_timestamp
query("export_last_processed_message_timestamp",
"node" => @name)
last_processed_message_timestamp
end

def last_processed_message_timestamp=(timestamp)
set_tag(Tag.last_processed_message_timestamp, timestamp)
# after that you must run update_cluster_state to update the cluster information cache
Expand Down

0 comments on commit 1523d80

Please sign in to comment.