couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fdman...@apache.org
Subject svn commit: r991573 - in /couchdb/branches/new_replicator: etc/couchdb/default.ini.tpl.in src/couchdb/couch_api_wrap.erl src/couchdb/couch_api_wrap_httpc.erl
Date Wed, 01 Sep 2010 15:35:15 GMT
Author: fdmanana
Date: Wed Sep  1 15:35:15 2010
New Revision: 991573

URL: http://svn.apache.org/viewvc?rev=991573&view=rev
Log:
New replicator: simplifying some code. No longer using HTTP pipeline to avoid having connections
shared between different replications to the same host and port.

Modified:
    couchdb/branches/new_replicator/etc/couchdb/default.ini.tpl.in
    couchdb/branches/new_replicator/src/couchdb/couch_api_wrap.erl
    couchdb/branches/new_replicator/src/couchdb/couch_api_wrap_httpc.erl

Modified: couchdb/branches/new_replicator/etc/couchdb/default.ini.tpl.in
URL: http://svn.apache.org/viewvc/couchdb/branches/new_replicator/etc/couchdb/default.ini.tpl.in?rev=991573&r1=991572&r2=991573&view=diff
==============================================================================
--- couchdb/branches/new_replicator/etc/couchdb/default.ini.tpl.in (original)
+++ couchdb/branches/new_replicator/etc/couchdb/default.ini.tpl.in Wed Sep  1 15:35:15 2010
@@ -116,6 +116,4 @@ compression_level = 8 ; from 1 (lowest, 
 compressible_types = text/*, application/javascript, application/json,  application/xml
 
 [replicator]
-copy_processes = 8
-max_http_sessions = 10
-max_http_pipeline_size = 10
\ No newline at end of file
+copy_processes = 10

Modified: couchdb/branches/new_replicator/src/couchdb/couch_api_wrap.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/new_replicator/src/couchdb/couch_api_wrap.erl?rev=991573&r1=991572&r2=991573&view=diff
==============================================================================
--- couchdb/branches/new_replicator/src/couchdb/couch_api_wrap.erl (original)
+++ couchdb/branches/new_replicator/src/couchdb/couch_api_wrap.erl Wed Sep  1 15:35:15 2010
@@ -128,7 +128,7 @@ update_doc(Db, Doc, Options) ->
 ensure_full_commit(#httpdb{} = Db) ->
     send_req(
         Db,
-        [{method, post}, {path, "_ensure_full_commit"}, {direct, true},
+        [{method, post}, {path, "_ensure_full_commit"},
             {headers, [{"Content-Type", "application/json"}]}],
         fun(201, _, {Props}) ->
             {ok, get_value(<<"instance_start_time">>, Props)}
@@ -141,8 +141,7 @@ get_missing_revs(#httpdb{} = Db, IdRevs)
     JsonBody = {[{Id, couch_doc:revs_to_strs(Revs)} || {Id, Revs} <- IdRevs]},
     send_req(
         Db,
-        [{method, post}, {path, "_revs_diff"}, {direct, true},
-            {body, ?JSON_ENCODE(JsonBody)}],
+        [{method, post}, {path, "_revs_diff"}, {body, ?JSON_ENCODE(JsonBody)}],
         fun(200, _, {Props}) ->
             ConvertToNativeFun = fun({Id, {Result}}) ->
                 MissingRevs = couch_doc:parse_revs(
@@ -176,7 +175,7 @@ open_doc_revs(#httpdb{} = HttpDb, Id, Re
     Streamer = spawn_link(fun() ->
             send_req(
                 HttpDb,
-                [{path, IdEncoded}, {qs, QArgs}, {direct, true},
+                [{path, IdEncoded}, {qs, QArgs},
                     {ibrowse_options, [{stream_to, {self(), once}}]},
                     {headers, [{"accept", "multipart/mixed"}]}],
                 fun(200, Headers, StreamDataFun) ->
@@ -212,7 +211,7 @@ open_doc(#httpdb{} = HttpDb, Id, Options
             send_req(
                 HttpDb,
                 [{headers, [{"accept", "application/json, multipart/related"}]},
-                    {path, IdEncoded}, {qs, QArgs}, {direct, true},
+                    {path, IdEncoded}, {qs, QArgs},
                     {ibrowse_options, [{stream_to, {self(), once}}]}],
                 fun(Code, Headers, StreamDataFun) ->
                     CType = get_value("Content-Type", Headers),
@@ -297,7 +296,7 @@ update_doc(#httpdb{} = HttpDb, #doc{id =
     end,
     send_req(
         HttpDb,
-        [{method, put}, {path, url_encode(DocId)}, {direct, true},
+        [{method, put}, {path, url_encode(DocId)},
             {qs, QArgs}, {headers, Headers}, {body, {SendFun, Len}}],
         fun(Code, _, {Props}) when Code =:= 200 orelse Code =:= 201 ->
                 {ok, couch_doc:parse_rev(get_value(<<"rev">>, Props))};
@@ -318,7 +317,7 @@ changes_since(#httpdb{} = HttpDb, Style,
         Options),
     send_req(
         HttpDb,
-        [{path, "_changes"}, {qs, QArgs}, {direct, true},
+        [{path, "_changes"}, {qs, QArgs},
             {ibrowse_options, [{stream_to, {self(), once}}]}],
         fun(200, _, DataStreamFun) ->
             EventFun = fun(Ev) ->

Modified: couchdb/branches/new_replicator/src/couchdb/couch_api_wrap_httpc.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/new_replicator/src/couchdb/couch_api_wrap_httpc.erl?rev=991573&r1=991572&r2=991573&view=diff
==============================================================================
--- couchdb/branches/new_replicator/src/couchdb/couch_api_wrap_httpc.erl (original)
+++ couchdb/branches/new_replicator/src/couchdb/couch_api_wrap_httpc.erl Wed Sep  1 15:35:15
2010
@@ -25,20 +25,11 @@
     ]).
 
 
-httpdb_setup(#httpdb{url = Url} = Db) ->
-    #url{host = Host, port = Port} = ibrowse_lib:parse_url(Url),
-    ibrowse:set_max_sessions(Host, Port, max_sessions()),
-    ibrowse:set_max_pipeline_size(Host, Port, pipeline_size()),
+httpdb_setup(#httpdb{} = Db) ->
+    % TODO: setup Ibrowse proxy options
     {ok, Db}.
 
 
-pipeline_size() ->
-    ?l2i(couch_config:get("replicator", "max_http_pipeline_size", "10")).
-
-max_sessions() ->
-    ?l2i(couch_config:get("replicator", "max_http_sessions", "10")).
-
-
 send_req(HttpDb, Params, Callback) ->
     #httpdb{headers = BaseHeaders, oauth = OAuth} = HttpDb,
     Method = get_value(method, Params, get),
@@ -50,18 +41,10 @@ send_req(HttpDb, Params, Callback) ->
     ],
     Url = full_url(HttpDb, Params),
     Headers2 = oauth_header(Url, [], Method, OAuth) ++ BaseHeaders ++ Headers,
-    {Response, Worker} = case get_value(direct, Params, false) of
-    false ->
-        Resp = ibrowse:send_req(
-            Url, Headers2, Method, Body, IbrowseOptions, infinity),
-        {Resp, nil};
-    true ->
-        #url{host = Host, port = Port} = ibrowse_lib:parse_url(Url),
-        {ok, Conn} = ibrowse:spawn_link_worker_process(Host, Port),
-        Resp = ibrowse:send_req_direct(
-            Conn, Url, Headers2, Method, Body, IbrowseOptions, infinity),
-        {Resp, Conn}
-    end,
+    #url{host = Host, port = Port} = ibrowse_lib:parse_url(Url),
+    {ok, Worker} = ibrowse:spawn_link_worker_process(Host, Port),
+    Response = ibrowse:send_req_direct(
+            Worker, Url, Headers2, Method, Body, IbrowseOptions, infinity),
     process_response(Response, Worker, HttpDb, Params, Callback).
 
 



Mime
View raw message