From 4074889c30690a3effef4fe49fa5a75f7d6c8e51 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 18 Nov 2011 10:23:50 +0000 Subject: [PATCH] admin: add support for replicate_now command --- lib/mogilefs/admin.rb | 10 ++++++++++ lib/mogilefs/backend.rb | 1 + test/test_fresh.rb | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/lib/mogilefs/admin.rb b/lib/mogilefs/admin.rb index abacfc8..51d507d 100644 --- a/lib/mogilefs/admin.rb +++ b/lib/mogilefs/admin.rb @@ -249,6 +249,16 @@ class MogileFS::Admin < MogileFS::Client ! @backend.set_state(:host => host, :device => device, :state => state).nil? end + # reschedules all deferred replication, returns a hash with the number + # of files rescheduled: + # + # admin.replicate_now => { "count" => 5 } + def replicate_now + rv = @backend.replicate_now + rv["count"] = rv["count"].to_i + rv + end + protected unless defined? $TESTING ## diff --git a/lib/mogilefs/backend.rb b/lib/mogilefs/backend.rb index 596e320..f4c7254 100644 --- a/lib/mogilefs/backend.rb +++ b/lib/mogilefs/backend.rb @@ -113,6 +113,7 @@ class MogileFS::Backend add_command :update_host add_command :delete_host add_command :set_state + add_command :replicate_now # Errors copied from MogileFS/Worker/Query.pm add_error 'dup' diff --git a/test/test_fresh.rb b/test/test_fresh.rb index cdff2f1..9b279c6 100644 --- a/test/test_fresh.rb +++ b/test/test_fresh.rb @@ -95,6 +95,10 @@ EOF assert_equal [], @admin.get_devices end + def test_replicate_now + assert_equal({"count" => 0}, @admin.replicate_now) + end + def test_create_update_delete_class domain = "rbmogtest#{Time.now.strftime('%Y%m%d%H%M%S')}.#{uuid}" @admin.create_domain(domain) -- 2.11.4.GIT