[Groonga-commit] droonga/droonga-engine at afdc3a1 [master] Add VolumeCollection#live_volumes to collect volumens from the list of live nodes

Back to archive index

YUKI Hiroshi null+****@clear*****
Fri May 9 13:39:25 JST 2014


YUKI Hiroshi	2014-05-09 13:39:25 +0900 (Fri, 09 May 2014)

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

  Message:
    Add VolumeCollection#live_volumes to collect volumens from the list of live nodes

  Modified files:
    lib/droonga/catalog/volume_collection.rb

  Modified: lib/droonga/catalog/volume_collection.rb (+14 -4)
===================================================================
--- lib/droonga/catalog/volume_collection.rb    2014-05-09 13:21:37 +0900 (966ac9e)
+++ lib/droonga/catalog/volume_collection.rb    2014-05-09 13:39:25 +0900 (8abec35)
@@ -39,14 +39,15 @@ module Droonga
         to_a.hash
       end
 
-      def select(how=nil)
+      def select(how=nil, live_nodes=nil)
+        volumes = live_volumes(live_nodes)
         case how
         when :top
-          [@volumes.first]
+          [volumes.first]
         when :random
-          [@volumes.sample]
+          [volumes.sample]
         when :all
-          @volumes
+          volumes
         else
           super
         end
@@ -56,6 +57,15 @@ module Droonga
         @all_nodes ||= collect_all_nodes
       end
 
+      def live_volumes(live_nodes=nil)
+        return @volumes unless live_nodes
+
+        @volumes.select do |volume|
+          dead_nodes = volume.all_nodes - live_nodes
+          dead_nodes.empty?
+        end
+      end
+
       private
       def collect_all_nodes
         nodes = []
-------------- next part --------------
HTML����������������������������...
Download 



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