diff options
author | Robert Newson <robert.newson@cloudant.com> | 2012-11-14 19:32:23 +0000 |
---|---|---|
committer | Robert Newson <robert.newson@cloudant.com> | 2012-11-15 11:23:46 +0000 |
commit | 19017b3612b4567ced3b8ac9cfe816e6cf80e0f8 (patch) | |
tree | a0ffdab1271fb3ffd0c95b22340c7f10c5e98e53 /apps/couch/src/couch_view_compactor.erl | |
parent | bf4d46be7037ddea375bdaf2bab067e29f2c423f (diff) |
Backport new /_active_tasks API
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
BugzID: 14269
Conflicts:
apps/couch/src/couch_db_updater.erl
apps/couch/src/couch_rep.erl
apps/couch/src/couch_task_status.erl
apps/couch/src/couch_view_compactor.erl
apps/couch/src/couch_view_updater.erl
Diffstat (limited to 'apps/couch/src/couch_view_compactor.erl')
-rw-r--r-- | apps/couch/src/couch_view_compactor.erl | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/apps/couch/src/couch_view_compactor.erl b/apps/couch/src/couch_view_compactor.erl index 8ea1dca2..1d789d35 100644 --- a/apps/couch/src/couch_view_compactor.erl +++ b/apps/couch/src/couch_view_compactor.erl @@ -49,7 +49,12 @@ compact_group(Group, EmptyGroup, DbName) -> <<"_design", ShortName/binary>> = GroupId, TaskName = <<DbName/binary, ShortName/binary>>, - couch_task_status:add_task(<<"View Group Compaction">>, TaskName, <<"">>), + couch_task_status:add_task([ + {type, view_compaction}, + {database, DbName}, + {design_document, ShortName}, + {progress, 0} + ]), Fun = fun({DocId, _ViewIdKeys} = KV, {Bt, Acc, TotalCopied, LastId}) -> if DocId =:= LastId -> % COUCHDB-999 @@ -59,8 +64,7 @@ compact_group(Group, EmptyGroup, DbName) -> exit({view_duplicated_id, DocId}); true -> ok end, if TotalCopied rem 10000 =:= 0 -> - couch_task_status:update("Copied ~p of ~p Ids (~p%)", - [TotalCopied, Count, (TotalCopied*100) div Count]), + couch_task_status:update([{changes_done, TotalCopied}, {progress, (TotalCopied * 100) div Count}]), {ok, Bt2} = couch_btree:add(Bt, lists:reverse([KV|Acc])), {ok, {Bt2, [], TotalCopied+1, DocId}}; true -> @@ -108,8 +112,7 @@ compact_view(View, EmptyView) -> %% Key is {Key,DocId} Fun = fun(KV, {Bt, Acc, TotalCopied}) -> if TotalCopied rem 10000 =:= 0 -> - couch_task_status:update("View #~p: copied ~p of ~p KVs (~p%)", - [View#view.id_num, TotalCopied, Count, (TotalCopied*100) div Count]), + couch_task_status:update([{changes_done, TotalCopied}, {progress, (TotalCopied * 100) div Count}]), {ok, Bt2} = couch_btree:add(Bt, lists:reverse([KV|Acc])), {ok, {Bt2, [], TotalCopied + 1}}; true -> @@ -121,4 +124,3 @@ compact_view(View, EmptyView) -> {EmptyView#view.btree, [], 0}), {ok, NewBt} = couch_btree:add(Bt3, lists:reverse(Uncopied)), EmptyView#view{btree = NewBt}. - |