couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From beno...@apache.org
Subject [3/8] refactor couch_replicator. close #COUCHDB-1323 .
Date Mon, 05 Dec 2011 09:33:29 GMT
http://git-wip-us.apache.org/repos/asf/couchdb/blob/f913ca6e/src/couch_replicator/src/couch_replicator_worker.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator/src/couch_replicator_worker.erl b/src/couch_replicator/src/couch_replicator_worker.erl
index aa04dc5..b42f81f 100644
--- a/src/couch_replicator/src/couch_replicator_worker.erl
+++ b/src/couch_replicator/src/couch_replicator_worker.erl
@@ -21,7 +21,7 @@
 -export([handle_call/3, handle_cast/2, handle_info/2]).
 
 -include("couch_db.hrl").
--include("couch_api_wrap.hrl").
+-include("couch_replicator_api_wrap.hrl").
 -include("couch_replicator.hrl").
 
 % TODO: maybe make both buffer max sizes configurable
@@ -295,14 +295,14 @@ spawn_doc_reader(Source, Target, FetchParams) ->
 
 fetch_doc(Source, {Id, Revs, PAs}, DocHandler, Acc) ->
     try
-        couch_api_wrap:open_doc_revs(
+        couch_replicator_api_wrap:open_doc_revs(
             Source, Id, Revs, [{atts_since, PAs}], DocHandler, Acc)
     catch
     throw:{missing_stub, _} ->
         ?LOG_ERROR("Retrying fetch and update of document `~p` due to out of "
             "sync attachment stubs. Missing revisions are: ~s",
             [Id, couch_doc:revs_to_strs(Revs)]),
-        couch_api_wrap:open_doc_revs(Source, Id, Revs, [], DocHandler, Acc)
+        couch_replicator_api_wrap:open_doc_revs(Source, Id, Revs, [], DocHandler, Acc)
     end.
 
 
@@ -444,9 +444,9 @@ flush_docs(_Target, []) ->
     #rep_stats{};
 
 flush_docs(Target, DocList) ->
-    {ok, Errors} = couch_api_wrap:update_docs(
+    {ok, Errors} = couch_replicator_api_wrap:update_docs(
         Target, DocList, [delay_commit], replicated_changes),
-    DbUri = couch_api_wrap:db_uri(Target),
+    DbUri = couch_replicator_api_wrap:db_uri(Target),
     lists:foreach(
         fun({Props}) ->
             ?LOG_ERROR("Replicator: couldn't write document `~s`, revision `~s`,"
@@ -460,12 +460,12 @@ flush_docs(Target, DocList) ->
     }.
 
 flush_doc(Target, #doc{id = Id, revs = {Pos, [RevId | _]}} = Doc) ->
-    try couch_api_wrap:update_doc(Target, Doc, [], replicated_changes) of
+    try couch_replicator_api_wrap:update_doc(Target, Doc, [], replicated_changes) of
     {ok, _} ->
         ok;
     Error ->
         ?LOG_ERROR("Replicator: error writing document `~s` to `~s`: ~s",
-            [Id, couch_api_wrap:db_uri(Target), couch_util:to_binary(Error)]),
+            [Id, couch_replicator_api_wrap:db_uri(Target), couch_util:to_binary(Error)]),
         Error
     catch
     throw:{missing_stub, _} = MissingStub ->
@@ -474,13 +474,13 @@ flush_doc(Target, #doc{id = Id, revs = {Pos, [RevId | _]}} = Doc) ->
         ?LOG_ERROR("Replicator: couldn't write document `~s`, revision `~s`,"
             " to target database `~s`. Error: `~s`, reason: `~s`.",
             [Id, couch_doc:rev_to_str({Pos, RevId}),
-                couch_api_wrap:db_uri(Target), to_binary(Error), to_binary(Reason)]),
+                couch_replicator_api_wrap:db_uri(Target), to_binary(Error), to_binary(Reason)]),
         {error, Error};
     throw:Err ->
         ?LOG_ERROR("Replicator: couldn't write document `~s`, revision `~s`,"
             " to target database `~s`. Error: `~s`.",
             [Id, couch_doc:rev_to_str({Pos, RevId}),
-                couch_api_wrap:db_uri(Target), to_binary(Err)]),
+                couch_replicator_api_wrap:db_uri(Target), to_binary(Err)]),
         {error, Err}
     end.
 
