diff options
| author | Simon MacMullen <simon@rabbitmq.com> | 2012-11-23 16:52:59 +0000 |
|---|---|---|
| committer | Simon MacMullen <simon@rabbitmq.com> | 2012-11-23 16:52:59 +0000 |
| commit | 613bd3c3b1178da56a6b414f84ddd4724a8fd775 (patch) | |
| tree | ef9ecff7e06ed9b270564ec49bfe20472f2fd43c /src | |
| parent | c0b8d853327b6a066bed78c8723f470a4bf9027e (diff) | |
| download | rabbitmq-server-git-613bd3c3b1178da56a6b414f84ddd4724a8fd775.tar.gz | |
Log progress, and an important optimisation.
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_amqqueue_process.erl | 2 | ||||
| -rw-r--r-- | src/rabbit_mirror_queue_master.erl | 29 |
2 files changed, 23 insertions, 8 deletions
diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl index 68ae481674..07f4c3b190 100644 --- a/src/rabbit_amqqueue_process.erl +++ b/src/rabbit_amqqueue_process.erl @@ -1308,7 +1308,7 @@ handle_cast(sync_mirrors, rabbit_mirror_queue_master -> {ok, #amqqueue{slave_pids = SPids, sync_slave_pids = SSPids}} = rabbit_amqqueue:lookup(Name), - rabbit_mirror_queue_master:sync_mirrors(SPids -- SSPids, BQS); + rabbit_mirror_queue_master:sync_mirrors(SPids -- SSPids, Name, BQS); _ -> ok end, diff --git a/src/rabbit_mirror_queue_master.erl b/src/rabbit_mirror_queue_master.erl index bc2d21acd8..05075d0f2b 100644 --- a/src/rabbit_mirror_queue_master.erl +++ b/src/rabbit_mirror_queue_master.erl @@ -28,7 +28,7 @@ -export([promote_backing_queue_state/7, sender_death_fun/0, depth_fun/0]). --export([init_with_existing_bq/3, stop_mirroring/1, sync_mirrors/2]). +-export([init_with_existing_bq/3, stop_mirroring/1, sync_mirrors/3]). -behaviour(rabbit_backing_queue). @@ -127,8 +127,14 @@ stop_mirroring(State = #state { coordinator = CPid, stop_all_slaves(shutdown, State), {BQ, BQS}. -sync_mirrors(SPids, #state { backing_queue = BQ, - backing_queue_state = BQS }) -> +sync_mirrors([], Name, _State) -> + rabbit_log:info("Synchronising ~s: nothing to do~n", + [rabbit_misc:rs(Name)]), + ok; +sync_mirrors(SPids, Name, #state { backing_queue = BQ, + backing_queue_state = BQS }) -> + rabbit_log:info("Synchronising ~s with slaves ~p~n", + [rabbit_misc:rs(Name), SPids]), Ref = make_ref(), SPidsMRefs = [begin SPid ! {sync_start, Ref, self()}, @@ -147,11 +153,20 @@ sync_mirrors(SPids, #state { backing_queue = BQ, end], SPid1 =/= dead], [erlang:demonitor(MRef) || {_, MRef} <- SPidsMRefs], - BQ:fold(fun (M = #basic_message{}, none) -> - [SPid ! {sync_message, Ref, M} || SPid <- SPids1], - none - end, none, BQS), + {Total, _BQS} = + BQ:fold(fun (M = #basic_message{}, I) -> + [SPid ! {sync_message, Ref, M} || SPid <- SPids1], + case I rem 1000 of + 0 -> rabbit_log:info( + "Synchronising ~s: ~p messages~n", + [rabbit_misc:rs(Name), I]); + _ -> ok + end, + I + 1 + end, 0, BQS), [SPid ! {sync_complete, Ref} || SPid <- SPids1], + rabbit_log:info("Synchronising ~s: ~p messages; complete~n", + [rabbit_misc:rs(Name), Total]), ok. terminate({shutdown, dropped} = Reason, |
