Permalink
Browse files

Merge branch 'master' into view_changes

Conflicts:
	apps/couch_changes/include/couch_changes.hrl
	apps/couch_changes/src/couch_changes.erl
	apps/couch_changes/src/couch_httpd_changes.erl
	apps/couch_replicator/src/couch_replicator_api_wrap.erl
  • Loading branch information...
2 parents 56bb344 + f8e221c commit e942d68278e6654b6072ceb0f725e5f35c4f57b5 @benoitc benoitc committed May 26, 2012
Showing with 864 additions and 75 deletions.
  1. +1 −2 Makefile
  2. 0 apps/couch/priv/.keep
  3. +1 −3 apps/couch/src/couch.app.src
  4. +8 −0 apps/couch/src/couch_db.erl
  5. +6 −0 apps/couch/src/couch_primary_sup.erl
  6. +12 −1 apps/couch/src/couch_server_sup.erl
  7. +1 −1 apps/couch/src/couch_util.erl
  8. +2 −2 apps/couch/src/couch_uuids.erl
  9. +0 −2 apps/couch/test/etap/001-load.t
  10. +1 −1 apps/couch/test/etap/041-uuid-gen.t
  11. +1 −1 apps/couch_changes/src/couch_changes.erl
  12. +2 −2 apps/couch_changes/src/couch_httpd_changes.erl
  13. +11 −1 apps/couch_httpd/src/couch_httpd_misc_handlers.erl
  14. +4 −1 apps/couch_httpd/src/couch_httpd_vhost.erl
  15. +1 −4 apps/couch_index/src/couch_index.app.src
  16. +505 −0 apps/couch_stats/LICENSE
  17. +75 −0 apps/couch_stats/NOTICE
  18. +8 −0 apps/couch_stats/ebin/couch_stats.app
  19. 0 apps/{couch → couch_stats}/priv/stat_descriptions.cfg
  20. +1 −0 apps/couch_stats/rebar.config
  21. +23 −0 apps/couch_stats/src/couch_stats.app.src
  22. +77 −34 apps/{couch → couch_stats}/src/couch_stats_aggregator.erl
  23. +23 −0 apps/couch_stats/src/couch_stats_app.erl
  24. +3 −3 apps/{couch → couch_stats}/src/couch_stats_collector.erl
  25. +30 −0 apps/couch_stats/src/couch_stats_sup.erl
  26. +7 −7 apps/{couch/test/etap → couch_stats/tests}/120-stats-collect.t
  27. 0 apps/{couch/test/etap → couch_stats/tests}/121-stats-aggregates.cfg
  28. 0 apps/{couch/test/etap → couch_stats/tests}/121-stats-aggregates.ini
  29. +3 −3 apps/{couch/test/etap → couch_stats/tests}/121-stats-aggregates.t
  30. +0 −4 example/rel/files/default.ini
  31. +50 −0 example/rel/files/stat_descriptions.cfg.sample
  32. +5 −0 example/rel/reltool.config
  33. +1 −0 rebar.config
  34. +0 −3 test/files/default.ini
  35. +2 −0 test/reltool.config
