[Archipelago-submits] [191] trunk/archipelago/lib/archipelago: added a publish-hook in disco and placeholders for the maintenance code in dump

nobody at rubyforge.org nobody at rubyforge.org
Wed Jan 24 10:22:35 EST 2007


Revision: 191
Author:   zond
Date:     2007-01-24 10:22:35 -0500 (Wed, 24 Jan 2007)

Log Message:
-----------
added a publish-hook in disco and placeholders for the maintenance code in dump

Modified Paths:
--------------
    trunk/archipelago/lib/archipelago/disco.rb
    trunk/archipelago/lib/archipelago/dump.rb

Modified: trunk/archipelago/lib/archipelago/disco.rb
===================================================================
--- trunk/archipelago/lib/archipelago/disco.rb	2007-01-24 14:24:58 UTC (rev 190)
+++ trunk/archipelago/lib/archipelago/disco.rb	2007-01-24 15:22:35 UTC (rev 191)
@@ -130,6 +130,14 @@
       end
 
       #
+      # Override this if you want to do something magical before or after you
+      # get published.
+      #
+      def around_publish(&block)
+        yield
+      end
+
+      #
       # Create an Archipelago::Disco::Jockey for this instance using @jockey_options
       # or optionally given <i>:jockey_options</i>.
       #
@@ -137,8 +145,10 @@
       # <i>:service_description</i>.
       #
       def publish!(options = {})
-        @jockey ||= defined?(Archipelago::Disco::MC) ? Archipelago::Disco::MC : Archipelago::Disco::Jockey.new(@jockey_options.merge(options[:jockey_options] || {}))
-        @jockey.publish(Archipelago::Disco::Record.new(@service_description.merge(options[:service_description] || {})))
+        around_publish do
+          @jockey ||= defined?(Archipelago::Disco::MC) ? Archipelago::Disco::MC : Archipelago::Disco::Jockey.new(@jockey_options.merge(options[:jockey_options] || {}))
+          @jockey.publish(Archipelago::Disco::Record.new(@service_description.merge(options[:service_description] || {})))
+        end
       end
 
       #

Modified: trunk/archipelago/lib/archipelago/dump.rb
===================================================================
--- trunk/archipelago/lib/archipelago/dump.rb	2007-01-24 14:24:58 UTC (rev 190)
+++ trunk/archipelago/lib/archipelago/dump.rb	2007-01-24 15:22:35 UTC (rev 191)
@@ -48,7 +48,11 @@
         # instance variables.
         #
         initialize_publishable(options)
+      end
 
+      def around_publish(&publish_block)
+        yield
+        assume_position!
       end
 
       def insert!(key, value, owner_id)
@@ -74,10 +78,36 @@
 
       private
 
+      #
+      # Is supposed to ensure that all the dumps responsible for +key+
+      # has chunks for that key.
+      #
+      def redistribute(key)
+        # IMPLEMENT!
+      end
+
+      #
+      # Is supposed to find my successor and steal those of his keys
+      # that now should belong with me.
+      #
+      def assume_position!
+        # IMPLEMENT ME!!!
+      end
+
+      #
+      # Is supposed to subscribe to :lost-events on all dumps responsible
+      # for +key+ except myself, and redistribute my keys if any of them
+      # drops.
+      #
       def subscribe_as_master(key)
         # IMPLEMENT ME DAMNIT
       end
-      
+
+      #
+      # Is supposed to subscribe to :lost-events on the dump with +owner_id+
+      # and check if I am possibly the new master for those keys, and if I am
+      # then redistribute them.
+      #
       def subscribe_as_slave(owner_id)
         # IMPLEMENT ME AS WELL!
       end




More information about the Archipelago-submits mailing list