Repository: couchdb-fabric Updated Branches: refs/heads/master 42a67d0a0 -> 140bcfacb
add clusterwide compaction for dbs PRs: https://github.com/apache/couchdb-fabric/pull/27 https://github.com/apache/couchdb-chttpd/pull/62 COUCHDB-2492 PR: #27 PR-URL: https://github.com/apache/couchdb-fabric/pull/27 Reviewed-By: Robert Newson <rnew...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/commit/140bcfac Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/tree/140bcfac Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/diff/140bcfac Branch: refs/heads/master Commit: 140bcfacbb220bc3b47697fdd7b8b306eb6d7330 Parents: 42a67d0 Author: Robert Kowalski <robertkowal...@apache.org> Authored: Fri Aug 21 14:16:34 2015 +0200 Committer: Robert Kowalski <robertkowal...@apache.org> Committed: Thu Aug 27 15:52:09 2015 +0200 ---------------------------------------------------------------------- src/fabric.erl | 6 +++++- src/fabric_rpc.erl | 11 ++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/140bcfac/src/fabric.erl ---------------------------------------------------------------------- diff --git a/src/fabric.erl b/src/fabric.erl index 07c4c9c..c52c10a 100644 --- a/src/fabric.erl +++ b/src/fabric.erl @@ -33,7 +33,7 @@ % miscellany -export([design_docs/1, reset_validation_funs/1, cleanup_index_files/0, - cleanup_index_files/1, dbname/1]). + cleanup_index_files/1, dbname/1, compact_db/1]). -include_lib("fabric/include/fabric.hrl"). @@ -411,6 +411,10 @@ reset_validation_funs(DbName) -> [rexi:cast(Node, {fabric_rpc, reset_validation_funs, [Name]}) || #shard{node=Node, name=Name} <- mem3:shards(DbName)]. +compact_db(DbName) -> + [rexi:cast(Node, {fabric_rpc, compact_db, [Name]}) || + #shard{node=Node, name=Name} <- mem3:shards(DbName)]. + %% @doc clean up index files for all Dbs -spec cleanup_index_files() -> [ok]. cleanup_index_files() -> http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/140bcfac/src/fabric_rpc.erl ---------------------------------------------------------------------- diff --git a/src/fabric_rpc.erl b/src/fabric_rpc.erl index 057dec3..aef34bc 100644 --- a/src/fabric_rpc.erl +++ b/src/fabric_rpc.erl @@ -21,7 +21,8 @@ -export([get_all_security/2, open_shard/2]). -export([get_db_info/2, get_doc_count/2, get_update_seq/2, - changes/4, map_view/5, reduce_view/5, group_info/3]). + changes/4, map_view/5, reduce_view/5, group_info/3, + compact_db/1]). -include_lib("fabric/include/fabric.hrl"). -include_lib("couch/include/couch_db.hrl"). @@ -132,6 +133,14 @@ delete_db(DbName) -> delete_shard_db_doc(_, DocId) -> rexi:reply(mem3_util:delete_db_doc(DocId)). +compact_db(DbName) -> + {ok, Db} = couch_db:open(DbName, [?ADMIN_CTX]), + try + {ok, _} = couch_db:start_compact(Db) + after + couch_db:close(Db) + end. + %% @equiv get_db_info(DbName, []) get_db_info(DbName) -> get_db_info(DbName, []).