couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bbast...@apache.org
Subject [1/3] couch-index commit: updated refs/heads/8409-view-cache to 5510d33
Date Mon, 27 Feb 2017 22:05:40 GMT
Repository: couchdb-couch-index
Updated Branches:
  refs/heads/8409-view-cache [created] 5510d33c0


change couch_db_monitor to couch_monitor and couch_monitor_server


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/commit/55e8d848
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/tree/55e8d848
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/diff/55e8d848

Branch: refs/heads/8409-view-cache
Commit: 55e8d8481473cab1c6b24ee8953d275761e95157
Parents: c8fa777
Author: Benjamin Bastian <benjamin.bastian@gmail.com>
Authored: Tue Jan 24 12:19:53 2017 -0800
Committer: Benjamin Bastian <benjamin.bastian@gmail.com>
Committed: Tue Jan 24 12:46:50 2017 -0800

----------------------------------------------------------------------
 src/couch_index_server.erl | 62 ++++++++++++++++++++---------------------
 1 file changed, 31 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/blob/55e8d848/src/couch_index_server.erl
----------------------------------------------------------------------
diff --git a/src/couch_index_server.erl b/src/couch_index_server.erl
index b46c368..e93147e 100644
--- a/src/couch_index_server.erl
+++ b/src/couch_index_server.erl
@@ -13,7 +13,7 @@
 -module(couch_index_server).
 -behaviour(gen_server).
 -behaviour(config_listener).
--behaviour(couch_db_monitor).
+-behaviour(couch_monitor_server).
 
 -vsn(2).
 
@@ -29,7 +29,7 @@
     handle_db_event/3
 ]).
 
-% Exported for couch_db_monitor behavior
+% Exported for couch_monitor_server behavior
 -export([close/2, tab_name/1]).
 
 -include_lib("couch/include/couch_db.hrl").
@@ -113,10 +113,10 @@ get_index_int(Module, IdxState, SysOwned) ->
     DbName = Module:get(db_name, IdxState),
     Sig = Module:get(signature, IdxState),
     Args = {Module, IdxState, DbName, Sig, SysOwned},
-    case couch_db_monitor:incref(?MODULE, {DbName, Sig}) of
+    case couch_monitor_server:incref(?MODULE, {DbName, Sig}) of
         ok ->
-            {ok, {Pid, Monitor, _SysOwned}} = couch_db_monitor:lookup(?MODULE, name, {DbName,
Sig}),
-            ok = couch_db_monitor:notify(Monitor),
+            {ok, {Pid, Monitor, _SysOwned}} = couch_monitor_server:lookup(?MODULE, name,
{DbName, Sig}),
+            ok = couch_monitor:notify(Monitor),
             {ok, Pid};
         _ ->
             gen_server:call(?MODULE, {get_index, Args}, infinity)
@@ -131,7 +131,7 @@ init([]) ->
     RootDir = couch_index_util:root_dir(),
     couch_file:init_delete_dir(RootDir),
     MaxIndexesOpen = list_to_integer(config:get("couchdb", "max_indexes_open", integer_to_list(?MAX_INDEXES_OPEN))),