@@ -492,7 +492,7 @@ find_missing(DocInfos, Target) ->
             {[{Id, Revs} | IdRevAcc], CountAcc + length(Revs)}
         end,
         {[], 0}, DocInfos),
-    {ok, Missing} = couch_api_wrap:get_missing_revs(Target, IdRevs),
+    {ok, Missing} = couch_replicator_api_wrap:get_missing_revs(Target, IdRevs),
     MissingRevsCount = lists:foldl(
         fun({_Id, MissingRevs, _PAs}, Acc) -> Acc + length(MissingRevs) end,
         0, Missing),

http://git-wip-us.apache.org/repos/asf/couchdb/blob/f913ca6e/src/couch_replicator/test/001-httpc-pool.t
----------------------------------------------------------------------
diff --git a/src/couch_replicator/test/001-httpc-pool.t b/src/couch_replicator/test/001-httpc-pool.t
index 90adcca..a7bde6c 100755
--- a/src/couch_replicator/test/001-httpc-pool.t
+++ b/src/couch_replicator/test/001-httpc-pool.t
@@ -177,7 +177,7 @@ spawn_client(Pool) ->
     Parent = self(),
     Ref = make_ref(),
     Pid = spawn(fun() ->
-        {ok, Worker} = couch_httpc_pool:get_worker(Pool),
+        {ok, Worker} = couch_replicator_httpc_pool:get_worker(Pool),
         loop(Parent, Ref, Worker, Pool)
     end),
     {Pid, Ref}.
@@ -233,7 +233,7 @@ loop(Parent, Ref, Worker, Pool) ->
             Parent ! {worker, Ref, Worker},
             loop(Parent, Ref, Worker, Pool);
         stop ->
-            couch_httpc_pool:release_worker(Pool, Worker),
+            couch_replicator_httpc_pool:release_worker(Pool, Worker),
             Parent ! {stop, Ref}
     end.
 
@@ -241,10 +241,10 @@ loop(Parent, Ref, Worker, Pool) ->
 spawn_pool() ->
     Host = couch_config:get("httpd", "bind_address", "127.0.0.1"),
     Port = couch_config:get("httpd", "port", "5984"),
-    {ok, Pool} = couch_httpc_pool:start_link(
+    {ok, Pool} = couch_replicator_httpc_pool:start_link(
         "http://" ++ Host ++ ":5984", [{max_connections, 3}]),
     Pool.
 
 
 stop_pool(Pool) ->
-    ok = couch_httpc_pool:stop(Pool).
+    ok = couch_replicator_httpc_pool:stop(Pool).

http://git-wip-us.apache.org/repos/asf/couchdb/blob/f913ca6e/src/couchdb/couch_primary_sup.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_primary_sup.erl b/src/couchdb/couch_primary_sup.erl
index ec141e9..150b92e 100644
--- a/src/couchdb/couch_primary_sup.erl
+++ b/src/couchdb/couch_primary_sup.erl
@@ -49,12 +49,12 @@ init([]) ->
             brutal_kill,
             worker,
             dynamic},
-        {couch_replication_supervisor,
-            {couch_rep_sup, start_link, []},
+        {couch_replicator_job_sup,
+            {couch_replicator_job_sup, start_link, []},
             permanent,
             infinity,
             supervisor,
-            [couch_rep_sup]},
+            [couch_replicator_job_sup]},
         {couch_log,
             {couch_log, start_link, []},
             permanent,


Mime
View raw message