View
@@ -1,7 +1,6 @@
ERLC ?= erlc
-
-all: check
+all: deps compile
compile:
rebar -C rebar_dev.config compile
View
No changes.
@@ -12,12 +12,10 @@
couch_rep_sup,
couch_secondary_services,
couch_server,
- couch_stats_aggregator,
- couch_stats_collector,
couch_task_status
]},
{mod, {couch_app, []}},
{applications, [kernel, stdlib, crypto, lager, sasl, public_key, ssl,
- inets, os_mon]}
+ inets, os_mon, couch_stats]}
]}.
@@ -335,6 +335,14 @@ check_is_admin(#db{user_ctx=#user_ctx{name=Name,roles=Roles}}=Db) ->
ok
end.
+check_is_member(#db{name = <<"rc_", _/binary>> } = Db) ->
+ case (catch check_is_admin(Db)) of
+ ok ->
+ ok;
+ _ ->
+ throw({unauthorized,
+ <<"You are not authorized to access this db.">>})
+ end;
check_is_member(#db{user_ctx=#user_ctx{name=Name,roles=Roles}=UserCtx}=Db) ->
case (catch check_is_admin(Db)) of
ok -> ok;
@@ -19,6 +19,12 @@ start_link() ->
init([]) ->
Children = [
+ {couch_uuids,
+ {couch_uuids, start_link, []},
+ permanent,
+ brutal_kill,
+ worker,
+ [couch_uuids]},
{couch_task_status,
{couch_task_status, start_link, []},
permanent,
@@ -112,7 +112,18 @@ stop() ->
config_change("daemons", _) ->
supervisor:terminate_child(couch_server_sup, couch_secondary_services),
- supervisor:restart_child(couch_server_sup, couch_secondary_services).
+ supervisor:restart_child(couch_server_sup,
+ couch_secondary_services);
+config_change("stat", "rate") ->
+ NewRate = integer_to_list(
+ couch_config:get_value("stats", "rate", "1000")
+ ),
+ couch_stats_aggregator:set_rate(NewRate);
+config_change("stats", "samples") ->
+ SampleStr = couch_config:get("stats", "samples", "[0]"),
+ {ok, Samples} = couch_util:parse_term(SampleStr),
+ couch_stats_aggregator:set_samples(Samples).
+
init(ChildSpecs) ->
{ok, ChildSpecs}.
@@ -28,7 +28,7 @@
-export([url_strip_password/1]).
-export([encode_doc_id/1]).
-export([with_db/2]).
--export([start_app_deps/1]).
+-export([start_app_deps/1, ensure_started/1]).
-export([capitalize/1]).
-export([json_decode/1]).
-export([get_uri/2, get_scheme/1, get_port/1]).
@@ -14,13 +14,13 @@
-behaviour(gen_server).
--export([start/0, stop/0]).
+-export([start_link/0, stop/0]).
-export([new/0, random/0, utc_random/0]).
-export([init/1, terminate/2, code_change/3]).
-export([handle_call/3, handle_cast/2, handle_info/2]).
-start() ->
+start_link() ->
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
stop() ->
@@ -39,8 +39,6 @@ main(_) ->
couch_ref_counter,
couch_server,
couch_server_sup,
- couch_stats_aggregator,
- couch_stats_collector,
couch_stream,
couch_task_status,
couch_util,
@@ -26,7 +26,7 @@ utc_alg_config() ->
run_test(IniFiles, Test) ->
{ok, Pid} = couch_config:start_link(IniFiles),
erlang:monitor(process, Pid),
- couch_uuids:start(),
+ couch_uuids:start_link(),
Test(),
couch_uuids:stop(),
couch_config:stop(),
@@ -12,9 +12,9 @@
-module(couch_changes).
+-include("couch_changes.hrl").
-include_lib("couch/include/couch_db.hrl").
-include_lib("couch_httpd/include/couch_httpd.hrl").
--include_lib("couch_changes/include/couch_changes.hrl").
-include_lib("couch_mrview/include/couch_mrview.hrl").
-export([handle_changes/3]).
@@ -11,7 +11,7 @@
% the License.
-module(couch_httpd_changes).
--include_lib("couch_changes/include/couch_changes.hrl").
+-include("couch_changes.hrl").
-include_lib("couch/include/couch_db.hrl").
-include_lib("couch_httpd/include/couch_httpd.hrl").
-export([handle_changes_req/2]).
@@ -101,7 +101,7 @@ do_changes_req(_Db, Req, #changes_args{feed="eventsource"}, ChangesFun,
{"Content-Type", "text/event-stream"},
{"Cache-Control", "no-cache"}
],
- {ok, Resp} = couch_httpd:start_json_response(Req, 200, Headers),
+ {ok, Resp} = couch_httpd:start_chunked_response(Req, 200, Headers),
ChangesFun(MakeCallback(Resp));
do_changes_req(_Db, Req, _ChangesArgs, ChangesFun, MakeCallback) ->
% "longpoll" or "continuous"
@@ -74,7 +74,17 @@ handle_utils_dir_req(Req, _) ->
send_method_not_allowed(Req, "GET,HEAD").
handle_all_dbs_req(#httpd{method='GET'}=Req) ->
- {ok, DbNames} = couch_server:all_databases(),
+ IsAdmin = case catch(couch_httpd:verify_is_server_admin(Req)) of
+ ok -> true;
+ _ -> false
+ end,
+ {ok, DbNames} = couch_server:all_databases(fun
+ (<<"rc_", _/binary>>, Acc)
+ when IsAdmin =:= false ->
+ {ok, Acc};
+ (Dbname, Acc) ->
+ {ok, [Dbname|Acc]}
+ end, []),
send_json(Req, DbNames);
handle_all_dbs_req(Req) ->
send_method_not_allowed(Req, "GET,HEAD").
@@ -245,7 +245,10 @@ bind_path(_, _) ->
%% create vhost list from ini
make_vhosts() ->
- Vhosts = lists:foldl(fun({Vhost, Path}, Acc) ->
+ Vhosts = lists:foldl(fun
+ ({_, ""}, Acc) ->
+ Acc;
+ ({Vhost, Path}, Acc) ->
[{parse_vhost(Vhost), split_path(Path)}|Acc]
end, [], couch_config:get("vhosts")),
@@ -13,10 +13,7 @@
{application, couch_index, [
{description, "CouchDB Secondary Index Manager"},
{vsn, "0.1"},
- {modules, [
- couch_index,
- couch_index_server
- ]},
+ {modules, []},
{registered, [couch_index_server]},
{applications, [kernel, stdlib, couch]},
{mod, {couch_index_app, []}}
Oops, something went wrong.

0 comments on commit e942d68

Please sign in to comment.