-    MonState = couch_db_monitor:new(?MODULE, MaxIndexesOpen),
+    MonState = couch_monitor_server:new(?MODULE, MaxIndexesOpen),
     {ok, #st{root_dir=RootDir, monitor_state=MonState}}.
 
 
@@ -141,7 +141,7 @@ terminate(_Reason, _State) ->
     ok.
 
 make_room(State, false) ->
-    case couch_db_monitor:maybe_close_idle(State#st.monitor_state) of
+    case couch_monitor_server:maybe_close_idle(State#st.monitor_state) of
         {ok, NewMonState} ->
             {ok, State#st{monitor_state=NewMonState}};
         Other ->
@@ -151,49 +151,49 @@ make_room(State, true) ->
     {ok, State}.
 
 handle_call({get_index, {_Mod, _IdxState, DbName, Sig, SysOwned}=Args}, From, State) ->
-    case couch_db_monitor:lookup(?MODULE, name, {DbName, Sig}) of
+    case couch_monitor_server:lookup(?MODULE, name, {DbName, Sig}) of
         not_found ->
             case make_room(State, SysOwned) of
                 {ok, NewState} ->
                     spawn_link(fun() -> new_index(Args) end),
-                    Monitor = couch_db_monitor:spawn_link(?MODULE, {DbName, Sig}, SysOwned),
-                    couch_db_monitor:insert(?MODULE, name, {DbName, Sig}, {[From], Monitor,
SysOwned}),
+                    Monitor = couch_monitor:spawn_link(?MODULE, {DbName, Sig}, SysOwned),
+                    couch_monitor_server:insert(?MODULE, name, {DbName, Sig}, {[From], Monitor,
SysOwned}),
                     {noreply, NewState};
                 {error, Reason} ->
                     {reply, {error, Reason}, State}
             end;
         {ok, {Waiters, Monitor, SysOwned}} when is_list(Waiters) ->
-            couch_db_monitor:insert(?MODULE, name, {DbName, Sig}, {[From | Waiters], Monitor,
SysOwned}),
+            couch_monitor_server:insert(?MODULE, name, {DbName, Sig}, {[From | Waiters],
Monitor, SysOwned}),
             {noreply, State};
         {ok, {Pid, Monitor, _SysOwned}} when is_pid(Pid) ->
-            ok = couch_db_monitor:incref(?MODULE, {DbName, Sig}),
-            ok = couch_db_monitor:notify(Monitor, From),
+            ok = couch_monitor_server:incref(?MODULE, {DbName, Sig}),
+            ok = couch_monitor:notify(Monitor, From),
             {reply, {ok, Pid}, State}
     end;
 handle_call({async_open, {DbName, DDocId, Sig}, {ok, Pid}}, _From, State) ->
-    {ok, {Waiters, Monitor, SysOwned}} = couch_db_monitor:lookup(?MODULE, name, {DbName,
Sig}),
+    {ok, {Waiters, Monitor, SysOwned}} = couch_monitor_server:lookup(?MODULE, name, {DbName,
Sig}),
     link(Pid),
-    couch_db_monitor:insert(?MODULE, name, {DbName, Sig}, {Pid, Monitor, SysOwned}),
-    couch_db_monitor:insert(?MODULE, pid, Pid, {DbName, Sig}),
-    couch_db_monitor:insert(?MODULE, counters, {DbName, Sig}, 0),
+    couch_monitor_server:insert(?MODULE, name, {DbName, Sig}, {Pid, Monitor, SysOwned}),
+    couch_monitor_server:insert(?MODULE, pid, Pid, {DbName, Sig}),
+    couch_monitor_server:insert(?MODULE, counters, {DbName, Sig}, 0),
     ets:insert(?BY_DB, {DbName, {DDocId, Sig}}),
     lists:foreach(fun(From) ->
         {Client, _} = From,
-        ok = couch_db_monitor:incref(?MODULE, {DbName, Sig}),
-        ok = couch_db_monitor:notify(Monitor, Client),
+        ok = couch_monitor_server:incref(?MODULE, {DbName, Sig}),
+        ok = couch_monitor:notify(Monitor, Client),
         gen_server:reply(From, {ok, Pid})
     end, Waiters),
-    {reply, ok, State#st{monitor_state=couch_db_monitor:opened(State#st.monitor_state, SysOwned)}};
+    {reply, ok, State#st{monitor_state=couch_monitor_server:opened(State#st.monitor_state,
SysOwned)}};
 handle_call({async_error, {DbName, _DDocId, Sig}, Error}, {FromPid, _}, State) ->
-    {ok, {Waiters, Monitor, _SO}} = couch_db_monitor:lookup(?MODULE, name, {DbName, Sig}),
+    {ok, {Waiters, Monitor, _SO}} = couch_monitor_server:lookup(?MODULE, name, {DbName, Sig}),
     [gen_server:reply(From, Error) || From <- Waiters],
-    couch_db_monitor:delete(?MODULE, {DbName, Sig}, FromPid),
-    ok = couch_db_monitor:close(Monitor),
+    couch_monitor_server:delete(?MODULE, {DbName, Sig}, FromPid),
+    ok = couch_monitor:close(Monitor),
     {reply, ok, State};
 handle_call({reset_indexes, DbName}, _From, State) ->
     {reply, ok, reset_indexes(DbName, State)};
 handle_call(open_index_count, _From, State) ->
-    {reply, couch_db_monitor:num_open(State#st.monitor_state), State};
+    {reply, couch_monitor_server:num_open(State#st.monitor_state), State};
 handle_call(get_server, _From, State) ->
     {reply, State, State}.
 
@@ -202,7 +202,7 @@ handle_cast({reset_indexes, DbName}, State) ->
     {noreply, reset_indexes(DbName, State)}.
 
 handle_info({'EXIT', Pid, Reason}, Server) ->
-    case couch_db_monitor:lookup(?MODULE, pid, Pid) of
+    case couch_monitor_server:lookup(?MODULE, pid, Pid) of
         {ok, {DbName, Sig}} ->
             [{DbName, {DDocId, Sig}}] =
                 ets:match_object(?BY_DB, {DbName, {'$1', Sig}}),
@@ -247,7 +247,7 @@ handle_config_terminate(_Server, _Reason, _State) ->
     erlang:send_after(?RELISTEN_DELAY, whereis(?MODULE), restart_config_listener),
     {ok, couch_index_util:root_dir()}.
 
-% couch_db_monitor behavior implementation
+% couch_monitor_server behavior implementation
 tab_name(name) -> couch_index;
 tab_name(pid) -> couch_index_by_pid;
 tab_name(counters) -> couch_index_counters;
@@ -275,13 +275,13 @@ reset_indexes(DbName, State) ->
     #st{root_dir=Root, monitor_state=MonState} = State,
     % shutdown all the updaters and clear the files, the db got changed
     Fun = fun({_, {DDocId, Sig}}, MonStateAcc) ->
-        {ok, {Pid, Monitor, SysOwned}} = couch_db_monitor:lookup(?MODULE, name, {DbName,
Sig}),
-        couch_db_monitor:close(Monitor),
+        {ok, {Pid, Monitor, SysOwned}} = couch_monitor_server:lookup(?MODULE, name, {DbName,
Sig}),
+        couch_monitor:close(Monitor),
         MRef = erlang:monitor(process, Pid),
         gen_server:cast(Pid, delete),
         receive {'DOWN', MRef, _, _, _} -> ok end,
         rem_from_ets(DbName, Sig, DDocId, Pid),
-        couch_db_monitor:closed(MonStateAcc, SysOwned)
+        couch_monitor_server:closed(MonStateAcc, SysOwned)
     end,
     NewMonState = lists:foldl(Fun, MonState, ets:lookup(?BY_DB, DbName)),
     Path = couch_index_util:index_dir("", DbName),
@@ -290,7 +290,7 @@ reset_indexes(DbName, State) ->
 
 
 rem_from_ets(DbName, Sig, DDocId, Pid) ->
-    couch_db_monitor:delete(?MODULE, {DbName, Sig}, Pid),
+    couch_monitor_server:delete(?MODULE, {DbName, Sig}, Pid),
     ets:delete_object(?BY_DB, {DbName, {DDocId, Sig}}).
 
 
@@ -302,7 +302,7 @@ handle_db_event(DbName, deleted, St) ->
     {ok, St};
 handle_db_event(DbName, {ddoc_updated, DDocId}, St) ->
     lists:foreach(fun({_DbName, {_DDocId, Sig}}) ->
-        case couch_db_monitor:lookup(?MODULE, name, {DbName, Sig}) of
+        case couch_monitor_server:lookup(?MODULE, name, {DbName, Sig}) of
             {ok, {IndexPid, _Monitor, _SysOwned}} ->
                 (catch gen_server:cast(IndexPid, ddoc_updated));
             not_found ->


Mime
View raw message