[Groonga-commit] droonga/droonga-engine at 69938dd [buffered-forward] Restart the server manually when the metadata is modified

アーカイブの一覧に戻る

YUKI Hiroshi null+****@clear*****
Thu Jan 22 17:46:46 JST 2015


YUKI Hiroshi	2015-01-22 17:46:46 +0900 (Thu, 22 Jan 2015)

  New Revision: 69938dd436af926b6c8c6260c3cc3b557510b67f
  https://github.com/droonga/droonga-engine/commit/69938dd436af926b6c8c6260c3cc3b557510b67f

  Message:
    Restart the server manually when the metadata is modified

  Added files:
    lib/droonga/restarter.rb
  Modified files:
    bin/droonga-engine-absorb-data
    lib/droonga/command/remote.rb
    lib/droonga/engine.rb
    lib/droonga/serf.rb

  Modified: bin/droonga-engine-absorb-data (+2 -0)
===================================================================
--- bin/droonga-engine-absorb-data    2015-01-22 17:17:40 +0900 (23b2ced)
+++ bin/droonga-engine-absorb-data    2015-01-22 17:46:46 +0900 (f015155)
@@ -27,6 +27,7 @@ require "droonga/data_absorber"
 require "droonga/serf"
 require "droonga/client"
 require "droonga/node_metadata"
+require "droonga/restarter"
 
 class AbsorbDataCommand
   def run
@@ -216,6 +217,7 @@ class AbsorbDataCommand
     if timestamp and not timestamp.empty?
       metadata = NodeMetadata.new
       metadata.set(:effective_message_timestamp, timestamp)
+      Droonga::Restarter.restart
     end
   end
 

  Modified: lib/droonga/command/remote.rb (+12 -2)
===================================================================
--- lib/droonga/command/remote.rb    2015-01-22 17:17:40 +0900 (065d9be)
+++ lib/droonga/command/remote.rb    2015-01-22 17:46:46 +0900 (b9f53d9)
@@ -14,6 +14,7 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
 require "json"
+require "fileutils"
 
 require "droonga/path"
 require "droonga/serf"
@@ -24,6 +25,7 @@ require "droonga/catalog_fetcher"
 require "droonga/data_absorber"
 require "droonga/safe_file_writer"
 require "droonga/service_installation"
+require "droonga/restarter"
 
 module Droonga
   module Command
@@ -105,11 +107,12 @@ module Droonga
         def process
           metadata = NodeMetadata.new
           metadata.set(@params["key"], @params["value"])
+          Restarter.restart
         end
       end
 
       class Join < Base
-        def process
+        def processt
           log("type = #{type}")
           case type
           when "replica"
@@ -233,14 +236,17 @@ module Droonga
 
           metadata = NodeMetadata.new
           metadata.set(:absorbing, true)
+          Restarter.restart(5)
+
           DataAbsorber.absorb(:dataset          => dataset_name,
                               :source_host      => source_host,
                               :destination_host => joining_host,
                               :port             => port,
                               :tag              => tag,
                               :messages_per_second => messages_per_second)
+
           metadata.delete(:absorbing)
-          sleep(1)
+          Restarter.restart(5)
         end
       end
 
@@ -271,6 +277,8 @@ module Droonga
 
           metadata = NodeMetadata.new
           metadata.set(:absorbing, true)
+          Restarter.restart(5)
+
           DataAbsorber.absorb(:dataset          => dataset_name,
                               :source_host      => source,
                               :destination_host => host,
@@ -278,7 +286,9 @@ module Droonga
                               :tag              => tag,
                               :messages_per_second => messages_per_second,
                               :client           => "droonga-send")
+
           metadata.delete(:absorbing)
+          Restarter.restart(5)
         end
 
         private

  Modified: lib/droonga/engine.rb (+1 -10)
===================================================================
--- lib/droonga/engine.rb    2015-01-22 17:17:40 +0900 (88e8f7c)
+++ lib/droonga/engine.rb    2015-01-22 17:46:46 +0900 (573e659)
@@ -25,6 +25,7 @@ require "droonga/catalog_loader"
 require "droonga/dispatcher"
 require "droonga/file_observer"
 require "droonga/node_metadata"
+require "droonga/restarter"
 
 module Droonga
   class Engine
@@ -44,13 +45,6 @@ module Droonga
 
       @dispatcher = create_dispatcher
 
-      @node_metadata_observer = FileObserver.new(loop, Path.node_metadata)
-      @node_metadata_observer.on_change = lambda do
-        logger.trace("reloading node_metadata: start")
-        @node_metadata.reload
-        logger.trace("reloading node_metadata: done")
-      end
-
       @on_ready = nil
     end
 
@@ -61,7 +55,6 @@ module Droonga
       end
       @state.start
       @cluster.start
-      @node_metadata_observer.start
       @dispatcher.start
       logger.trace("start: done")
     end
@@ -69,7 +62,6 @@ module Droonga
     def stop_gracefully
       logger.trace("stop_gracefully: start")
       @cluster.stop_observe
-      @node_metadata_observer.stop
       on_finish = lambda do
         logger.trace("stop_gracefully/on_finish: start")
         save_last_processed_message_timestamp
@@ -95,7 +87,6 @@ module Droonga
       logger.trace("stop_immediately: start")
       save_last_processed_message_timestamp
       @cluster.stop_observe
-      @node_metadata_observer.stop
       @dispatcher.stop_immediately
       @cluster.shutdown
       @state.shutdown

  Added: lib/droonga/restarter.rb (+32 -0) 100644
===================================================================
--- /dev/null
+++ lib/droonga/restarter.rb    2015-01-22 17:46:46 +0900 (26f81cd)
@@ -0,0 +1,32 @@
+# Copyright (C) 2015 Droonga Project
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1 as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+require "fileutils"
+require "droonga/path"
+
+module Droonga
+  class Restarter
+    class << self
+      def restart(wait_for_next=nil)
+        new.restart(wait_for_next)
+      end
+    end
+
+    def restart(wait_for_next=nil)
+      FileUtils.touch(Path.restart.to_s)
+      sleep(wait_for_next) if wait_for_next
+    end
+  end
+end

  Modified: lib/droonga/serf.rb (+3 -0)
===================================================================
--- lib/droonga/serf.rb    2015-01-22 17:17:40 +0900 (d68cdab)
+++ lib/droonga/serf.rb    2015-01-22 17:46:46 +0900 (d008689)
@@ -14,6 +14,7 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
 require "json"
+require "fileutils"
 
 require "droonga/path"
 require "droonga/loggable"
@@ -25,6 +26,7 @@ require "droonga/serf/command"
 require "droonga/line_buffer"
 require "droonga/safe_file_writer"
 require "droonga/service_installation"
+require "droonga/restarter"
 
 module Droonga
   class Serf
@@ -150,6 +152,7 @@ module Droonga
       new_role ||= NodeMetadata::Role::SERVICE_PROVIDER
       set_tag("role", new_role)
       @node_metadata.role = new_role
+      Restarter.restart
     end
 
     def cluster_id
-------------- next part --------------
HTML����������������������������...
ダウンロード 



More information about the Groonga-commit mailing list
アーカイブの一覧に戻る