[Archipelago-submits] [220] trunk/archipelago: made debug output from dump better.

nobody at rubyforge.org nobody at rubyforge.org
Sun Mar 4 13:49:54 EST 2007


Revision: 220
Author:   zond
Date:     2007-03-04 13:49:53 -0500 (Sun, 04 Mar 2007)

Log Message:
-----------
made debug output from dump better. made console services able to select drburi as well. lowered validation interval slightly. added lots of debug stuff to dump. made dump not run redistribute within the each-block when redistributing orphan keys. added options to hashish db getters. made sanitation synchronize on a unique lock when fetching instead of the return value.

Modified Paths:
--------------
    trunk/archipelago/lib/archipelago/disco.rb
    trunk/archipelago/lib/archipelago/dump.rb
    trunk/archipelago/lib/archipelago/hashish.rb
    trunk/archipelago/lib/archipelago/sanitation.rb
    trunk/archipelago/script/officer.rb
    trunk/archipelago/script/pirate.rb
    trunk/archipelago/script/services.rb

Modified: trunk/archipelago/lib/archipelago/disco.rb
===================================================================
--- trunk/archipelago/lib/archipelago/disco.rb	2007-02-22 22:33:52 UTC (rev 219)
+++ trunk/archipelago/lib/archipelago/disco.rb	2007-03-04 18:49:53 UTC (rev 220)
@@ -54,7 +54,7 @@
     # Default pause between trying to validate all services we
     # know about.
     #
-    VALIDATION_INTERVAL = 60
+    VALIDATION_INTERVAL = 30
     #
     # Only save stuff that we KNOW we want.
     #

Modified: trunk/archipelago/lib/archipelago/dump.rb
===================================================================
--- trunk/archipelago/lib/archipelago/dump.rb	2007-02-22 22:33:52 UTC (rev 219)
+++ trunk/archipelago/lib/archipelago/dump.rb	2007-03-04 18:49:53 UTC (rev 220)
@@ -125,6 +125,7 @@
         values = @db.duplicates(key).collect do |value|
           [value[0...4], value[4..-1]]
         end
+        return values
       end
 
       #
@@ -178,6 +179,7 @@
             @officer.redistribute(key)
             @db.delete(key)
           rescue Archipelago::Sanitation::NotEnoughDataException => e
+            @debug_callable.call("#{service_id}.check_key(#{key}) got #{e}: #{PP.pp(e.backtrace, "")}") if @debug_callable
             # What shall we do in this case? 
             # * Nothing, and wait for the admins to make a manual check?
             # * Send an email someplace?
@@ -211,7 +213,7 @@
                 break if check_key(key)
               end
             rescue Exception => e
-              # /moo
+              @debug_callable.call("#{service_id}.start_edge_check() got #{e}: #{PP.pp(e.backtrace, "")}") if @debug_callable
             end
             sleep(@check_interval)
           end
@@ -242,6 +244,7 @@
           @debug_callable.call("#{service_id}.redistribute_key(#{key}) called") if @debug_callable
           @officer.redistribute(key)
         rescue Archipelago::Sanitation::NotEnoughDataException => e
+          @debug_callable.call("#{service_id}.redistribute_key(#{key}) got #{e}: #{PP.pp(e.backtrace, "")}") if @debug_callable
           # What shall we do in this case? 
           # * Nothing, and wait for the admins to make a manual check?
           # * Send an email someplace?
@@ -263,20 +266,24 @@
       #
       def lost_peer(record)
         @debug_callable.call("#{service_id}.lost_peer(#{record[:service_id]}) called") if @debug_callable
+        keys_to_redistribute = []
         if right_before?(record[:service_id])
           @debug_callable.call("#{service_id}.lost_peer(#{record[:service_id]}) is right_before, redistributing from #{@officer.second_master_to(service_id)}") if @debug_callable
           @db.reverse_each_key do |key|
-            redistribute_key(key)
+            keys_to_redistribute << key
             break if key < @officer.second_master_to(service_id)
           end
         end
         if right_after?(record[:service_id])
           @debug_callable.call("#{service_id}.lost_peer(#{record[:service_id]}) is right_after, redistributing up to #{record[:service_id]}") if @debug_callable
           @db.each_key do |key|
-            redistribute_key(key)
+            keys_to_redistribute << key
             break if key > record[:service_id]
           end
         end
+        keys_to_redistribute.each do |key|
+          redistribute_key(key)
+        end
       end
 
     end

Modified: trunk/archipelago/lib/archipelago/hashish.rb
===================================================================
--- trunk/archipelago/lib/archipelago/hashish.rb	2007-02-22 22:33:52 UTC (rev 219)
+++ trunk/archipelago/lib/archipelago/hashish.rb	2007-03-04 18:49:53 UTC (rev 220)
@@ -271,13 +271,13 @@
         return hashish
       end
       #
