couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject [22/44] couchdb commit: updated refs/heads/1843-feature-bigcouch-multi-repo to 2385a37
Date Tue, 04 Feb 2014 23:44:35 GMT
Remove src/ddoc_cache


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

Branch: refs/heads/1843-feature-bigcouch-multi-repo
Commit: 572ee3ce4603be89d8545b50142a183ded001d27
Parents: 550e820
Author: Paul J. Davis <paul.joseph.davis@gmail.com>
Authored: Tue Feb 4 17:40:28 2014 -0600
Committer: Paul J. Davis <paul.joseph.davis@gmail.com>
Committed: Tue Feb 4 17:40:28 2014 -0600

----------------------------------------------------------------------
 src/ddoc_cache/README.md                 |   4 -
 src/ddoc_cache/src/ddoc_cache.app.src    |  42 ------
 src/ddoc_cache/src/ddoc_cache.erl        |  81 -----------
 src/ddoc_cache/src/ddoc_cache_app.erl    |  25 ----
 src/ddoc_cache/src/ddoc_cache_opener.erl | 196 --------------------------
 src/ddoc_cache/src/ddoc_cache_sup.erl    |  67 ---------
 src/ddoc_cache/src/ddoc_cache_util.erl   |  34 -----
 7 files changed, 449 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/572ee3ce/src/ddoc_cache/README.md
----------------------------------------------------------------------
diff --git a/src/ddoc_cache/README.md b/src/ddoc_cache/README.md
deleted file mode 100644
index 81d600b..0000000
--- a/src/ddoc_cache/README.md
+++ /dev/null
@@ -1,4 +0,0 @@
-Design Doc Cache
-================
-
-Pretty much covers it.

http://git-wip-us.apache.org/repos/asf/couchdb/blob/572ee3ce/src/ddoc_cache/src/ddoc_cache.app.src
----------------------------------------------------------------------
diff --git a/src/ddoc_cache/src/ddoc_cache.app.src b/src/ddoc_cache/src/ddoc_cache.app.src
deleted file mode 100644
index a183dbd..0000000
--- a/src/ddoc_cache/src/ddoc_cache.app.src
+++ /dev/null
@@ -1,42 +0,0 @@
-% 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.
-
-{application, ddoc_cache, [
-    {description, "Design Document Cache"},
-    {vsn, git},
-    {modules, [
-        ddoc_cache,
-        ddoc_cache_app,
-        ddoc_cache_opener,
-        ddoc_cache_sup,
-        ddoc_cache_util
-    ]},
-    {registered, [
-        ddoc_cache_lru,
-        ddoc_cache_opener
-    ]},
-    {applications, [
-        kernel,
-        stdlib,
-        crypto,
-        ets_lru,
-        mem3,
-        fabric,
-        twig
-    ]},
-    {mod, {ddoc_cache_app, []}},
-    {env, [
-        {max_objects, unlimited},
-        {max_size, 104857600}, % 100M
-        {max_lifetime, 60000} % 1m
-    ]}
-]}.

