You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2011/02/05 06:08:17 UTC

svn commit: r1067390 - in /trafficserver/traffic/trunk: CHANGES iocore/cache/Cache.cc mgmt/api/NetworkUtilsLocal.cc mgmt/api/TSControlMain.cc proxy/http/HttpTransact.cc

Author: zwoop
Date: Sat Feb  5 05:08:16 2011
New Revision: 1067390

URL: http://svn.apache.org/viewvc?rev=1067390&view=rev
Log:
TS-662 Make per partition stats for bytes used work

Modified:
    trafficserver/traffic/trunk/CHANGES
    trafficserver/traffic/trunk/iocore/cache/Cache.cc
    trafficserver/traffic/trunk/mgmt/api/NetworkUtilsLocal.cc
    trafficserver/traffic/trunk/mgmt/api/TSControlMain.cc
    trafficserver/traffic/trunk/proxy/http/HttpTransact.cc

Modified: trafficserver/traffic/trunk/CHANGES
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/CHANGES?rev=1067390&r1=1067389&r2=1067390&view=diff
==============================================================================
--- trafficserver/traffic/trunk/CHANGES (original)
+++ trafficserver/traffic/trunk/CHANGES Sat Feb  5 05:08:16 2011
@@ -2,6 +2,8 @@
 
 Changes with Apache Traffic Server 2.1.6
 
+  *) [TS-662] Make per partition stats for bytes_used work.
+
   *) [TS-661] Delay the copy of per transaction configs until a plugin
    actually tries to modify a setting. We also add these settings to the
    list of configurations that is overridable:

Modified: trafficserver/traffic/trunk/iocore/cache/Cache.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/iocore/cache/Cache.cc?rev=1067390&r1=1067389&r2=1067390&view=diff
==============================================================================
--- trafficserver/traffic/trunk/iocore/cache/Cache.cc (original)
+++ trafficserver/traffic/trunk/iocore/cache/Cache.cc Sat Feb  5 05:08:16 2011
@@ -149,7 +149,7 @@ static void cplist_update();
 int cplist_reconfigure();
 static int create_partition(int partition_number, int size_in_blocks, int scheme, CachePart *cp);
 static void rebuild_host_table(Cache *cache);
-void register_cache_stats(RecRawStatBlock *rsb, const char *prefix, bool reg_bytes_used=true);
+void register_cache_stats(RecRawStatBlock *rsb, const char *prefix);
 
 Queue<CachePart> cp_list;
 int cp_list_len = 0;
