Navigation Menu

Skip to content

Commit

Permalink
Output more trace logs around last message timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 28, 2015
1 parent 3f5fe53 commit 3afb045
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/droonga/engine.rb
Expand Up @@ -151,6 +151,9 @@ def export_last_message_timestamp_to_cluster
serf = Serf.new(@name)
old_timestamp = serf.last_message_timestamp
old_timestamp = Time.parse(old_timestamp) if old_timestamp
logger.trace("export_last_message_timestamp_to_cluster: check",
:old => old_timestamp,
:current => @last_message_timestamp)
if old_timestamp.nil? or timestamp > old_timestamp
timestamp = timestamp.utc.iso8601(MICRO_SECONDS_DECIMAL_PLACE)
serf.last_message_timestamp = timestamp
Expand All @@ -162,9 +165,14 @@ def export_last_message_timestamp_to_cluster
end

def export_last_message_timestamp_to_file
logger.trace("export_last_message_timestamp_to_file: start")
old_timestamp = read_last_message_timestamp
logger.trace("export_last_message_timestamp_to_file: check",
:loaded => old_timestamp,
:current => @last_message_timestamp)
if old_timestamp and
old_timestamp > @last_message_timestamp
logger.trace("export_last_message_timestamp_to_file: skipped")
return
end
path = Path.last_message_timestamp
Expand All @@ -173,13 +181,17 @@ def export_last_message_timestamp_to_file
timestamp = timestamp.utc.iso8601(MICRO_SECONDS_DECIMAL_PLACE)
output.puts(timestamp)
end
logger.trace("export_last_message_timestamp_to_file: done")
end

def run_last_message_timestamp_observer
path = Path.last_message_timestamp
observer = FileObserver.new(@loop, path)
observer.on_change = lambda do
timestamp = read_last_message_timestamp
logger.trace("last message stamp file is modified",
:loaded => timestamp,
:current => @last_message_timestamp)
if timestamp
if @last_message_timestamp.nil? or
timestamp > @last_message_timestamp
Expand Down

0 comments on commit 3afb045

Please sign in to comment.