[Groonga-commit] droonga/droonga-engine at 830ab2d [master] Shorten

Back to archive index

Piro / YUKI Hiroshi null+****@clear*****
Fri Apr 24 00:53:12 JST 2015


Piro / YUKI Hiroshi	2015-04-24 00:53:12 +0900 (Fri, 24 Apr 2015)

  New Revision: 830ab2ddf17e7fd0ca0529a2fb7bcf5d663a6d37
  https://github.com/droonga/droonga-engine/commit/830ab2ddf17e7fd0ca0529a2fb7bcf5d663a6d37

  Message:
    Shorten

  Modified files:
    lib/droonga/command/serf_event_handler.rb
    lib/droonga/engine.rb
    lib/droonga/path.rb
    lib/droonga/serf.rb
    lib/droonga/serf/remote_command.rb
    lib/droonga/serf/tag.rb

  Modified: lib/droonga/command/serf_event_handler.rb (+2 -2)
===================================================================
--- lib/droonga/command/serf_event_handler.rb    2015-04-24 00:50:39 +0900 (731a0dc)
+++ lib/droonga/command/serf_event_handler.rb    2015-04-24 00:53:12 +0900 (13d691e)
@@ -82,8 +82,8 @@ module Droonga
         case event_name
         when "change_role"
           Serf::RemoteCommand::ChangeRole
-        when "export_last_processed_message_timestamp"
-          Serf::RemoteCommand::ExportLastProcessedMessageTimestamp
+        when "export_last_message_timestamp"
+          Serf::RemoteCommand::ExportLastMessageTimestamp
         when "accept_messages_newer_than"
           Serf::RemoteCommand::AcceptMessagesNewerThan
         when "join"

  Modified: lib/droonga/engine.rb (+29 -29)
===================================================================
--- lib/droonga/engine.rb    2015-04-24 00:50:39 +0900 (ae87e90)
+++ lib/droonga/engine.rb    2015-04-24 00:53:12 +0900 (3d7824f)
@@ -71,7 +71,7 @@ module Droonga
       @state.start
       @cluster.start
       @dispatcher.start
-      @last_processed_message_timestamp_observer = run_last_processed_message_timestamp_observer
+      @last_message_timestamp_observer = run_last_message_timestamp_observer
       logger.trace("start: done")
     end
 
@@ -80,14 +80,14 @@ module Droonga
       @cluster.shutdown
       on_finish = lambda do
         logger.trace("stop_gracefully: middle")
-        @last_processed_message_timestamp_observer.stop
+        @last_message_timestamp_observer.stop
         @dispatcher.stop_gracefully do
           @state.shutdown
           yield
           #XXX We must save last processed message timstamp
           #    based on forwarded/dispatched messages while
           #    "graceful stop" operations.
-          export_last_processed_message_timestamp_to_file
+          export_last_message_timestamp_to_file
           logger.trace("stop_gracefully: done")
         end
       end
@@ -103,11 +103,11 @@ module Droonga
     # It may be called after stop_gracefully.
     def stop_immediately
       logger.trace("stop_immediately: start")
-      @last_processed_message_timestamp_observer.stop
+      @last_message_timestamp_observer.stop
       @dispatcher.stop_immediately
       @cluster.shutdown
       @state.shutdown
-      export_last_processed_message_timestamp_to_file
+      export_last_message_timestamp_to_file
       logger.trace("stop_immediately: done")
     end
 
@@ -119,9 +119,9 @@ module Droonga
     def process(message)
       if message.include?("date")
         date = Time.parse(message["date"])
-        if @last_processed_message_timestamp.nil? or
-             @last_processed_message_timestamp < date
-          @last_processed_message_timestamp = date
+        if @last_message_timestamp.nil? or
+             @last_message_timestamp < date
+          @last_message_timestamp = date
         end
       end
       @dispatcher.process_message(message)
@@ -144,56 +144,56 @@ module Droonga
 
     MICRO_SECONDS_DECIMAL_PLACE = 6
 
-    def export_last_processed_message_timestamp_to_cluster
-      logger.trace("export_last_processed_message_timestamp_to_cluster: start")
-      if @last_processed_message_timestamp
-        timestamp = @last_processed_message_timestamp
+    def export_last_message_timestamp_to_cluster
+      logger.trace("export_last_message_timestamp_to_cluster: start")
+      if @last_message_timestamp
+        timestamp = @last_message_timestamp
         serf = Serf.new(@name)
-        old_timestamp = serf.last_processed_message_timestamp
+        old_timestamp = serf.last_message_timestamp
         old_timestamp = Time.parse(old_timestamp) if old_timestamp
         if old_timestamp.nil? or timestamp > old_timestamp
           timestamp = timestamp.utc.iso8601(MICRO_SECONDS_DECIMAL_PLACE)
-          serf.last_processed_message_timestamp = timestamp
+          serf.last_message_timestamp = timestamp
           logger.info("exported last processed message timestamp",
                       :timestamp => timestamp)
         end
       end