@@ -162,15 +162,25 @@ void force_link_CacheTestCaller() {
 #endif
 
 int64_t
-cache_bytes_used(void)
+cache_bytes_used(int partition)
 {
   uint64_t used = 0;
-  for (int i = 0; i < gnpart; i++) {
+  int start, end;
+
+  if (-1 == partition) {
+    start = 0;
+    end = gnpart;
+  } else {
+    start = partition;
+    end = partition + 1;
+  }
+  
+  for (int i = start; i < end; i++) {
     if (!DISK_BAD(gpart[i]->disk)) {
       if (!gpart[i]->header->cycle)
-        used += gpart[i]->header->write_pos - gpart[i]->start;
+          used += gpart[i]->header->write_pos - gpart[i]->start;
       else
-        used += gpart[i]->len - part_dirlen(gpart[i]) - EVACUATION_SIZE;
+          used += gpart[i]->len - part_dirlen(gpart[i]) - EVACUATION_SIZE;
     }
   }
   return used;
@@ -189,12 +199,18 @@ cache_bytes_total(void)
 int
 cache_stats_bytes_used_cb(const char *name, RecDataT data_type, RecData *data, RecRawStatBlock *rsb, int id)
 {
-  NOWARN_UNUSED(name);
+  int partition = -1;
+
   NOWARN_UNUSED(data_type);
   NOWARN_UNUSED(data);
-  if (cacheProcessor.initialized == CACHE_INITIALIZED) {
-    RecSetGlobalRawStatSum(rsb, id, cache_bytes_used());
-  }
+
+  // Well, there's no way to pass along the partition ID, so extracting it from the stat name.
+  if (0 == strncmp(name+20, "partition_", 10))
+    partition = strtol(name+30, NULL, 10);
+
+  if (cacheProcessor.initialized == CACHE_INITIALIZED)
+    RecSetGlobalRawStatSum(rsb, id, cache_bytes_used(partition));
+
   RecRawStatSyncSum(name, data_type, data, rsb, id);
 
   return 1;
@@ -2567,15 +2583,12 @@ static void reg_int(const char *str, int
 
 // Register Stats
 void
-register_cache_stats(RecRawStatBlock *rsb, const char *prefix, bool reg_bytes_used)
+register_cache_stats(RecRawStatBlock *rsb, const char *prefix)
 {
   char stat_str[256];
 
-  // TODO: At some point we should figure out how to calculate bytes_used for the per partition stats. Right now they will be zero.
-  if (reg_bytes_used) {
-    REG_INT("bytes_used", cache_bytes_used_stat);
-  }
- 
+  // Special case for this sucker, since it uses its own aggregator.
+  reg_int("bytes_used", cache_bytes_used_stat, rsb, prefix, cache_stats_bytes_used_cb);
 
   REG_INT("bytes_total", cache_bytes_total_stat);
   snprintf(stat_str, sizeof(stat_str), "%s.%s", prefix, "ram_cache.total_bytes");
@@ -2722,10 +2735,7 @@ ink_cache_init(ModuleVersion v)
   IOCORE_RegisterConfigUpdateFunc("proxy.config.cache.enable_read_while_writer", update_cache_config, NULL);
   Debug("cache_init", "proxy.config.cache.enable_read_while_writer = %d", cache_config_read_while_writer);
 
-  // Special case here for cache.bytes_used, since it uses a different CB than the "normal" SUM. This
-  // is a little ugly, but it's for one single stat, and saves an entire thread (and unecessary callbacks).
-  reg_int("bytes_used", cache_bytes_used_stat, cache_rsb, "proxy.process.cache", cache_stats_bytes_used_cb);
-  register_cache_stats(cache_rsb, "proxy.process.cache", false);
+  register_cache_stats(cache_rsb, "proxy.process.cache");
 
   const char *err = NULL;
   if ((err = theCacheStore.read_config())) {

Modified: trafficserver/traffic/trunk/mgmt/api/NetworkUtilsLocal.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/api/NetworkUtilsLocal.cc?rev=1067390&r1=1067389&r2=1067390&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/api/NetworkUtilsLocal.cc (original)
+++ trafficserver/traffic/trunk/mgmt/api/NetworkUtilsLocal.cc Sat Feb  5 05:08:16 2011
@@ -73,7 +73,6 @@ socket_flush(struct SocketInfo sock_info
 
     if (ret == 0) {
       Debug("ts_main", "[socket_read_n] returned 0 on reading: %s.\n", strerror(errno));
-      mgmt_log("[socket_flush] (TS_ERR_NET_EOF) %s\n", strerror(errno));
       return TS_ERR_NET_EOF;
     }
     // we are all good here
@@ -117,7 +116,6 @@ socket_read_n(struct SocketInfo sock_inf
 
     if (ret == 0) {
       Debug("ts_main", "[socket_read_n] returned 0 on reading: %s.\n", strerror(errno));
-      mgmt_log("[socket_read_n] (TS_ERR_NET_EOF) %s\n", strerror(errno));
       return TS_ERR_NET_EOF;
     }
     // we are all good here

Modified: trafficserver/traffic/trunk/mgmt/api/TSControlMain.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/api/TSControlMain.cc?rev=1067390&r1=1067389&r2=1067390&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/api/TSControlMain.cc (original)
+++ trafficserver/traffic/trunk/mgmt/api/TSControlMain.cc Sat Feb  5 05:08:16 2011
@@ -194,7 +194,6 @@ ts_ctrl_main(void *arg)
           new_client_con->sock_info.SSLcon = NULL;
           ink_hash_table_insert(accepted_con, (char *) &new_client_con->sock_info.fd, new_client_con);
           Debug("ts_main", "[ts_ctrl_main] Add new client connection \n");
-          //mgmt_log(stderr, "[ts_ctrl_main] Accept new connection: fd=%d\n", new_con_fd);
         }
       }                         // end if(new_con_fd >= 0 && FD_ISSET(new_con_fd, &selectFDs))
 
@@ -213,9 +212,7 @@ ts_ctrl_main(void *arg)
             ret = preprocess_msg(client_entry->sock_info, (OpType *) & op_t, &req);
             if (ret == TS_ERR_NET_READ || ret == TS_ERR_NET_EOF) {
               // occurs when remote API client terminates connection
-              Debug("ts_main", "[ts_ctrl_main] ERROR: preprocess_msg - remove client %d \n",
-                    client_entry->sock_info.fd);
-              mgmt_log("[ts_ctrl_main] preprocess_msg - remove client %d\n", client_entry->sock_info.fd);
+              Debug("ts_main", "[ts_ctrl_main] ERROR: preprocess_msg - remove client %d \n", client_entry->sock_info.fd);
               remove_client(client_entry, accepted_con);
               // get next client connection (if any)
               con_entry = ink_hash_table_iterator_next(accepted_con, &con_state);

Modified: trafficserver/traffic/trunk/proxy/http/HttpTransact.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/HttpTransact.cc?rev=1067390&r1=1067389&r2=1067390&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/HttpTransact.cc (original)
+++ trafficserver/traffic/trunk/proxy/http/HttpTransact.cc Sat Feb  5 05:08:16 2011
@@ -5044,7 +5044,6 @@ HttpTransact::get_ka_info_from_host_db(S
   bool force_http11 = false;
   bool http11_if_hostdb = false;
 
-  printf("IT IS %d\n", (int)s->txn_conf->send_http11_requests);
   switch (s->txn_conf->send_http11_requests) {
   case HttpConfigParams::SEND_HTTP11_NEVER:
     // No need to do anything since above vars