trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpe...@apache.org
Subject [trafficserver] 02/03: Refactor network stats registration for readability.
Date Mon, 26 Sep 2016 20:47:21 GMT
This is an automated email from the ASF dual-hosted git repository.

jpeach pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/trafficserver.git

commit 538447dcc2f70f3639ae7a5e664cd11537ca406a
Author: James Peach <jpeach@apache.org>
AuthorDate: Wed Sep 21 12:57:08 2016 -0700

    Refactor network stats registration for readability.
---
 iocore/net/Net.cc | 95 ++++++++++++++++++++-----------------------------------
 1 file changed, 34 insertions(+), 61 deletions(-)

diff --git a/iocore/net/Net.cc b/iocore/net/Net.cc
index 74fe378..10427be 100644
--- a/iocore/net/Net.cc
+++ b/iocore/net/Net.cc
@@ -29,6 +29,7 @@
 ************************************************************************/
 
 #include "P_Net.h"
+#include <utility>
 
 RecRawStatBlock *net_rsb = NULL;
 
@@ -56,82 +57,54 @@ configure_net(void)
 static inline void
 register_net_stats()
 {
-  //
-  // Register statistics
-  //
-  RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.net_handler_run", RECD_INT,
RECP_PERSISTENT,
-                     (int)net_handler_run_stat, RecRawStatSyncSum);
-  NET_CLEAR_DYN_STAT(net_handler_run_stat);
-
-  RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.read_bytes", RECD_INT, RECP_PERSISTENT,
(int)net_read_bytes_stat,
-                     RecRawStatSyncSum);
+  const std::pair<const char *, Net_Stats> persistent[] = {
+    {"proxy.process.net.calls_to_read", net_calls_to_read_stat},
+    {"proxy.process.net.calls_to_read_nodata", net_calls_to_read_nodata_stat},
+    {"proxy.process.net.calls_to_readfromnet", net_calls_to_readfromnet_stat},
+    {"proxy.process.net.calls_to_readfromnet_afterpoll", net_calls_to_readfromnet_afterpoll_stat},
+    {"proxy.process.net.calls_to_write", net_calls_to_write_stat},
+    {"proxy.process.net.calls_to_write_nodata", net_calls_to_write_nodata_stat},
+    {"proxy.process.net.calls_to_writetonet", net_calls_to_writetonet_stat},
+    {"proxy.process.net.calls_to_writetonet_afterpoll", net_calls_to_writetonet_afterpoll_stat},
+    {"proxy.process.net.inactivity_cop_lock_acquire_failure", inactivity_cop_lock_acquire_failure_stat},
+    {"proxy.process.net.net_handler_run", net_handler_run_stat},
+    {"proxy.process.net.read_bytes", net_read_bytes_stat},
+    {"proxy.process.net.write_bytes", net_write_bytes_stat},
+    {"proxy.process.socks.connections_successful", socks_connections_successful_stat},
+    {"proxy.process.socks.connections_unsuccessful", socks_connections_unsuccessful_stat},
+  };
+
+  const std::pair<const char *, Net_Stats> non_persistent[] = {
+    {"proxy.process.net.accepts_currently_open", net_accepts_currently_open_stat},
+    {"proxy.process.net.connections_currently_open", net_connections_currently_open_stat},
+    {"proxy.process.net.default_inactivity_timeout_applied", default_inactivity_timeout_stat},
+    {"proxy.process.net.dynamic_keep_alive_timeout_in_count", keep_alive_queue_timeout_count_stat},
+    {"proxy.process.net.dynamic_keep_alive_timeout_in_total", keep_alive_queue_timeout_total_stat},
+    {"proxy.process.socks.connections_currently_open", socks_connections_currently_open_stat},
+  };
+
+  for (auto &p : persistent) {
+    RecRegisterRawStat(net_rsb, RECT_PROCESS, p.first, RECD_INT, RECP_PERSISTENT, p.second,
RecRawStatSyncSum);
+  }
 
-  RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.write_bytes", RECD_INT, RECP_PERSISTENT,
(int)net_write_bytes_stat,
-                     RecRawStatSyncSum);
+  for (auto &p : non_persistent) {
+    RecRegisterRawStat(net_rsb, RECT_PROCESS, p.first, RECD_INT, RECP_NON_PERSISTENT, p.second,
RecRawStatSyncSum);
+  }
 
-  RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.connections_currently_open",
RECD_INT, RECP_NON_PERSISTENT,
-                     (int)net_connections_currently_open_stat, RecRawStatSyncSum);
+  NET_CLEAR_DYN_STAT(net_handler_run_stat);
   NET_CLEAR_DYN_STAT(net_connections_currently_open_stat);