http://git-wip-us.apache.org/repos/asf/couchdb/blob/572ee3ce/src/ddoc_cache/src/ddoc_cache.erl
----------------------------------------------------------------------
diff --git a/src/ddoc_cache/src/ddoc_cache.erl b/src/ddoc_cache/src/ddoc_cache.erl
deleted file mode 100644
index e862667..0000000
--- a/src/ddoc_cache/src/ddoc_cache.erl
+++ /dev/null
@@ -1,81 +0,0 @@
-% 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(ddoc_cache).
-
-
--export([
-    start/0,
-    stop/0,
-    
-    open/2,
-    evict/2
-]).
-
-
--define(CACHE, ddoc_cache_lru).
--define(OPENER, ddoc_cache_opener).
-
-
-start() ->
-    application:start(ddoc_cache).
-
-
-stop() ->
-    application:stop(ddoc_cache).
-
-
-open(DbName, validation_funs) ->
-    open({DbName, validation_funs});
-open(DbName, <<"_design/", _/binary>>=DDocId) when is_binary(DbName) ->
-    open({DbName, DDocId});
-open(DbName, DDocId) when is_binary(DDocId) ->
-    open({DbName, <<"_design/", DDocId/binary>>}).
-
-
-open(Key) ->
-    try ets_lru:lookup_d(?CACHE, Key) of
-        {ok, _} = Resp ->
-            Resp;
-        _ ->
-            case gen_server:call(?OPENER, {open, Key}, infinity) of
-                {open_ok, Resp} ->
-                    Resp;
-                {open_error, throw, Error} ->
-                    throw(Error);
-                {open_error, error, Error} ->
-                    erlang:error(Error);
-                {open_error, exit, Error} ->
-                    exit(Error)
-            end
-    catch
-        error:badarg ->
-            recover(Key)
-    end.
-
-
-evict(ShardDbName, DDocIds) ->
-    DbName = mem3:dbname(ShardDbName),
-    gen_server:cast(?OPENER, {evict, DbName, DDocIds}).
-
-
-recover({DbName, validation_funs}) ->
-    {ok, DDocs} = fabric:design_docs(mem3:dbname(DbName)),
-    Funs = lists:flatmap(fun(DDoc) ->
-        case couch_doc:get_validate_doc_fun(DDoc) of
-            nil -> [];
-            Fun -> [Fun]
-        end
-    end, DDocs),
-    {ok, Funs};
-recover({DbName, DDocId}) ->
-    fabric:open_doc(DbName, DDocId, [ejson_body]).

http://git-wip-us.apache.org/repos/asf/couchdb/blob/572ee3ce/src/ddoc_cache/src/ddoc_cache_app.erl
----------------------------------------------------------------------
diff --git a/src/ddoc_cache/src/ddoc_cache_app.erl b/src/ddoc_cache/src/ddoc_cache_app.erl
deleted file mode 100644
index 5afa7ac..0000000
--- a/src/ddoc_cache/src/ddoc_cache_app.erl
+++ /dev/null
@@ -1,25 +0,0 @@
-% 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(ddoc_cache_app).
--behaviour(application).
-
-
--export([start/2, stop/1]).
-
-
-start(_StartType, _StartArgs) ->
-    ddoc_cache_sup:start_link().
-
-
-stop(_State) ->
-    ok.

