You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by fd...@apache.org on 2010/10/05 11:51:41 UTC
svn commit: r1004594 - in /couchdb/branches/new_replicator/src/couchdb:
couch_replicator.erl couch_replicator_doc_copiers.erl
couch_replicator_rev_finders.erl
Author: fdmanana
Date: Tue Oct 5 09:51:41 2010
New Revision: 1004594
URL: http://svn.apache.org/viewvc?rev=1004594&view=rev
Log:
New replicator: aggregate stats messages.
Modified:
couchdb/branches/new_replicator/src/couchdb/couch_replicator.erl
couchdb/branches/new_replicator/src/couchdb/couch_replicator_doc_copiers.erl
couchdb/branches/new_replicator/src/couchdb/couch_replicator_rev_finders.erl
Modified: couchdb/branches/new_replicator/src/couchdb/couch_replicator.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/new_replicator/src/couchdb/couch_replicator.erl?rev=1004594&r1=1004593&r2=1004594&view=diff
==============================================================================
--- couchdb/branches/new_replicator/src/couchdb/couch_replicator.erl (original)
+++ couchdb/branches/new_replicator/src/couchdb/couch_replicator.erl Tue Oct 5 09:51:41 2010
@@ -365,10 +365,8 @@ handle_cast({seq_start, {Seq, NumChanges
handle_cast({seq_changes_done, Changes}, State) ->
{noreply, process_seq_changes_done(Changes, State)};
-handle_cast({add_stat, {StatPos, Val}}, #rep_state{stats = Stats} = State) ->
- Stat = element(StatPos, Stats),
- NewStats = setelement(StatPos, Stats, Stat + Val),
- {noreply, State#rep_state{stats = NewStats}};
+handle_cast({add_stats, StatsInc}, #rep_state{stats = Stats} = State) ->
+ {noreply, State#rep_state{stats = sum_stats([Stats, StatsInc])}};
handle_cast(Msg, State) ->
?LOG_ERROR("Replicator received an unexpected asynchronous call: ~p", [Msg]),
@@ -730,3 +728,20 @@ get_next_through_seq(Current, SmallestIn
ordsets:del_element(LargestDone, NewDone), [LargestDone | NewDone])
end.
+
+sum_stats([Stats1 | RestStats]) ->
+ lists:foldl(
+ fun(Stats, Acc) ->
+ #rep_stats{
+ missing_checked = Stats#rep_stats.missing_checked +
+ Acc#rep_stats.missing_checked,
+ missing_found = Stats#rep_stats.missing_found +
+ Acc#rep_stats.missing_found,
+ docs_read = Stats#rep_stats.docs_read + Acc#rep_stats.docs_read,
+ docs_written = Stats#rep_stats.docs_written +
+ Acc#rep_stats.docs_written,
+ doc_write_failures = Stats#rep_stats.doc_write_failures +
+ Acc#rep_stats.doc_write_failures
+ }
+ end,
+ Stats1, RestStats).
Modified: couchdb/branches/new_replicator/src/couchdb/couch_replicator_doc_copiers.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/new_replicator/src/couchdb/couch_replicator_doc_copiers.erl?rev=1004594&r1=1004593&r2=1004594&view=diff
==============================================================================
--- couchdb/branches/new_replicator/src/couchdb/couch_replicator_doc_copiers.erl (original)
+++ couchdb/branches/new_replicator/src/couchdb/couch_replicator_doc_copiers.erl Tue Oct 5 09:51:41 2010
@@ -73,12 +73,9 @@ doc_copy_loop(CopierId, Cp, Source, Targ
end,
case Result of
{Source2, DocAcc} ->
- maybe_send_stat(DocAcc#doc_acc.read, #rep_stats.docs_read, Cp),
- #doc_acc{written = W, wfail = Wf, seqs = SeqsDone} =
- bulk_write_docs(DocAcc, Target),
+ #doc_acc{seqs = SeqsDone} = DocAcc2 = bulk_write_docs(DocAcc, Target),
seqs_done(SeqsDone, Cp),
- maybe_send_stat(W, #rep_stats.docs_written, Cp),
- maybe_send_stat(Wf, #rep_stats.doc_write_failures, Cp),
+ send_stats(DocAcc2, Cp),
doc_copy_loop(CopierId, Cp, Source2, Target, MissingRevsQueue);
stop ->
ok
@@ -162,8 +159,10 @@ seqs_done(SeqCounts, Cp) ->
ok = gen_server:cast(Cp, {seq_changes_done, SeqCounts}).
-maybe_send_stat(0, _StatPos, _Cp) ->
- ok;
-maybe_send_stat(Value, StatPos, Cp) ->
- ok = gen_server:cast(Cp, {add_stat, {StatPos, Value}}).
-
+send_stats(#doc_acc{read = R, written = W, wfail = Wf}, Cp) ->
+ Stats = #rep_stats{
+ docs_read = R,
+ docs_written = W,
+ doc_write_failures = Wf
+ },
+ ok = gen_server:cast(Cp, {add_stats, Stats}).
Modified: couchdb/branches/new_replicator/src/couchdb/couch_replicator_rev_finders.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/new_replicator/src/couchdb/couch_replicator_rev_finders.erl?rev=1004594&r1=1004593&r2=1004594&view=diff
==============================================================================
--- couchdb/branches/new_replicator/src/couchdb/couch_replicator_rev_finders.erl (original)
+++ couchdb/branches/new_replicator/src/couchdb/couch_replicator_rev_finders.erl Tue Oct 5 09:51:41 2010
@@ -79,7 +79,7 @@ missing_revs_finder_loop(FinderId, Cp, T
ok = couch_work_queue:queue(RevsQueue, {Id, Revs, PAs, Seq}),
Count + length(Revs)
end, 0, Missing),
- maybe_add_stat(MissingCount, #rep_stats.missing_found, Cp),
+ send_missing_found(MissingCount, Cp),
missing_revs_finder_loop(FinderId, Cp, Target, ChangesQueue, RevsQueue)
end.
@@ -95,10 +95,10 @@ report_non_missing(RevsDict, Cp) ->
end.
-maybe_add_stat(0, _StatPos, _Cp) ->
+send_missing_found(0, _Cp) ->
ok;
-maybe_add_stat(Value, StatPos, Cp) ->
- ok = gen_server:cast(Cp, {add_stat, {StatPos, Value}}).
+send_missing_found(Value, Cp) ->
+ ok = gen_server:cast(Cp, {add_stats, #rep_stats{missing_found = Value}}).
remove_missing(IdRevsSeqDict, []) ->