couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e...@apache.org
Subject [1/2] chttpd commit: updated refs/heads/master to 5a96fa8
Date Thu, 02 Jun 2016 19:30:25 GMT
Repository: couchdb-chttpd
Updated Branches:
  refs/heads/master 880dedc94 -> 5a96fa895


Fix _node/$node/_system endpoint

The endpoint is using same handler as a backdoor interface,
which only works for the requests to a local $node.
For rpc calls to the remote nodes, the same as it's done
on rest of /_node endpoints, handle_node_req handler is getting
{badrpc,{'EXIT',normal}} response and fails with invalid_ejson exception.

The change splits stats gathering from stats responding,
allowing to use former on both /_node/$node/_system
and backend's /_system endpoints.


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

Branch: refs/heads/master
Commit: cdeab872144d30ef89c5aca36a3adbf22766c092
Parents: 880dedc
Author: Eric Avdey <eiri@eiri.ca>
Authored: Fri May 27 14:59:23 2016 -0300
Committer: Eric Avdey <eiri@eiri.ca>
Committed: Thu Jun 2 16:23:23 2016 -0300

----------------------------------------------------------------------
 src/chttpd_misc.erl | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/cdeab872/src/chttpd_misc.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_misc.erl b/src/chttpd_misc.erl
index 0f573cb..2f56f4b 100644
--- a/src/chttpd_misc.erl
+++ b/src/chttpd_misc.erl
@@ -26,7 +26,8 @@
     handle_utils_dir_req/2,
     handle_uuids_req/1,
     handle_welcome_req/1,
-    handle_welcome_req/2
+    handle_welcome_req/2,
+    get_stats/0
 ]).
 
 -include_lib("couch/include/couch_db.hrl").
@@ -294,8 +295,9 @@ handle_node_req(#httpd{path_parts=[_, _Node, <<"_stats">>]}=Req)
->
     send_method_not_allowed(Req, "GET");
 % GET /_node/$node/_system
 handle_node_req(#httpd{method='GET', path_parts=[_, Node, <<"_system">>]}=Req)
->
-    Stats = call_node(Node, chttpd_misc, handle_system_req, [Req]),
-    chttpd:send_json(Req, Stats);
+    Stats = call_node(Node, chttpd_misc, get_stats, []),
+    EJSON = couch_stats_httpd:to_ejson(Stats),
+    send_json(Req, EJSON);
 handle_node_req(#httpd{path_parts=[_, _Node, <<"_system">>]}=Req) ->
     send_method_not_allowed(Req, "GET");
 handle_node_req(#httpd{path_parts=[_]}=Req) ->
@@ -334,6 +336,11 @@ flush(Node, Req) ->
 % Note: this resource is exposed on the backdoor interface, but it's in chttpd
 % because it's not couch trunk
 handle_system_req(Req) ->
+    Stats = get_stats(),
+    EJSON = couch_stats_httpd:to_ejson(Stats),
+    send_json(Req, EJSON).
+
+get_stats() ->
     Other = erlang:memory(system) - lists:sum([X || {_,X} <-
         erlang:memory([atom, code, binary, ets])]),
     Memory = [{other, Other} | erlang:memory([atom, atom_used, processes,
@@ -343,7 +350,7 @@ handle_system_req(Req) ->
     {CF, CDU} = db_pid_stats(),
     MessageQueues0 = [{couch_file, {CF}}, {couch_db_updater, {CDU}}],
     MessageQueues = MessageQueues0 ++ message_queues(registered()),
-    send_json(Req, {[
+    [
         {uptime, element(1,statistics(wall_clock)) div 1000},
         {memory, {Memory}},
         {run_queue, statistics(run_queue)},
@@ -361,7 +368,7 @@ handle_system_req(Req) ->
         {message_queues, {MessageQueues}},
         {internal_replication_jobs, mem3_sync:get_backlog()},
         {distribution, {get_distribution_stats()}}
-    ]}).
+    ].
 
 db_pid_stats() ->
     {monitors, M} = process_info(whereis(couch_stats_process_tracker), monitors),


Mime
View raw message