-      # Returns something acting like an uncached Berkeley Hash DB instance allowing duplicate entries
+      # Returns something acting like a Berkeley Hash DB instance allowing duplicate entries
       # and transactions using +name+.
       #
-      def get_dup_tree(name)
+      def get_dup_tree(name, flags = BDB::CREATE | BDB::NOMMAP)
         db = BDB::Hash.open(Pathname.new(File.join(@env.home, name)).expand_path, 
                             nil, 
-                            BDB::CREATE | BDB::NOMMAP, 
+                            flags,
                             0,
                             "env" => @env,
                             "set_flags" => BDB::DUP)
@@ -285,10 +285,10 @@
         return db
       end
       #
-      # Returns something acting like an uncached Berkeley Hash DB instance using +name+.
+      # Returns something acting like a Berkeley Hash DB instance using +name+.
       #
-      def get_hashish(name)
-        db = @env.open_db(BDB::HASH, name, nil, BDB::CREATE | BDB::NOMMAP)
+      def get_hashish(name, flags = BDB::CREATE | BDB::NOMMAP)
+        db = @env.open_db(BDB::HASH, name, nil, flags)
         @bdb_dbs << db
         return db
       end

Modified: trunk/archipelago/lib/archipelago/sanitation.rb
===================================================================
--- trunk/archipelago/lib/archipelago/sanitation.rb	2007-02-22 22:33:52 UTC (rev 219)
+++ trunk/archipelago/lib/archipelago/sanitation.rb	2007-03-04 18:49:53 UTC (rev 220)
@@ -214,18 +214,17 @@
         newest_timestamp = "\000\000\000\000"
         threads = []
         rval = Oneliner::SuperString.new
-        rval.extend(MonitorMixin)
+        lock = Archipelago::Current::Lock.new
 
         dump_hash.t_each do |dump_id, nr_of_chunks_available|
           site = @sites[dump_id][:service]
           begin
             chunks = site.fetch(key)
-            rval.mon_synchronize do
+            lock.mon_synchronize do
               while chunks.size > 0
                 t, data = chunks.shift
                 if t > newest_timestamp
                   rval = Oneliner::SuperString.new
-                  rval.extend(MonitorMixin)
                   newest_timestamp = t
                 end
                 

Modified: trunk/archipelago/script/officer.rb
===================================================================
--- trunk/archipelago/script/officer.rb	2007-02-22 22:33:52 UTC (rev 219)
+++ trunk/archipelago/script/officer.rb	2007-03-04 18:49:53 UTC (rev 220)
@@ -5,6 +5,6 @@
 begin
   DRb.uri
 rescue DRb::DRbServerNotFound
-  DRb.start_service
+  DRb.start_service(ENV["DRBURI"])
 end
 @o = Archipelago::Sanitation::Officer.new

Modified: trunk/archipelago/script/pirate.rb
===================================================================
--- trunk/archipelago/script/pirate.rb	2007-02-22 22:33:52 UTC (rev 219)
+++ trunk/archipelago/script/pirate.rb	2007-03-04 18:49:53 UTC (rev 220)
@@ -5,7 +5,7 @@
 begin
   DRb.uri
 rescue DRb::DRbServerNotFound
-  DRb.start_service
+  DRb.start_service(ENV["DRBURI"])
 end
 @p = Archipelago::Pirate::Captain.new
 @p.evaluate!(File.join(File.dirname(__FILE__), 'overloads.rb'))

Modified: trunk/archipelago/script/services.rb
===================================================================
--- trunk/archipelago/script/services.rb	2007-02-22 22:33:52 UTC (rev 219)
+++ trunk/archipelago/script/services.rb	2007-03-04 18:49:53 UTC (rev 220)
@@ -26,7 +26,7 @@
 c = Archipelago::Treasure::Chest.new(:persistence_provider => Archipelago::Hashish::BerkeleyHashishProvider.new(Pathname.new(File.join(ARGV[0], "chest"))))
 c.publish!
 puts "published #{c.class} with id #{c.service_id}"
-d = Archipelago::Dump::Site.new(:debug_callable => Proc.new do |msg| puts msg end, 
+d = Archipelago::Dump::Site.new(:debug_callable => Proc.new do |msg| puts "#{$$}:#{Thread.current}:#{Time.new.to_f}: #{msg}" end, 
                                 :persistence_provider => Archipelago::Hashish::BerkeleyHashishProvider.new(Pathname.new(File.join(ARGV[0], "dump"))))
 d.publish!
 puts "published #{d.class} with id #{d.service_id}"




More information about the Archipelago-submits mailing list