You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by sh...@apache.org on 2015/07/10 14:12:19 UTC
trafficserver git commit: TS-3435 Make Log.cc:PERIODIC_TASKS_INTERVAL
configurable. This closes #243.
Repository: trafficserver
Updated Branches:
refs/heads/master 1a5624162 -> ed1eb0305
TS-3435 Make Log.cc:PERIODIC_TASKS_INTERVAL configurable. This closes #243.
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/ed1eb030
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/ed1eb030
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/ed1eb030
Branch: refs/heads/master
Commit: ed1eb03053e05a1d247ba94d09ab77559f58624a
Parents: 1a56241
Author: Daniel Xu <da...@yahoo-inc.com>
Authored: Tue Jul 7 06:13:31 2015 -0700
Committer: shinrich <sh...@yahoo-inc.com>
Committed: Fri Jul 10 07:11:40 2015 -0500
----------------------------------------------------------------------
mgmt/RecordsConfig.cc | 4 +++-
proxy/config/records.config.default.in | 1 +
proxy/logging/Log.cc | 34 +++++++++++++++++++++++++++--
proxy/logging/Log.h | 2 ++
4 files changed, 38 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ed1eb030/mgmt/RecordsConfig.cc
----------------------------------------------------------------------
diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc
index c967acd..4d847b0 100644
--- a/mgmt/RecordsConfig.cc
+++ b/mgmt/RecordsConfig.cc
@@ -1170,6 +1170,9 @@ static const RecordElement RecordsConfig[] =
,
{RECT_CONFIG, "proxy.config.log.max_line_size", RECD_INT, "9216", RECU_DYNAMIC, RR_NULL, RECC_NULL, NULL, RECA_NULL}
,
+ // How often periodic tasks get executed in the Log.cc infrastructure
+ {RECT_CONFIG, "proxy.config.log.periodic_tasks_interval", RECD_INT, "5", RECU_DYNAMIC, RR_NULL, RECC_NULL, "^[0-9]+$", RECA_NULL}
+ ,
//##############################################################################
//#
@@ -1998,7 +2001,6 @@ static const RecordElement RecordsConfig[] =
//#
//###########
{RECT_CONFIG, "proxy.config.cache.http.compatibility.4-2-0-fixup", RECD_INT, "1", RECU_DYNAMIC, RR_NULL, RECC_NULL, NULL, RECA_NULL}
-
};
// clang-format on
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ed1eb030/proxy/config/records.config.default.in
----------------------------------------------------------------------
diff --git a/proxy/config/records.config.default.in b/proxy/config/records.config.default.in
index f02eebd..b8837d5 100644
--- a/proxy/config/records.config.default.in
+++ b/proxy/config/records.config.default.in
@@ -146,6 +146,7 @@ CONFIG proxy.config.log.rolling_enabled INT 1
CONFIG proxy.config.log.rolling_interval_sec INT 86400
CONFIG proxy.config.log.rolling_size_mb INT 10
CONFIG proxy.config.log.auto_delete_rolled_files INT 1
+CONFIG proxy.config.log.periodic_tasks_interval INT 5
##############################################################################
# These settings control remapping, and if the proxy allows (open) forward proxy or not. Docs:
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ed1eb030/proxy/logging/Log.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/Log.cc b/proxy/logging/Log.cc
index 23a6c84..fa66fba 100644
--- a/proxy/logging/Log.cc
+++ b/proxy/logging/Log.cc
@@ -57,7 +57,7 @@
#include "ink_apidefs.h"
-#define PERIODIC_TASKS_INTERVAL 5 // TODO: Maybe this should be done as a config option
+#define PERIODIC_TASKS_INTERVAL_FALLBACK 5
// Log global objects
inkcoreapi LogObject *Log::error_log = NULL;
@@ -82,6 +82,7 @@ int Log::collation_port;
int Log::init_status = 0;
int Log::config_flags = 0;
bool Log::logging_mode_changed = false;
+uint32_t Log::periodic_tasks_interval = PERIODIC_TASKS_INTERVAL_FALLBACK;
// Hash table for LogField symbols
InkHashTable *Log::field_symbol_hash = 0;
@@ -223,6 +224,7 @@ Log::periodic_tasks(long time_now)
change_configuration();
} else if (logging_mode > LOG_MODE_NONE || config->collation_mode == Log::COLLATION_HOST || config->has_api_objects()) {
Debug("log-periodic", "Performing periodic tasks");
+ Debug("log-periodic", "Periodic task interval = %d", periodic_tasks_interval);
// Check if space is ok and update the space used
//
@@ -766,6 +768,23 @@ Log::handle_logging_mode_change(const char * /* name ATS_UNUSED */, RecDataT /*
return 0;
}
+int
+Log::handle_periodic_tasks_int_change(const char * /* name ATS_UNUSED */, RecDataT /* data_type ATS_UNUSED */, RecData data,
+ void * /* cookie ATS_UNSED */)
+{
+ Debug("log-periodic", "periodic task interval changed");
+ if (data.rec_int <= 0) {
+ periodic_tasks_interval = PERIODIC_TASKS_INTERVAL_FALLBACK;
+ Error("new periodic tasks interval = %d is invalid, falling back to default = %d", (int)data.rec_int,
+ PERIODIC_TASKS_INTERVAL_FALLBACK);
+ } else {
+ periodic_tasks_interval = (uint32_t)data.rec_int;
+ Debug("log-periodic", "periodic task interval changed to %u", periodic_tasks_interval);
+ }
+ return REC_ERR_OKAY;
+}
+
+
void
Log::init(int flags)
{
@@ -809,6 +828,17 @@ Log::init(int flags)
}
}
+ // periodic task interval are set on a per instance basis
+ int pti = (int)REC_ConfigReadInteger("proxy.config.log.periodic_tasks_interval");
+ if (pti <= 0) {
+ Error("proxy.config.log.periodic_tasks_interval = %d is invalid", pti);
+ Note("falling back to default periodic tasks interval = %d", PERIODIC_TASKS_INTERVAL_FALLBACK);
+ periodic_tasks_interval = PERIODIC_TASKS_INTERVAL_FALLBACK;
+ } else
+ periodic_tasks_interval = (uint32_t)pti;
+
+ REC_RegisterConfigUpdateFunc("proxy.config.log.periodic_tasks_interval", &Log::handle_periodic_tasks_int_change, NULL);
+
// if remote management is enabled, do all necessary initialization to
// be able to handle a logging mode change
//
@@ -1202,7 +1232,7 @@ Log::flush_thread_main(void * /* args ATS_UNUSED */)
// Time to work on periodic events??
//
now = Thread::get_hrtime() / HRTIME_SECOND;
- if (now >= last_time + PERIODIC_TASKS_INTERVAL) {
+ if (now >= last_time + periodic_tasks_interval) {
Debug("log-preproc", "periodic tasks for %" PRId64, (int64_t)now);
periodic_tasks(now);
last_time = Thread::get_hrtime() / HRTIME_SECOND;
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ed1eb030/proxy/logging/Log.h
----------------------------------------------------------------------
diff --git a/proxy/logging/Log.h b/proxy/logging/Log.h
index f726d32..a2462ba 100644
--- a/proxy/logging/Log.h
+++ b/proxy/logging/Log.h
@@ -458,6 +458,7 @@ public:
// reconfiguration stuff
static void change_configuration();
static int handle_logging_mode_change(const char *name, RecDataT data_type, RecData data, void *cookie);
+ static int handle_periodic_tasks_int_change(const char *name, RecDataT data_type, RecData data, void *cookie);
Log(); // shut up stupid DEC C++ compiler
@@ -471,6 +472,7 @@ private:
static int init_status;
static int config_flags;
static bool logging_mode_changed;
+ static uint32_t periodic_tasks_interval;
// -- member functions that are not allowed --
Log(const Log &rhs);