[Groonga-commit] droonga/droonga-engine at 7fabf54 [master] Put local databases under "DROONGA_BASE_DIR/databases"

Back to archive index

YUKI Hiroshi null+****@clear*****
Thu Sep 18 13:28:20 JST 2014


YUKI Hiroshi	2014-09-18 13:28:20 +0900 (Thu, 18 Sep 2014)

  New Revision: 7fabf540df538fe780769305161b0d0dd8d9c04c
  https://github.com/droonga/droonga-engine/commit/7fabf540df538fe780769305161b0d0dd8d9c04c

  Message:
    Put local databases under "DROONGA_BASE_DIR/databases"

  Modified files:
    lib/droonga/catalog/version1.rb
    lib/droonga/catalog/version2.rb
    lib/droonga/path.rb

  Modified: lib/droonga/catalog/version1.rb (+16 -3)
===================================================================
--- lib/droonga/catalog/version1.rb    2014-09-18 13:08:50 +0900 (c67c00e)
+++ lib/droonga/catalog/version1.rb    2014-09-18 13:28:20 +0900 (013c8f2)
@@ -14,6 +14,8 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
 require "English"
+require "pathname"
+require "fileutils"
 
 require "droonga/catalog/base"
 require "droonga/catalog/dataset"
@@ -51,11 +53,14 @@ module Droonga
             part["partitions"].each do |range, partitions|
               partitions.each do |partition|
                 if partition =~ pattern
-                  path = File.join([device, $POSTMATCH, "db"])
-                  path = File.expand_path(path, base_path)
+                  database_name = $POSTMATCH
+                  path = File.join([device, Path.databases.basename, database_name, "db"])
+                  path = Pathname(path).expand_path(base_path)
+                  migrate_database_location(path, :device => device,
+                                                  :name   => database_name)
                   options = {
                     :dataset => dataset_name,
-                    :database => path,
+                    :database => path.to_s,
                     :n_workers => workers,
                     :plugins => plugins
                   }
@@ -384,6 +389,14 @@ module Droonga
         end
       end
 
+      def migrate_database_location(path, params)
+        old_path = File.join([params[:device], params[:name], "db"])
+        old_path = Pathname(old_path).expand_path(base_path)
+        if old_path.exist? and not path.exist?
+          FileUtils.move(old_path.to_s, path.to_s)
+        end
+      end
+
       class Dataset < Catalog::Dataset
         def compute_routes(args, live_nodes=nil)
           routes = []

  Modified: lib/droonga/catalog/version2.rb (+16 -3)
===================================================================
--- lib/droonga/catalog/version2.rb    2014-09-18 13:08:50 +0900 (6c54aee)
+++ lib/droonga/catalog/version2.rb    2014-09-18 13:28:20 +0900 (5f72700)
@@ -13,6 +13,9 @@
 # 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 "pathname"
+require "fileutils"
+
 require "droonga/address"
 require "droonga/catalog/base"
 require "droonga/catalog/dataset"
@@ -41,11 +44,13 @@ module Droonga
             volume.slices.each do |slice|
               volume_address = slice.volume.address
               if volume_address.node == node
-                path = File.join([device, volume_address.name, "db"])
-                path = File.expand_path(path, base_path)
+                path = File.join([device, Path.databases.basename, volume_address.name, "db"])
+                path = Pathname(path).expand_path(base_path)
+                migrate_database_location(path, :device => device,
+                                                :name   => volume_address.name)
                 options = {
                   :dataset => dataset_name,
-                  :database => path,
+                  :database => path.to_s,
                   :n_workers => n_workers,
                   :plugins => plugins
                 }
@@ -81,6 +86,14 @@ module Droonga
         end
         nodes.sort.uniq
       end
+
+      def migrate_database_location(path, params)
+        old_path = File.join([params[:device], params[:name], "db"])
+        old_path = Pathname(old_path).expand_path(base_path)
+        if old_path.exist? and not path.exist?
+          FileUtils.move(old_path.to_s, path.to_s)
+        end
+      end
     end
   end
 end

  Modified: lib/droonga/path.rb (+4 -0)
===================================================================
--- lib/droonga/path.rb    2014-09-18 13:08:50 +0900 (e58d193)
+++ lib/droonga/path.rb    2014-09-18 13:28:20 +0900 (69c83ad)
@@ -34,6 +34,10 @@ module Droonga
         ENV[BASE_DIR_ENV_NAME] = new_base
       end
 
+      def databases
+        base + "database"
+      end
+
       def state
         base + "state"
       end
-------------- next part --------------
HTML����������������������������...
Download 



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