couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fdman...@apache.org
Subject svn commit: r1004715 - in /couchdb/branches/new_replicator/src/couchdb: couch_replicator.erl couch_replicator_doc_copiers.erl couch_replicator_rev_finders.erl
Date Tue, 05 Oct 2010 17:05:52 GMT
Author: fdmanana
Date: Tue Oct  5 17:05:52 2010
New Revision: 1004715

URL: http://svn.apache.org/viewvc?rev=1004715&view=rev
Log:
New replicator: removing some no longer necessary code.

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=1004715&r1=1004714&r2=1004715&view=diff
==============================================================================
--- couchdb/branches/new_replicator/src/couchdb/couch_replicator.erl (original)
+++ couchdb/branches/new_replicator/src/couchdb/couch_replicator.erl Tue Oct  5 17:05:52 2010
@@ -296,21 +296,21 @@ handle_info({'EXIT', Pid, normal}, State
         missing_rev_finders = RevFinders,
         missing_revs_queue = RevsQueue
     } = State,
-    case get_value(Pid, RevFinders) of
-    undefined ->
-        case get_value(Pid, DocCopiers) of
-        undefined ->
+    case lists:member(Pid, RevFinders) of
+    false ->
+        case lists:member(Pid, DocCopiers) of
+        false ->
             {stop, {unknown_process_died, Pid, normal}, State};
