You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2017/02/22 16:06:27 UTC

[1/6] chttpd commit: updated refs/heads/COUCHDB-3287-pluggable-storage-engines to d672352 [Forced Update!]

Repository: couchdb-chttpd
Updated Branches:
  refs/heads/COUCHDB-3287-pluggable-storage-engines fb73a5d3f -> d67235278 (forced update)


Handle error return clauses for fabric:open_revs

When calling fabric:open_revs, we don't account for situations where
the function returns an {error, any()} value as specified by the
function specification. This will account for errors thrown.

COUCHDB-3289


Project: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/commit/cd4c5c70
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/tree/cd4c5c70
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/diff/cd4c5c70

Branch: refs/heads/COUCHDB-3287-pluggable-storage-engines
Commit: cd4c5c70c146e74a344b42e7e636e8e81f08495c
Parents: 90648a2
Author: Tony Sun <to...@cloudant.com>
Authored: Wed Feb 1 13:14:42 2017 -0800
Committer: Tony Sun <to...@cloudant.com>
Committed: Wed Feb 1 13:14:42 2017 -0800

----------------------------------------------------------------------
 src/chttpd_db.erl | 37 ++++++++++++++++++++++---------------
 1 file changed, 22 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/cd4c5c70/src/chttpd_db.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_db.erl b/src/chttpd_db.erl