-      logger.trace("export_last_processed_message_timestamp_to_cluster: done")
+      logger.trace("export_last_message_timestamp_to_cluster: done")
     end
 
-    def export_last_processed_message_timestamp_to_file
-      old_timestamp = read_last_processed_message_timestamp
+    def export_last_message_timestamp_to_file
+      old_timestamp = read_last_message_timestamp
       if old_timestamp and
-           old_timestamp > @last_processed_message_timestamp
+           old_timestamp > @last_message_timestamp
         return
       end
-      path = Path.last_processed_message_timestamp
+      path = Path.last_message_timestamp
       SafeFileWriter.write(path) do |output, file|
-        timestamp = @last_processed_message_timestamp
+        timestamp = @last_message_timestamp
         timestamp = timestamp.utc.iso8601(MICRO_SECONDS_DECIMAL_PLACE)
         output.puts(timestamp)
       end
     end
 
-    def run_last_processed_message_timestamp_observer
-      path = Path.last_processed_message_timestamp
+    def run_last_message_timestamp_observer
+      path = Path.last_message_timestamp
       observer = FileObserver.new(@loop, path)
       observer.on_change = lambda do
-        timestamp = read_last_processed_message_timestamp
+        timestamp = read_last_message_timestamp
         if timestamp
-          if @last_processed_message_timestamp.nil? or
-               timestamp > @last_processed_message_timestamp
-            @last_processed_message_timestamp = timestamp
+          if @last_message_timestamp.nil? or
+               timestamp > @last_message_timestamp
+            @last_message_timestamp = timestamp
           end
         end
-        export_last_processed_message_timestamp_to_cluster
+        export_last_message_timestamp_to_cluster
       end
       observer.start
       observer
     end
 
-    def read_last_processed_message_timestamp
-      file = Path.last_processed_message_timestamp
+    def read_last_message_timestamp
+      file = Path.last_message_timestamp
       return nil unless file.exist?
       timestamp = file.read
       return nil if timestamp.nil? or timestamp.empty?

  Modified: lib/droonga/path.rb (+2 -2)
===================================================================
--- lib/droonga/path.rb    2015-04-24 00:50:39 +0900 (00ebe4c)
+++ lib/droonga/path.rb    2015-04-24 00:53:12 +0900 (36478d1)
@@ -61,8 +61,8 @@ module Droonga
         Pathname.new(base_file_name).expand_path(base)
       end
 
-      def last_processed_message_timestamp
-        base + "last-processed-message-timestamp.txt"
+      def last_message_timestamp
+        base + "last-message-timestamp.txt"
       end
 
       def accidental_buffer

  Modified: lib/droonga/serf.rb (+7 -7)
===================================================================
--- lib/droonga/serf.rb    2015-04-24 00:50:39 +0900 (0ed3b6a)
+++ lib/droonga/serf.rb    2015-04-24 00:53:12 +0900 (644893a)
@@ -195,18 +195,18 @@ module Droonga
       role
     end
 
-    def last_processed_message_timestamp
-      get_tag(Tag.last_processed_message_timestamp)
+    def last_message_timestamp
+      get_tag(Tag.last_message_timestamp)
     end
 
-    def latest_last_processed_message_timestamp
-      send_query("export_last_processed_message_timestamp",
+    def latest_last_message_timestamp
+      send_query("export_last_message_timestamp",
                  "node" => @name.to_s)
-      last_processed_message_timestamp
+      last_message_timestamp
     end
 
-    def last_processed_message_timestamp=(timestamp)
-      set_tag(Tag.last_processed_message_timestamp, timestamp)
+    def last_message_timestamp=(timestamp)
+      set_tag(Tag.last_message_timestamp, timestamp)
       # after that you must run update_cluster_state to update the cluster information cache
     end
 

  Modified: lib/droonga/serf/remote_command.rb (+2 -2)
===================================================================
--- lib/droonga/serf/remote_command.rb    2015-04-24 00:50:39 +0900 (e8e1e21)
+++ lib/droonga/serf/remote_command.rb    2015-04-24 00:53:12 +0900 (45b811c)
@@ -121,9 +121,9 @@ module Droonga
         end
       end
 
-      class ExportLastProcessedMessageTimestamp < Base
+      class ExportLastMessageTimestamp < Base
         def process
-          FileUtils.touch(Path.last_processed_message_timestamp.to_s)
+          FileUtils.touch(Path.last_message_timestamp.to_s)
         end
       end
 

  Modified: lib/droonga/serf/tag.rb (+1 -1)
===================================================================
--- lib/droonga/serf/tag.rb    2015-04-24 00:50:39 +0900 (f48af77)
+++ lib/droonga/serf/tag.rb    2015-04-24 00:53:12 +0900 (7691d80)
@@ -37,7 +37,7 @@ module Droonga
           "accept-newer-than"
         end
 
-        def last_processed_message_timestamp
+        def last_message_timestamp
           "last-timestamp"
         end
 
-------------- next part --------------
HTML����������������������������...
Descargar 



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