[Groonga-commit] droonga/droonga-engine at 1d6248f [master] Manage effective_message_timestamp and last_processed_timestamp as a part of node-status

Back to archive index

YUKI Hiroshi null+****@clear*****
Fri Nov 21 12:19:50 JST 2014


YUKI Hiroshi	2014-11-21 12:19:50 +0900 (Fri, 21 Nov 2014)

  New Revision: 1d6248f204fabbdf7f7e32df05b08760f4b28263
  https://github.com/droonga/droonga-engine/commit/1d6248f204fabbdf7f7e32df05b08760f4b28263

  Message:
    Manage effective_message_timestamp and last_processed_timestamp as a part of node-status

  Modified files:
    lib/droonga/engine.rb
    lib/droonga/path.rb

  Modified: lib/droonga/engine.rb (+11 -11)
===================================================================
--- lib/droonga/engine.rb    2014-11-21 11:45:52 +0900 (396d14d)
+++ lib/droonga/engine.rb    2014-11-21 12:19:50 +0900 (bab3952)
@@ -24,6 +24,7 @@ require "droonga/catalog_loader"
 require "droonga/dispatcher"
 require "droonga/file_observer"
 require "droonga/live_nodes_list_loader"
+require "droonga/node_status"
 
 module Droonga
   class Engine
@@ -58,7 +59,7 @@ module Droonga
       @live_nodes_list_observer.stop
       on_finish = lambda do
         logger.trace("stop_gracefully/on_finish: start")
-        output_last_processed_timestamp
+        save_last_processed_timestamp
         @dispatcher.stop_gracefully do
           @state.shutdown
           yield
@@ -78,7 +79,7 @@ module Droonga
     # It may be called after stop_gracefully.
     def stop_immediately
       logger.trace("stop_immediately: start")
-      output_last_processed_timestamp
+      save_last_processed_timestamp
       @live_nodes_list_observer.stop
       @dispatcher.stop_immediately
       @state.shutdown
@@ -91,6 +92,10 @@ module Droonga
       @dispatcher.process_message(message)
     end
 
+    def node_status
+      @node_status ||= NodeStatus.new
+    end
+
     private
     def load_catalog
       catalog_path = Path.catalog
@@ -116,13 +121,9 @@ module Droonga
       Dispatcher.new(@state, @catalog)
     end
 
-    def output_last_processed_timestamp
+    def save_last_processed_timestamp
       logger.trace("output_last_processed_timestamp: start")
-      path = Path.last_processed_timestamp
-      FileUtils.mkdir_p(path.dirname.to_s)
-      path.open("w") do |file|
-        file.write(@last_processed_timestamp)
-      end
+      node_status.set(:last_processed_timestamp, @last_processed_timestamp.to_s)
       logger.trace("output_last_processed_timestamp: done")
     end
 
@@ -138,10 +139,9 @@ module Droonga
     end
 
     def effective_message_timestamp
-      path = Path.effective_message_timestamp
-      return nil unless path.exist?
+      timestamp = node_status.get(:effective_message_timestamp)
+      return nil unless timestamp
 
-      timestamp = path.read
       begin
         Time.parse(timestamp)
       rescue ArgumentError

  Modified: lib/droonga/path.rb (+0 -8)
===================================================================
--- lib/droonga/path.rb    2014-11-21 11:45:52 +0900 (c50d0a7)
+++ lib/droonga/path.rb    2014-11-21 12:19:50 +0900 (18577d4)
@@ -48,14 +48,6 @@ module Droonga
         state + "live-nodes.json"
       end
 
-      def last_processed_timestamp
-        state + "last-processed.timestamp"
-      end
-
-      def effective_message_timestamp
-        state + "effective-message.timestamp"
-      end
-
       def config
         base + "droonga-engine.yaml"
       end
-------------- next part --------------
HTML����������������������������...
Télécharger 



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