-        _CopierId ->
-            case lists:keydelete(Pid, 1, DocCopiers) of
+        true ->
+            case DocCopiers -- [Pid] of
             [] ->
                 {stop, normal, do_last_checkpoint(State)};
             DocCopiers2 ->
                 {noreply, State#rep_state{doc_copiers = DocCopiers2}}
             end
         end;
-    _FinderId ->
-        case lists:keydelete(Pid, 1, RevFinders) of
+    true ->
+        case RevFinders -- [Pid] of
         [] ->
             couch_work_queue:close(RevsQueue),
             {noreply, State#rep_state{missing_rev_finders = []}};
@@ -325,19 +325,17 @@ handle_info({'EXIT', Pid, Reason}, State
         missing_rev_finders = RevFinders
     } = State,
     State2 = cancel_timer(State),
-    case get_value(Pid, DocCopiers) of
-    undefined ->
-        case get_value(Pid, RevFinders) of
-        undefined ->
+    case lists:member(Pid, DocCopiers) of
+    false ->
+        case lists:member(Pid, RevFinders) of
+        false ->
             {stop, {unknown_process_died, Pid, Reason}, State2};
-        FinderId ->
-            ?LOG_ERROR("RevsFinder process ~p died with reason: ~p",
-                [FinderId, Reason]),
+        true ->
+            ?LOG_ERROR("RevsFinder ~p died with reason: ~p", [Pid, Reason]),
             {stop, {revs_finder_died, Pid, Reason}, State2}
         end;
-    CopierId ->
-        ?LOG_ERROR("DocCopier process ~p died with reason: ~p",
-            [CopierId, Reason]),
+    true ->
+        ?LOG_ERROR("DocCopier ~p died with reason: ~p", [Pid, Reason]),
         {stop, {doc_copier_died, Pid, Reason}, State2}
     end.
 

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=1004715&r1=1004714&r2=1004715&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 17:05:52 2010
@@ -23,11 +23,10 @@
 
 spawn_doc_copiers(Cp, Source, Target, MissingRevsQueue, CopiersCount) ->
     lists:map(
-        fun(CopierId) ->
-            Pid = spawn_link(fun() ->
-                doc_copy_loop(CopierId, Cp, Source, Target, MissingRevsQueue)
-            end),
-            {Pid, CopierId}
+        fun(_) ->
+            spawn_link(fun() ->
+                doc_copy_loop(Cp, Source, Target, MissingRevsQueue)
+            end)
         end,
         lists:seq(1, CopiersCount)).
 
@@ -40,16 +39,16 @@ spawn_doc_copiers(Cp, Source, Target, Mi
     wfail = 0
 }).
 
-doc_copy_loop(CopierId, Cp, Source, Target, MissingRevsQueue) ->
+doc_copy_loop(Cp, Source, Target, MissingRevsQueue) ->
     Result = case couch_work_queue:dequeue(MissingRevsQueue, ?DOC_BATCH_SIZE) of
     closed ->
-        ?LOG_DEBUG("Doc copier ~p got missing revs queue closed", [CopierId]),
+        ?LOG_DEBUG("Doc copier ~p got missing revs queue closed", [self()]),
         stop;
 
     {ok, [{doc_id, _} | _] = DocIds} ->
         Acc = lists:foldl(
             fun({doc_id, Id}, Acc) ->
-                ?LOG_DEBUG("Doc copier ~p got {doc_id, ~p}", [CopierId, Id]),
+                ?LOG_DEBUG("Doc copier ~p got {doc_id, ~p}", [self(), Id]),
                 {ok, Acc2} = couch_api_wrap:open_doc_revs(
                     Source, Id, all, [],
                     fun(R, A) -> doc_handler(R, nil, Target, A) end, Acc),
@@ -61,7 +60,7 @@ doc_copy_loop(CopierId, Cp, Source, Targ
     {ok, IdRevList} ->
         lists:foldl(
             fun({Id, Revs, PossibleAncestors, Seq} = IdRev, {SrcDb, BulkAcc}) ->
-                ?LOG_DEBUG("Doc copier ~p got ~p", [CopierId, IdRev]),
+                ?LOG_DEBUG("Doc copier ~p got ~p", [self(), IdRev]),
                 SrcDb2 = couch_api_wrap:maybe_reopen_db(SrcDb, Seq),
                 {ok, BulkAcc2} = couch_api_wrap:open_doc_revs(
                     SrcDb2, Id, Revs, [{atts_since, PossibleAncestors}],
@@ -76,7 +75,7 @@ doc_copy_loop(CopierId, Cp, Source, Targ
         #doc_acc{seqs = SeqsDone} = DocAcc2 = bulk_write_docs(DocAcc, Target),
         seqs_done(SeqsDone, Cp),
         send_stats(DocAcc2, Cp),
-        doc_copy_loop(CopierId, Cp, Source2, Target, MissingRevsQueue);
+        doc_copy_loop(Cp, Source2, Target, MissingRevsQueue);
     stop ->
         ok
     end.

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=1004715&r1=1004714&r2=1004715&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 17:05:52 2010
@@ -35,16 +35,15 @@ spawn_missing_rev_finders(_, _, DocIds, 
 spawn_missing_rev_finders(StatsProcess,
         Target, ChangesQueue, MissingRevsQueue, RevFindersCount) ->
     lists:map(
-        fun(FinderId) ->
-            Pid = spawn_link(fun() ->
-                missing_revs_finder_loop(FinderId, StatsProcess,
+        fun(_) ->
+            spawn_link(fun() ->
+                missing_revs_finder_loop(StatsProcess,
                     Target, ChangesQueue, MissingRevsQueue)
-            end),
-            {Pid, FinderId}
+            end)
         end, lists:seq(1, RevFindersCount)).
 
 
-missing_revs_finder_loop(FinderId, Cp, Target, ChangesQueue, RevsQueue) ->
+missing_revs_finder_loop(Cp, Target, ChangesQueue, RevsQueue) ->
     case couch_work_queue:dequeue(ChangesQueue, ?REV_BATCH_SIZE) of
     closed ->
         ok;
@@ -52,10 +51,10 @@ missing_revs_finder_loop(FinderId, Cp, T
         IdRevs = [{Id, [Rev || #rev_info{rev=Rev} <- RevsInfo]} ||
                 #doc_info{id=Id, revs=RevsInfo} <- DocInfos],
         ?LOG_DEBUG("Revs finder ~p got ~p IdRev pairs from queue",
-            [FinderId, length(IdRevs)]),
+            [self(), length(IdRevs)]),
         {ok, Missing} = couch_api_wrap:get_missing_revs(Target, IdRevs),
         ?LOG_DEBUG("Revs finder ~p found ~p missing IdRev pairs",
-            [FinderId, length(Missing)]),
+            [self(), length(Missing)]),
         % Figured out which on the target are missing.
         % Missing contains the id and revs missing, and any possible
         % ancestors that already exist on the target. This enables
@@ -80,7 +79,7 @@ missing_revs_finder_loop(FinderId, Cp, T
                 Count + length(Revs)
             end, 0, Missing),
         send_missing_found(MissingCount, Cp),
-        missing_revs_finder_loop(FinderId, Cp, Target, ChangesQueue, RevsQueue)
+        missing_revs_finder_loop(Cp, Target, ChangesQueue, RevsQueue)
     end.
 
 



Mime
View raw message