http://git-wip-us.apache.org/repos/asf/couchdb/blob/572ee3ce/src/ddoc_cache/src/ddoc_cache_opener.erl
----------------------------------------------------------------------
diff --git a/src/ddoc_cache/src/ddoc_cache_opener.erl b/src/ddoc_cache/src/ddoc_cache_opener.erl
deleted file mode 100644
index 68b9127..0000000
--- a/src/ddoc_cache/src/ddoc_cache_opener.erl
+++ /dev/null
@@ -1,196 +0,0 @@
-% 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(ddoc_cache_opener).
--behaviour(gen_server).
-
-
--include_lib("mem3/include/mem3.hrl").
-
-
--export([
-    start_link/0
-]).
-
--export([
-    open_ddoc/1
-]).
-
--export([
-    init/1,
-    terminate/2,
-
-    handle_call/3,
-    handle_cast/2,
-    handle_info/2,
-
-    code_change/3
-]).
-
--export([
-    evictor/1
-]).
-
-
--define(OPENING, ddoc_cache_opening).
-
-
--record(opener, {
-    key,
-    pid,
-    clients
-}).
-
--record(st, {
-    db_ddocs,
-    evictor
-}).
-
-
-start_link() ->
-    gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
-
-
-init(_) ->
-    process_flag(trap_exit, true),
-    ets:new(?OPENING, [set, protected, named_table, {keypos, #opener.key}]),
-    {ok, Evictor} = couch_db_update_notifier:start_link(fun ?MODULE:evictor/1),
-    {ok, #st{
-        evictor = Evictor
-    }}.
-
-
-terminate(_Reason, St) ->
-    case is_pid(St#st.evictor) of
-        true -> exit(St#st.evictor, kill);
-        false -> ok
-    end,
-    ok.
-
-
-handle_call({open, {_DbName, _DDocId}=Key}, From, St) ->
-    case ets:lookup(?OPENING, Key) of
-        [#opener{clients=Clients}=O] ->
-            ets:insert(?OPENING, O#opener{clients=[From | Clients]}),
-            {noreply, St};
-        [] ->
-            Pid = spawn_link(?MODULE, open_ddoc, [Key]),
-            ets:insert(?OPENING, #opener{key=Key, pid=Pid, clients=[From]}),
-            {noreply, St}
-    end;
-
-handle_call(Msg, _From, St) ->
-    {stop, {invalid_call, Msg}, {invalid_call, Msg}, St}.
-
-
-handle_cast({evict, DbName}, St) ->
-    gen_server:abcast(mem3:nodes(), ?MODULE, {do_evict, DbName}),
-    {noreply, St};
-
-handle_cast({evict, DbName, DDocIds}, St) ->
-    gen_server:abcast(mem3:nodes(), ?MODULE, {do_evict, DbName, DDocIds}),
-    {noreply, St};
-
-handle_cast({do_evict, DbName}, St) ->
-    % Bit of hack to introspect the ets_lru ETS tables directly
-    % but I think this is better than having to manage our own
-    % DbName -> DDocIdList table
-    DDocIds = ets:foldl(fun(Obj, Acc) ->
-        entry = element(1, Obj), % assert this is an entry record
-        {EntryDbName, EntryDDocId} = element(2, Obj),
-        case EntryDbName == DbName of
-            true -> [EntryDDocId | Acc];
-            false -> Acc
-        end
-    end, [], ddoc_cache_lru_objects),
-    handle_cast({do_evict, DbName, DDocIds}, St);
-
-handle_cast({do_evict, DbName, DDocIds}, St) ->
-    ets_lru:remove(ddoc_cache_lru, {DbName, validation_funs}),
-    lists:foreach(fun(DDocId) ->
-        ets_lru:remove(ddoc_cache_lru, {DbName, DDocId})
-    end, DDocIds),
-    {noreply, St};
-
-handle_cast(Msg, St) ->
-    {stop, {invalid_cast, Msg}, St}.
-
-
-handle_info({'EXIT', Pid, Reason}, #st{evictor=Pid}=St) ->
-    twig:log(err, "ddoc_cache_opener evictor died ~w", [Reason]),
-    {ok, Evictor} = couch_db_update_notifier:start_link(fun ?MODULE:evictor/1),
-    {noreply, St#st{evictor=Evictor}};
-
-handle_info({'EXIT', _Pid, {open_ok, Key, Resp}}, St) ->
-    respond(Key, {open_ok, Resp}),
-    {noreply, St};
-
-handle_info({'EXIT', _Pid, {open_error, Key, Type, Error}}, St) ->
-    respond(Key, {open_error, Type, Error}),
-    {noreply, St};
-
-handle_info({'EXIT', Pid, Reason}, St) ->
-    Pattern = #opener{pid=Pid, _='_'},
-    case ets:match_object(?OPENING, Pattern) of
-        [#opener{key=Key, clients=Clients}] ->
-            [gen_server:reply(C, {error, Reason}) || C <- Clients],
-            ets:delete(?OPENING, Key),
-            {noreply, St};
-        [] ->
-            {stop, {unknown_pid_died, {Pid, Reason}}, St}
-    end;
-
-handle_info(Msg, St) ->
-    {stop, {invalid_info, Msg}, St}.
-
-
-code_change(_OldVsn, State, _Extra) ->
-    {ok, State}.
-
-
-evictor({created, ShardDbName}) ->
-    DbName = mem3:dbname(ShardDbName),
-    gen_server:cast(?MODULE, {evict, DbName});
-evictor({deleted, ShardDbName}) ->
-    DbName = mem3:dbname(ShardDbName),
-    gen_server:cast(?MODULE, {evict, DbName});
-evictor(_) ->
-    ok.
-
-
-open_ddoc({DbName, validation_funs}=Key) ->
-    {ok, DDocs} = fabric:design_docs(mem3:dbname(DbName)),
-    Funs = lists:flatmap(fun(DDoc) ->
-        case couch_doc:get_validate_doc_fun(DDoc) of
-            nil -> [];
-            Fun -> [Fun]
-        end
-    end, DDocs),
-    ok = ets_lru:insert(ddoc_cache_lru, {DbName, validation_funs}, Funs),
-    exit({open_ok, Key, {ok, Funs}});
-open_ddoc({DbName, DDocId}=Key) ->
-    try fabric:open_doc(DbName, DDocId, [ejson_body]) of
-        {ok, Doc} ->
-            ok = ets_lru:insert(ddoc_cache_lru, {DbName, DDocId}, Doc),
-            exit({open_ok, Key, {ok, Doc}});
-        Else ->
-            exit({open_ok, Key, Else})
-    catch
-        Type:Reason ->
-            exit({open_error, Key, Type, Reason})
-    end.
-
-
-respond(Key, Resp) ->
-    [#opener{clients=Clients}] = ets:lookup(?OPENING, Key),
-    [gen_server:reply(C, Resp) || C <- Clients],
-    ets:delete(?OPENING, Key).

http://git-wip-us.apache.org/repos/asf/couchdb/blob/572ee3ce/src/ddoc_cache/src/ddoc_cache_sup.erl
----------------------------------------------------------------------
diff --git a/src/ddoc_cache/src/ddoc_cache_sup.erl b/src/ddoc_cache/src/ddoc_cache_sup.erl
deleted file mode 100644
index 5ffd7e6..0000000
--- a/src/ddoc_cache/src/ddoc_cache_sup.erl
+++ /dev/null
@@ -1,67 +0,0 @@
-% 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(ddoc_cache_sup).
--behaviour(supervisor).
-
-
--export([
-    start_link/0,
-    init/1
-]).
-
-
-start_link() ->
-    supervisor:start_link({local, ?MODULE}, ?MODULE, []).
-
-
-init([]) ->
-    Children = [
-        {
-            ddoc_cache_lru,
-            {ets_lru, start_link, [ddoc_cache_lru, lru_opts()]},
-            permanent,
-            5000,
-            worker,
-            [ets_lru]
-        },
-        {
-            ddoc_cache_opener,
-            {ddoc_cache_opener, start_link, []},
-            permanent,
-            5000,
-            worker,
-            [ddoc_cache_opener]
-        }
-    ],
-    {ok, {{one_for_one, 5, 10}, Children}}.
-
-
-lru_opts() ->
-    case application:get_env(ddoc_cache, max_objects) of
-        {ok, MxObjs} when is_integer(MxObjs), MxObjs > 0 ->
-            [{max_objects, MxObjs}];
-        _ ->
-            []
-    end ++
-    case application:get_env(ddoc_cache, max_size) of
-        {ok, MxSize} when is_integer(MxSize), MxSize > 0 ->
-            [{max_size, MxSize}];
-        _ ->
-            []
-    end ++
-    case application:get_env(ddoc_cache, max_lifetime) of
-        {ok, MxLT} when is_integer(MxLT), MxLT > 0 ->
-            [{max_lifetime, MxLT}];
-        _ ->
-            []
-    end.

http://git-wip-us.apache.org/repos/asf/couchdb/blob/572ee3ce/src/ddoc_cache/src/ddoc_cache_util.erl
----------------------------------------------------------------------
diff --git a/src/ddoc_cache/src/ddoc_cache_util.erl b/src/ddoc_cache/src/ddoc_cache_util.erl
deleted file mode 100644
index fb3c0b9..0000000
--- a/src/ddoc_cache/src/ddoc_cache_util.erl
+++ /dev/null
@@ -1,34 +0,0 @@
-% 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(ddoc_cache_util).
-
-
--export([
-    new_uuid/0
-]).
-
-
-new_uuid() ->
-    to_hex(crypto:rand_bytes(16), []).
-
-
-to_hex(<<>>, Acc) ->
-    list_to_binary(lists:reverse(Acc));
-to_hex(<<C1:4, C2:4, Rest/binary>>, Acc) ->
-    to_hex(Rest, [hexdig(C1), hexdig(C2) | Acc]).
-
-
-hexdig(C) when C >= 0, C =< 9 ->
-    C + $0;
-hexdig(C) when C >= 10, C =< 15 ->
-    C + $A - 10.


Mime
View raw message