Improved _active_tasks API

Tasks are now free to set any properties they wish (as an
Erlang proplist). Different tasks can have different properties
and the status string doesn't exist anymore - instead client
applications can build it using more granular properties from
_active_tasks. Some of these properties are:

1) "progress" (an integer percentage, for all tasks)
2) "database" (for compactions and indexer tasks)
3) "design_document" (for indexer and view compaction tasks)
4) "source" and "target" (for replications)
5) "docs_read", "docs_written", "doc_write_failures",
   "missing_revs_found", "missing_revs_checked", "source_seq",
   "checkpointed_source_seq" and "continuous" for replications



git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@1171888 
13f79535-47bb-0310-9956-ffa450edef68


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/00998154
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/tree/00998154
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/diff/00998154

Branch: refs/heads/import
Commit: 00998154f36840b0f6cb95bbc4b16c96a68dd737
Parents: e29573b
Author: Filipe David Borba Manana <fdman...@apache.org>
Authored: Sat Sep 17 03:31:12 2011 +0000
Committer: Filipe David Borba Manana <fdman...@apache.org>
Committed: Sat Sep 17 03:31:12 2011 +0000

----------------------------------------------------------------------
 src/couch_index_api.erl     |  2 +-
 src/couch_index_updater.erl | 29 ++++++-----------------------
 2 files changed, 7 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/blob/00998154/src/couch_index_api.erl
----------------------------------------------------------------------
diff --git a/src/couch_index_api.erl b/src/couch_index_api.erl
index 24b01f9..6a5087f 100644
--- a/src/couch_index_api.erl
+++ b/src/couch_index_api.erl
@@ -29,7 +29,7 @@ reset(State) ->
     ok.
 
 
-start_update(State) ->
+start_update(State, PurgedState, NumChanges) ->
     {ok, State}.
 
 purge(PurgedIdRevs, State) ->

http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/blob/00998154/src/couch_index_updater.erl
----------------------------------------------------------------------
diff --git a/src/couch_index_updater.erl b/src/couch_index_updater.erl
index 1b90d2a..fb60136 100644
--- a/src/couch_index_updater.erl
+++ b/src/couch_index_updater.erl
@@ -121,10 +121,6 @@ update(Idx, Mod, IdxState) ->
         _ -> [conflicts, deleted_conflicts]
     end,
 
-    TaskType = <<"Indexer">>,
-    Starting = <<"Starting index update.">>,
-    couch_task_status:add_task(TaskType, Mod:get(idx_name, IdxState), 
Starting),
-
     couch_util:with_db(DbName, fun(Db) ->
         DbUpdateSeq = couch_db:get_update_seq(Db),
         DbCommittedSeq = couch_db:get_committed_update_seq(Db),
@@ -134,7 +130,6 @@ update(Idx, Mod, IdxState) ->
             reset -> exit(reset)
         end,
 
-        couch_task_status:set_update_frequency(500),
         NumChanges = couch_db:count_changes_since(Db, CurrSeq),
 
         LoadDoc = fun(DocInfo) ->
@@ -155,23 +150,22 @@ update(Idx, Mod, IdxState) ->
             end
         end,
 
-        Proc = fun(DocInfo, _, {IdxStateAcc, Count, _}) ->
+        Proc = fun(DocInfo, _, {IdxStateAcc, _}) ->
             HighSeq = DocInfo#doc_info.high_seq,
             case CommittedOnly and (HighSeq > DbCommittedSeq) of
                 true ->
-                    {stop, {IdxStateAcc, Count, false}};
+                    {stop, {IdxStateAcc, false}};
                 false ->
-                    update_task_status(NumChanges, Count),
                     {Doc, Seq} = LoadDoc(DocInfo),
                     {ok, NewSt} = Mod:process_doc(Doc, Seq, IdxStateAcc),
-                    {ok, {NewSt, Count+1, true}}
+                    {ok, {NewSt, true}}
             end
         end,
 
-        {ok, InitIdxState} = Mod:start_update(Idx, PurgedIdxState),
-        Acc0 = {InitIdxState, 0, true},
+        {ok, InitIdxState} = Mod:start_update(Idx, PurgedIdxState, NumChanges),
+        Acc0 = {InitIdxState, true},
         {ok, _, Acc} = couch_db:enum_docs_since(Db, CurrSeq, Proc, Acc0, []),
-        {ProcIdxSt, _, SendLast} = Acc,
+        {ProcIdxSt, SendLast} = Acc,
 
         % If we didn't bail due to hitting the last committed seq we need
         % to send our last update_seq through.
@@ -182,9 +176,6 @@ update(Idx, Mod, IdxState) ->
                 {ok, ProcIdxSt}
         end,
 
-        couch_task_status:set_update_frequency(0),
-        couch_task_status:update("Waiting for index writer to finish."),
-
         {ok, FinalIdxState} = Mod:finish_update(LastIdxSt),
         exit({updated, FinalIdxState})
     end).
@@ -197,16 +188,8 @@ purge_index(Db, Mod, IdxState) ->
         DbPurgeSeq == IdxPurgeSeq ->
             {ok, IdxState};
         DbPurgeSeq == IdxPurgeSeq + 1 ->
-            couch_task_status:update(<<"Purging index entries.">>),
             {ok, PurgedIdRevs} = couch_db:get_last_purged(Db),
             Mod:purge(Db, DbPurgeSeq, PurgedIdRevs, IdxState);
         true ->
-            couch_task_status:update(<<"Resetting index due to purge 
state.">>),
             reset
     end.
-
-
-update_task_status(Total, Count) ->
-    PercDone = (Count * 100) div Total,
-    Mesg = "Processed ~p of ~p changes (~p%)",
-    couch_task_status:update(Mesg, [Count, Total, PercDone]).

Reply via email to