index f3dd2ab..bb08db6 100644
--- a/src/chttpd_db.erl
+++ b/src/chttpd_db.erl
@@ -673,11 +673,10 @@ db_doc_req(#httpd{method='GET', mochi_req=MochiReq}=Req, Db, DocId) ->
         Doc = couch_doc_open(Db, DocId, Rev, Options2),
         send_doc(Req, Doc, Options2);
     _ ->
-        {ok, Results} = fabric:open_revs(Db, DocId, Revs, Options),
-        case Results of
-            [] when Revs == all ->
+        case fabric:open_revs(Db, DocId, Revs, Options) of
+            {ok, []} when Revs == all ->
                 chttpd:send_error(Req, {not_found, missing});
-            _Else ->
+            {ok, Results} ->
                 case MochiReq:accepts_content_type("multipart/mixed") of
                 false ->
                     {ok, Resp} = start_json_response(Req, 200),
@@ -703,7 +702,9 @@ db_doc_req(#httpd{method='GET', mochi_req=MochiReq}=Req, Db, DocId) ->
                     end_json_response(Resp);
                 true ->
                     send_docs_multipart(Req, Results, Options)
-                end
+                end;
+            {error, Error} ->
+                chttpd:send_error(Req, Error)
         end
     end;
 
@@ -722,7 +723,10 @@ db_doc_req(#httpd{method='POST', user_ctx=Ctx}=Req, Db, DocId) ->
         Doc = couch_doc_from_req(Req, DocId, Json);
     false ->
         Rev = couch_doc:parse_rev(list_to_binary(couch_util:get_value("_rev", Form))),
-        {ok, [{ok, Doc}]} = fabric:open_revs(Db, DocId, [Rev], [])
+        Doc = case fabric:open_revs(Db, DocId, [Rev], []) of
+            {ok, [{ok, Doc0}]} -> Doc0;
+            {error, Error} -> throw(Error)
+        end
     end,
     UpdatedAtts = [
         couch_att:new([
@@ -1063,14 +1067,16 @@ couch_doc_open(#db{} = Db, DocId, Rev, Options0) ->
          Error ->
              throw(Error)
          end;
-  _ -> % open a specific rev (deletions come back as stubs)
-      case fabric:open_revs(Db, DocId, [Rev], Options) of
-          {ok, [{ok, Doc}]} ->
-              Doc;
-          {ok, [{{not_found, missing}, Rev}]} ->
-              throw(not_found);
-          {ok, [Else]} ->
-              throw(Else)
+    _ -> % open a specific rev (deletions come back as stubs)
+        case fabric:open_revs(Db, DocId, [Rev], Options) of
+        {ok, [{ok, Doc}]} ->
+            Doc;
+        {ok, [{{not_found, missing}, Rev}]} ->
+            throw(not_found);
+        {ok, [Else]} ->
+            throw(Else);
+        {error, Error} ->
+            throw(Error)
       end
   end.
 
@@ -1235,7 +1241,8 @@ db_attachment_req(#httpd{method=Method, user_ctx=Ctx}=Req, Db, DocId, FileNamePa
         Rev ->
             case fabric:open_revs(Db, DocId, [Rev], [{user_ctx,Ctx}]) of
             {ok, [{ok, Doc0}]}  -> Doc0;
-            {ok, [Error]}       -> throw(Error)
+            {ok, [Error]}       -> throw(Error);
+            {error, Error}      -> throw(Error)
             end
     end,
 


[5/6] chttpd commit: updated refs/heads/COUCHDB-3287-pluggable-storage-engines to d672352

Posted by da...@apache.org.
Remove public db record

COUCHDB-3288


Project: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/commit/27cadc58
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/tree/27cadc58
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/diff/27cadc58

Branch: refs/heads/COUCHDB-3287-pluggable-storage-engines
Commit: 27cadc58d35ce56c5587df5a9b34280f37d3faee
Parents: 90bd048
Author: Paul J. Davis <pa...@gmail.com>
Authored: Wed Feb 1 12:32:15 2017 -0600
Committer: Paul J. Davis <pa...@gmail.com>
Committed: Wed Feb 22 10:03:39 2017 -0600

----------------------------------------------------------------------
 src/chttpd_db.erl       | 21 ++++++++++++---------
 src/chttpd_external.erl | 22 ++++++++++++++--------
 src/chttpd_show.erl     |  3 ++-
 3 files changed, 28 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/27cadc58/src/chttpd_db.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_db.erl b/src/chttpd_db.erl
index bb08db6..9311837 100644
--- a/src/chttpd_db.erl
+++ b/src/chttpd_db.erl
@@ -84,7 +84,7 @@ handle_changes_req1(#httpd{}=Req, Db) ->
     #changes_args{filter=Raw, style=Style} = Args0 = parse_changes_query(Req),
     ChangesArgs = Args0#changes_args{
         filter_fun = couch_changes:configure_filter(Raw, Style, Req, Db),
-        db_open_options = [{user_ctx, Db#db.user_ctx}]
+        db_open_options = [{user_ctx, couch_db:get_user_ctx(Db)}]
     },
     Max = chttpd:chunked_response_buffer_size(),
     case ChangesArgs#changes_args.feed of
@@ -253,7 +253,7 @@ handle_view_cleanup_req(Req, Db) ->
 handle_design_req(#httpd{
         path_parts=[_DbName, _Design, Name, <<"_",_/binary>> = Action | _Rest]
     }=Req, Db) ->
-    DbName = mem3:dbname(Db#db.name),
+    DbName = mem3:dbname(couch_db:name(Db)),
     case ddoc_cache:open(DbName, <<"_design/", Name/binary>>) of
     {ok, DDoc} ->
         Handler = chttpd_handlers:design_handler(Action, fun bad_action_req/3),
@@ -309,7 +309,8 @@ delete_db_req(#httpd{}=Req, DbName) ->
 
 do_db_req(#httpd{path_parts=[DbName|_], user_ctx=Ctx}=Req, Fun) ->
     fabric:get_security(DbName, [{user_ctx,Ctx}]), % calls check_is_reader
-    Fun(Req, #db{name=DbName, user_ctx=Ctx}).
+    {ok, Db} = couch_db:clustered_db(DbName, Ctx),
+    Fun(Req, Db).
 
 db_req(#httpd{method='GET',path_parts=[DbName]}=Req, _Db) ->
     % measure the time required to generate the etag, see if it's worth it
@@ -767,16 +768,17 @@ db_doc_req(#httpd{method='PUT', user_ctx=Ctx}=Req, Db, DocId) ->
     } = parse_doc_query(Req),
     couch_doc:validate_docid(DocId),
 
+    DbName = couch_db:name(Db),
     W = chttpd:qs_value(Req, "w", integer_to_list(mem3:quorum(Db))),
     Options = [{user_ctx,Ctx}, {w,W}],
 
-    Loc = absolute_uri(Req, [$/, couch_util:url_encode(Db#db.name),
+    Loc = absolute_uri(Req, [$/, couch_util:url_encode(DbName),
         $/, couch_util:url_encode(DocId)]),
     RespHeaders = [{"Location", Loc}],
     case couch_util:to_list(couch_httpd:header_value(Req, "Content-Type")) of
     ("multipart/related;" ++ _) = ContentType ->
         couch_httpd:check_max_request_length(Req),
-        couch_httpd_multipart:num_mp_writers(mem3:n(mem3:dbname(Db#db.name), DocId)),
+        couch_httpd_multipart:num_mp_writers(mem3:n(mem3:dbname(DbName), DocId)),
         {ok, Doc0, WaitFun, Parser} = couch_doc:doc_from_multi_part_stream(ContentType,
                 fun() -> receive_request_data(Req) end),
         Doc = couch_doc_from_req(Req, DocId, Doc0),
@@ -833,8 +835,9 @@ db_doc_req(#httpd{method='COPY', user_ctx=Ctx}=Req, Db, SourceDocId) ->
         HttpCode = 202
     end,
     % respond
+    DbName = couch_db:name(Db),
     {PartRes} = update_doc_result_to_json(TargetDocId, {ok, NewTargetRev}),
-    Loc = absolute_uri(Req, "/" ++ couch_util:url_encode(Db#db.name) ++ "/" ++ couch_util:url_encode(TargetDocId)),
+    Loc = absolute_uri(Req, "/" ++ couch_util:url_encode(DbName) ++ "/" ++ couch_util:url_encode(TargetDocId)),
     send_json(Req, HttpCode,
         [{"Location", Loc},
         {"ETag", "\"" ++ ?b2l(couch_doc:rev_to_str(NewTargetRev)) ++ "\""}],
@@ -1057,8 +1060,8 @@ couch_doc_from_req(Req, DocId, Json) ->
 % couch_doc_open(Db, DocId) ->
 %   couch_doc_open(Db, DocId, nil, []).
 
-couch_doc_open(#db{} = Db, DocId, Rev, Options0) ->
-    Options = [{user_ctx, Db#db.user_ctx} | Options0],
+couch_doc_open(Db, DocId, Rev, Options0) ->
+    Options = [{user_ctx, couch_db:get_user_ctx(Db)} | Options0],
     case Rev of
     nil -> % open most recent rev
         case fabric:open_doc(Db, DocId, Options) of
@@ -1258,7 +1261,7 @@ db_attachment_req(#httpd{method=Method, user_ctx=Ctx}=Req, Db, DocId, FileNamePa
         HttpCode = 202
     end,
     erlang:put(mochiweb_request_recv, true),
-    #db{name=DbName} = Db,
+    DbName = couch_db:name(Db),
 
     {Status, Headers} = case Method of
         'DELETE' ->

http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/27cadc58/src/chttpd_external.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_external.erl b/src/chttpd_external.erl
index 1dccf2a..e01887f 100644
--- a/src/chttpd_external.erl
+++ b/src/chttpd_external.erl
@@ -120,16 +120,22 @@ json_req_obj_field(<<"secObj">>, #httpd{user_ctx=UserCtx}, Db, _DocId) ->
     get_db_security(Db, UserCtx).
 
 
-get_db_info(#db{main_pid = nil} = Db) ->
-    fabric:get_db_info(Db);
-get_db_info(#db{} = Db) ->
-    couch_db:get_db_info(Db).
+get_db_info(Db) ->
+    case couch_db:is_clustered(Db) of
+        true ->
+            fabric:get_db_info(Db);
+        false ->
+            couch_db:get_db_info(Db)
+    end.
 
 
-get_db_security(#db{main_pid = nil}=Db, #user_ctx{}) ->
-    fabric:get_security(Db);
-get_db_security(#db{}=Db, #user_ctx{}) ->
-    couch_db:get_security(Db).
+get_db_security(Db, #user_ctx{}) ->
+    case couch_db:is_clustered(Db) of
+        true ->
+            fabric:get_security(Db);
+        false ->
+            couch_db:get_security(Db)
+    end.
 
 
 to_json_terms(Data) ->

http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/27cadc58/src/chttpd_show.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_show.erl b/src/chttpd_show.erl
index bbe51b2..674b571 100644
--- a/src/chttpd_show.erl
+++ b/src/chttpd_show.erl
@@ -196,7 +196,8 @@ handle_view_list_req(Req, _Db, _DDoc) ->
 handle_view_list(Req, Db, DDoc, LName, {ViewDesignName, ViewName}, Keys) ->
     %% Will throw an exception if the _list handler is missing
     couch_util:get_nested_json_value(DDoc#doc.body, [<<"lists">>, LName]),
-    {ok, VDoc} = ddoc_cache:open(Db#db.name, <<"_design/", ViewDesignName/binary>>),
+    DbName = couch_db:name(Db),
+    {ok, VDoc} = ddoc_cache:open(DbName, <<"_design/", ViewDesignName/binary>>),
     CB = fun couch_mrview_show:list_cb/2,
     QueryArgs = couch_mrview_http:parse_params(Req, Keys),
     Options = [{user_ctx, Req#httpd.user_ctx}],


[2/6] chttpd commit: updated refs/heads/COUCHDB-3287-pluggable-storage-engines to d672352

Posted by da...@apache.org.
Introduce 503 error when nodes are all unavailable.

In rare situations when all nodes are down or in maintenance mode and
no workers can service a request, we return a 503 to the user.

COUCHDB-3289


Project: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/commit/928bb2e4
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/tree/928bb2e4
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/diff/928bb2e4

Branch: refs/heads/COUCHDB-3287-pluggable-storage-engines
Commit: 928bb2e4b9e542a8fd37202493af96a7e20f44cb
Parents: cd4c5c7
Author: Tony Sun <to...@cloudant.com>
Authored: Wed Feb 1 13:23:26 2017 -0800
Committer: Tony Sun <to...@cloudant.com>
Committed: Thu Feb 9 11:03:21 2017 -0800

----------------------------------------------------------------------
 src/chttpd.erl                       |   3 +
 test/chttpd_open_revs_error_test.erl | 105 ++++++++++++++++++++++++++++++
 2 files changed, 108 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/928bb2e4/src/chttpd.erl
----------------------------------------------------------------------
diff --git a/src/chttpd.erl b/src/chttpd.erl
index e2ab054..cdf6e8d 100644
--- a/src/chttpd.erl
+++ b/src/chttpd.erl
@@ -894,6 +894,9 @@ error_info(request_entity_too_large) ->
 error_info({error, security_migration_updates_disabled}) ->
     {503, <<"security_migration">>, <<"Updates to security docs are disabled during "
         "security migration.">>};
+error_info(all_workers_died) ->
+    {503, <<"service unvailable">>, <<"Nodes are unable to service this "
+        "request due to overloading or maintenance mode.">>};
 error_info(not_implemented) ->
     {501, <<"not_implemented">>, <<"this feature is not yet implemented">>};
 error_info(timeout) ->

http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/928bb2e4/test/chttpd_open_revs_error_test.erl
----------------------------------------------------------------------
diff --git a/test/chttpd_open_revs_error_test.erl b/test/chttpd_open_revs_error_test.erl
new file mode 100644
index 0000000..5b26b5c
--- /dev/null
+++ b/test/chttpd_open_revs_error_test.erl
@@ -0,0 +1,105 @@
+% Licensed under the Apache License, Version 2.0 (the "License"); you may not
+% use this file except in compliance with the License. You may obtain a copy of
+% the License at
+%
+%   http://www.apache.org/licenses/LICENSE-2.0
+%
+% Unless required by applicable law or agreed to in writing, software
+% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+% License for the specific language governing permissions and limitations under
+% the License.
+
+-module(chttpd_open_revs_error_test).
+
+-include_lib("couch/include/couch_eunit.hrl").
+-include_lib("couch/include/couch_db.hrl").
+
+-define(USER, "chttpd_db_test_admin").
+-define(PASS, "pass").
+-define(AUTH, {basic_auth, {?USER, ?PASS}}).
+-define(CONTENT_JSON, {"Content-Type", "application/json"}).
+-define(CONTENT_MULTI_FORM, {"Content-Type",
+    "multipart/form-data;boundary=\"bound\""}).
+
+setup() ->
+    ok = config:set("admins", ?USER, ?PASS, _Persist=false),
+    TmpDb = ?tempdb(),
+    Addr = config:get("chttpd", "bind_address", "127.0.0.1"),
+    Port = mochiweb_socket_server:get(chttpd, port),
+    Url = lists:concat(["http://", Addr, ":", Port, "/", ?b2l(TmpDb)]),
+    mock(fabric),
+    create_db(Url),
+    Url.
+
+teardown(Url) ->
+    delete_db(Url),
+    (catch meck:unload(fabric)),
+    ok = config:delete("admins", ?USER, _Persist=false).
+
+create_db(Url) ->
+    {ok, Status, _, _} = test_request:put(Url, [?CONTENT_JSON, ?AUTH], "{}"),
+    ?assert(Status =:= 201 orelse Status =:= 202).
+
+
+create_doc(Url, Id) ->
+    test_request:put(Url ++ "/" ++ Id,
+        [?CONTENT_JSON, ?AUTH], "{\"mr\": \"rockoartischocko\"}").
+
+delete_db(Url) ->
+    {ok, 200, _, _} = test_request:delete(Url, [?AUTH]).
+
+open_revs_error_test_() ->
+    {
+        "open revs error tests",
+        {
+            setup,
+            fun chttpd_test_util:start_couch/0, fun chttpd_test_util:stop_couch/1,
+            {
+                foreach,
+                fun setup/0, fun teardown/1,
+                [
+                    fun should_return_503_error_for_open_revs_get/1,
+                    fun should_return_503_error_for_open_revs_post_form/1
+                ]
+            }
+        }
+    }.
+
+should_return_503_error_for_open_revs_get(Url) ->
+    {ok, _, _, Body} = create_doc(Url, "testdoc"),
+    {Json} = ?JSON_DECODE(Body),
+    Ref = couch_util:get_value(<<"rev">>, Json, undefined),
+    mock_open_revs({error, all_workers_died}),
+    {ok, Code, _, _} = test_request:get(Url ++
+        "/testdoc?rev=" ++ ?b2l(Ref), [?AUTH]),
+     ?_assertEqual(503, Code).
+
+should_return_503_error_for_open_revs_post_form(Url) ->
+    Port = mochiweb_socket_server:get(chttpd, port),
+    Host = lists:concat([ "http://127.0.0.1:", Port]),
+    Referer = {"Referer", Host},
+    Body1 = "{\"body\":\"This is a body.\"}",
+    DocBeg = "--bound\r\nContent-Disposition: form-data; name=\"_doc\"\r\n\r\n",
+    DocRev = "--bound\r\nContent-Disposition: form-data; name=\"_rev\"\r\n\r\n",
+    DocRest = "\r\n--bound\r\nContent-Disposition:"
+        "form-data; name=\"_attachments\"; filename=\"file.txt\"\r\n"
+        "Content-Type: text/plain\r\n\r\ncontents of file.txt\r\n\r\n"
+        "--bound--",
+    Doc1 = lists:concat([DocBeg, Body1, DocRest]),
+    {ok, _, _, ResultBody} = test_request:post(Url ++ "/" ++ "RevDoc",
+        [?CONTENT_MULTI_FORM, ?AUTH, Referer], Doc1),
+    {Json} = ?JSON_DECODE(ResultBody),
+    Ref = couch_util:get_value(<<"rev">>, Json, undefined),
+    Doc2 = lists:concat([DocRev, ?b2l(Ref) , DocRest]),
+
+    mock_open_revs({error, all_workers_died}),
+    {ok, Code, _, ResultBody1} = test_request:post(Url ++ "/" ++ "RevDoc",
+        [?CONTENT_MULTI_FORM, ?AUTH, Referer], Doc2),
+    ?_assertEqual(503, Code).
+
+mock_open_revs(RevsResp) ->
+    ok = meck:expect(fabric, open_revs, fun(_, _, _, _) -> RevsResp end).
+
+mock(fabric) ->
+    ok = meck:new(fabric, [passthrough]).


[3/6] chttpd commit: updated refs/heads/COUCHDB-3287-pluggable-storage-engines to d672352

Posted by da...@apache.org.
Mock config module in tests

The tests in chttpd_db_bulk_get_test do not start config app.
The change in https://github.com/apache/couchdb-couch/pull/226
introduces call to config app.
Make sure we mock config so the tests pass.

COUCHDB-3293


Project: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/commit/cae3664d
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/tree/cae3664d
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/diff/cae3664d

Branch: refs/heads/COUCHDB-3287-pluggable-storage-engines
Commit: cae3664d6583adf110302704fb546b4565e19b91
Parents: 928bb2e
Author: ILYA Khlopotov <ii...@apache.org>
Authored: Thu Feb 9 13:36:39 2017 -0800
Committer: ILYA Khlopotov <ii...@apache.org>
Committed: Thu Feb 9 13:57:42 2017 -0800

----------------------------------------------------------------------
 test/chttpd_db_bulk_get_test.erl | 6 ++++++
 1 file changed, 6 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/cae3664d/test/chttpd_db_bulk_get_test.erl
----------------------------------------------------------------------
diff --git a/test/chttpd_db_bulk_get_test.erl b/test/chttpd_db_bulk_get_test.erl
index a5edcc0..f892131 100644
--- a/test/chttpd_db_bulk_get_test.erl
+++ b/test/chttpd_db_bulk_get_test.erl
@@ -19,6 +19,7 @@
 
 
 setup() ->
+    mock(config),
     mock(chttpd),
     mock(couch_epi),
     mock(couch_httpd),
@@ -31,6 +32,7 @@ setup() ->
 
 teardown(Pid) ->
     ok = stop_accumulator(Pid),
+    meck:unload(config),
     meck:unload(chttpd),
     meck:unload(couch_epi),
     meck:unload(couch_httpd),
@@ -270,6 +272,10 @@ mock(couch_stats) ->
     ok;
 mock(fabric) ->
     ok = meck:new(fabric, [passthrough]),
+    ok;
+mock(config) ->
+    ok = meck:new(config, [passthrough]),
+    ok = meck:expect(config, get, fun(_, _, Default) -> Default end),
     ok.
 
 


[4/6] chttpd commit: updated refs/heads/COUCHDB-3287-pluggable-storage-engines to d672352

Posted by da...@apache.org.
Merge remote branch 'cloudant:couchdb-3293'

This closes #155

Signed-off-by: ILYA Khlopotov <ii...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/commit/90bd0481
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/tree/90bd0481
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/diff/90bd0481

Branch: refs/heads/COUCHDB-3287-pluggable-storage-engines
Commit: 90bd048118223b8a19ba24fc209df3d9991bc73b
Parents: 928bb2e cae3664
Author: ILYA Khlopotov <ii...@apache.org>
Authored: Thu Feb 9 13:58:44 2017 -0800
Committer: ILYA Khlopotov <ii...@apache.org>
Committed: Thu Feb 9 13:58:44 2017 -0800

----------------------------------------------------------------------
 test/chttpd_db_bulk_get_test.erl | 6 ++++++
 1 file changed, 6 insertions(+)
----------------------------------------------------------------------



[6/6] chttpd commit: updated refs/heads/COUCHDB-3287-pluggable-storage-engines to d672352

Posted by da...@apache.org.
Support engine selection from the HTTP API

COUCHDB-3287


Project: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/commit/d6723527
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/tree/d6723527
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/diff/d6723527

Branch: refs/heads/COUCHDB-3287-pluggable-storage-engines
Commit: d67235278cd7abb451501ae32a098da01857e965
Parents: 27cadc5
Author: Paul J. Davis <pa...@gmail.com>
Authored: Wed Apr 6 10:48:01 2016 -0500
Committer: Paul J. Davis <pa...@gmail.com>
Committed: Wed Feb 22 10:06:13 2017 -0600

----------------------------------------------------------------------
 src/chttpd_db.erl | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/d6723527/src/chttpd_db.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_db.erl b/src/chttpd_db.erl
index 9311837..738cfe4 100644
--- a/src/chttpd_db.erl
+++ b/src/chttpd_db.erl
@@ -284,8 +284,15 @@ create_db_req(#httpd{}=Req, DbName) ->
     N = chttpd:qs_value(Req, "n", config:get("cluster", "n", "3")),
     Q = chttpd:qs_value(Req, "q", config:get("cluster", "q", "8")),
     P = chttpd:qs_value(Req, "placement", config:get("cluster", "placement")),
+    E = iolist_to_binary(chttpd:qs_value(Req, "engine", "couch")),
+    Options = [
+        {n, N},
+        {q, Q},
+        {placement, P},
+        {engine, E}
+    ],
     DocUrl = absolute_uri(Req, "/" ++ couch_util:url_encode(DbName)),
-    case fabric:create_db(DbName, [{n,N}, {q,Q}, {placement,P}]) of
+    case fabric:create_db(DbName, Options) of
     ok ->
         send_json(Req, 201, [{"Location", DocUrl}], {[{ok, true}]});
     accepted ->