-
-  RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.accepts_currently_open", RECD_INT,
RECP_NON_PERSISTENT,
-                     (int)net_accepts_currently_open_stat, RecRawStatSyncSum);
   NET_CLEAR_DYN_STAT(net_accepts_currently_open_stat);
-
-  RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.calls_to_readfromnet", RECD_INT,
RECP_PERSISTENT,
-                     (int)net_calls_to_readfromnet_stat, RecRawStatSyncSum);
   NET_CLEAR_DYN_STAT(net_calls_to_readfromnet_stat);
-
-  RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.calls_to_readfromnet_afterpoll",
RECD_INT, RECP_PERSISTENT,
-                     (int)net_calls_to_readfromnet_afterpoll_stat, RecRawStatSyncSum);
   NET_CLEAR_DYN_STAT(net_calls_to_readfromnet_afterpoll_stat);
-
-  RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.calls_to_read", RECD_INT,
RECP_PERSISTENT,
-                     (int)net_calls_to_read_stat, RecRawStatSyncSum);
   NET_CLEAR_DYN_STAT(net_calls_to_read_stat);
-
-  RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.calls_to_read_nodata", RECD_INT,
RECP_PERSISTENT,
-                     (int)net_calls_to_read_nodata_stat, RecRawStatSyncSum);
   NET_CLEAR_DYN_STAT(net_calls_to_read_nodata_stat);
-
-  RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.calls_to_writetonet", RECD_INT,
RECP_PERSISTENT,
-                     (int)net_calls_to_writetonet_stat, RecRawStatSyncSum);
   NET_CLEAR_DYN_STAT(net_calls_to_writetonet_stat);
-
-  RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.calls_to_writetonet_afterpoll",
RECD_INT, RECP_PERSISTENT,
-                     (int)net_calls_to_writetonet_afterpoll_stat, RecRawStatSyncSum);
   NET_CLEAR_DYN_STAT(net_calls_to_writetonet_afterpoll_stat);
-
-  RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.calls_to_write", RECD_INT,
RECP_PERSISTENT,
-                     (int)net_calls_to_write_stat, RecRawStatSyncSum);
   NET_CLEAR_DYN_STAT(net_calls_to_write_stat);
-
-  RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.calls_to_write_nodata", RECD_INT,
RECP_PERSISTENT,
-                     (int)net_calls_to_write_nodata_stat, RecRawStatSyncSum);
   NET_CLEAR_DYN_STAT(net_calls_to_write_nodata_stat);
-
-  RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.socks.connections_successful",
RECD_INT, RECP_PERSISTENT,
-                     (int)socks_connections_successful_stat, RecRawStatSyncSum);
-
-  RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.socks.connections_unsuccessful",
RECD_INT, RECP_PERSISTENT,
-                     (int)socks_connections_unsuccessful_stat, RecRawStatSyncSum);
-
-  RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.socks.connections_currently_open",
RECD_INT, RECP_NON_PERSISTENT,
-                     (int)socks_connections_currently_open_stat, RecRawStatSyncSum);
   NET_CLEAR_DYN_STAT(socks_connections_currently_open_stat);
-
-  RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.inactivity_cop_lock_acquire_failure",
RECD_INT, RECP_PERSISTENT,
-                     (int)inactivity_cop_lock_acquire_failure_stat, RecRawStatSyncSum);
-
-  RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.dynamic_keep_alive_timeout_in_total",
RECD_INT, RECP_NON_PERSISTENT,
-                     (int)keep_alive_queue_timeout_total_stat, RecRawStatSyncSum);
   NET_CLEAR_DYN_STAT(keep_alive_queue_timeout_total_stat);
-
-  RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.dynamic_keep_alive_timeout_in_count",
RECD_INT, RECP_NON_PERSISTENT,
-                     (int)keep_alive_queue_timeout_count_stat, RecRawStatSyncSum);
   NET_CLEAR_DYN_STAT(keep_alive_queue_timeout_count_stat);
-
-  RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.default_inactivity_timeout_applied",
RECD_INT, RECP_NON_PERSISTENT,
-                     (int)default_inactivity_timeout_stat, RecRawStatSyncSum);
   NET_CLEAR_DYN_STAT(default_inactivity_timeout_stat);
 }
 

-- 
To stop receiving notification emails like this one, please contact
"commits@trafficserver.apache.org" <commits@trafficserver.apache.org>.

Mime
View raw message