couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robertkowal...@apache.org
Subject [1/4] chttpd commit: updated refs/heads/2492-compaction to 3b50727
Date Thu, 27 Aug 2015 13:34:43 GMT
Repository: couchdb-chttpd
Updated Branches:
  refs/heads/2492-compaction [created] 3b507275d


add clusterwide compaction for dbs

COUCHDB-2492


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

Branch: refs/heads/2492-compaction
Commit: 0648df6b7fabf9e081baa14d19a1ddadd5ea0f7b
Parents: b8437a9
Author: Robert Kowalski <robertkowalski@apache.org>
Authored: Fri Aug 21 14:13:18 2015 +0200
Committer: Robert Kowalski <robertkowalski@apache.org>
Committed: Fri Aug 21 14:13:18 2015 +0200

----------------------------------------------------------------------
 src/chttpd_db.erl | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/0648df6b/src/chttpd_db.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_db.erl b/src/chttpd_db.erl
index a8fdc16..1fec0ec 100644
--- a/src/chttpd_db.erl
+++ b/src/chttpd_db.erl
@@ -225,9 +225,19 @@ maybe_flush_changes_feed(Acc0, Data, Len) ->
     },
     {ok, Acc}.
 
-handle_compact_req(Req, _) ->
-    Msg = <<"Compaction must be triggered on a per-shard basis in CouchDB">>,
-    couch_httpd:send_error(Req, 403, forbidden, Msg).
+handle_compact_req(#httpd{method='POST'}=Req, Db) ->
+    case Req#httpd.path_parts of
+        [_DbName, <<"_compact">>] ->
+            ok = couch_db:check_is_admin(Db),
+            couch_httpd:validate_ctype(Req, "application/json"),
+            _ = couch_httpd:body(Req),
+            fabric:compact_db_all_nodes(Db#db.name),
+            send_json(Req, 202, {[{ok, true}]});
+    end;
+
+handle_compact_req(Req, _Db) ->
+    send_method_not_allowed(Req, "POST").
+
 
 handle_view_cleanup_req(Req, Db) ->
     ok = fabric:cleanup_index_files(Db),


Mime
View raw message