Navigation Menu

Skip to content

Commit

Permalink
Store last processed message timestamp as a serf tag
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 21, 2015
1 parent 1aa6966 commit 028129a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/droonga/engine.rb
Expand Up @@ -32,6 +32,7 @@ class Engine
include Deferrable

def initialize(loop, name, internal_name)
@name = name
@loop = loop
@catalog = load_catalog
@node_metadata = NodeMetadata.new
Expand Down Expand Up @@ -117,7 +118,8 @@ def create_dispatcher
def save_last_processed_message_timestamp
logger.trace("output_last_processed_message_timestamp: start")
if @last_processed_message_timestamp
@node_metadata.set(:last_processed_message_timestamp, @last_processed_message_timestamp.to_s)
serf = Serf.new(@name)
serf.last_processed_message_timestamp = @last_processed_message_timestamp
end
logger.trace("output_last_processed_message_timestamp: done")
end
Expand Down
12 changes: 12 additions & 0 deletions lib/droonga/serf.rb
Expand Up @@ -186,6 +186,18 @@ def role=(new_role)
# after that you must run update_cluster_state to update the cluster information cache
end

def last_processed_message_timestamp
@node_metadata.reload
@node_metadata.get(:last_processed_message_timestamp)
end

def last_processed_message_timestamp=(timestamp)
@node_metadata.reload
@node_metadata.set(:last_processed_message_timestamp, timestamp.to_s)
set_tag("last-processed-message-timestamp", timestamp.to_s)
# after that you must run update_cluster_state to update the cluster information cache
end

def accept_messages_newer_than_timestamp
@node_metadata.reload
@node_metadata.get(:accept_messages_newer_than)
Expand Down

0 comments on commit 028129a

Please sign in to comment.