[svn] commit: r3418 - in /experiments/kambe-auth-stats/src/bin/auth: asio_link.cc auth.spec.pre.in auth_srv.cc auth_srv.h main.cc
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Nov 2 12:56:36 UTC 2010
Author: naokikambe
Date: Tue Nov 2 12:56:36 2010
New Revision: 3418
Log:
- get timeout seconds from spec file
- add updating of timeout seconds via cfgmgr
- add command "send_immediately" to stats module in spec file
Modified:
experiments/kambe-auth-stats/src/bin/auth/asio_link.cc
experiments/kambe-auth-stats/src/bin/auth/auth.spec.pre.in
experiments/kambe-auth-stats/src/bin/auth/auth_srv.cc
experiments/kambe-auth-stats/src/bin/auth/auth_srv.h
experiments/kambe-auth-stats/src/bin/auth/main.cc
Modified: experiments/kambe-auth-stats/src/bin/auth/asio_link.cc
==============================================================================
--- experiments/kambe-auth-stats/src/bin/auth/asio_link.cc (original)
+++ experiments/kambe-auth-stats/src/bin/auth/asio_link.cc Tue Nov 2 12:56:36 2010
@@ -561,9 +561,6 @@
// This member is used only for testing at the moment.
IOService::IOCallBack callback_;
- // timeout seconds
- static const size_t DEFAULT_TIMEOUT = 3;
-
// async_wait handler
void AsWaitHandler(const asio::error_code& error);
};
@@ -607,7 +604,8 @@
}
// start deadline_timer
dltimer_.reset(new asio::deadline_timer(io_service_));
- dltimer_->expires_from_now(boost::posix_time::seconds(DEFAULT_TIMEOUT));
+ dltimer_->expires_from_now(boost::posix_time::seconds(
+ auth_server_->getTimeoutSec()));
dltimer_->async_wait(boost::bind(&IOServiceImpl::AsWaitHandler,
this, asio::placeholders::error));
} catch (const asio::system_error& err) {
@@ -623,14 +621,16 @@
IOServiceImpl::AsWaitHandler(const asio::error_code& error)
{
if (error == asio::error::operation_aborted) {
- isc_throw(IOError, "wait_handler: Error: " << error.message());
+ isc_throw(IOError, "AsWaitHandler: Error: " << error.message());
return;
}
if (!auth_server_->sendtoStats()) {
isc_throw(IOError, "Failed to send statistics data");
}
+ dltimer_->cancel();
dltimer_->expires_at(dltimer_->expires_at()
- + boost::posix_time::seconds(DEFAULT_TIMEOUT));
+ + boost::posix_time::seconds(
+ auth_server_->getTimeoutSec()));
dltimer_->async_wait(boost::bind(&IOServiceImpl::AsWaitHandler,
this, asio::placeholders::error));
}
Modified: experiments/kambe-auth-stats/src/bin/auth/auth.spec.pre.in
==============================================================================
--- experiments/kambe-auth-stats/src/bin/auth/auth.spec.pre.in (original)
+++ experiments/kambe-auth-stats/src/bin/auth/auth.spec.pre.in Tue Nov 2 12:56:36 2010
@@ -7,6 +7,11 @@
"item_type": "string",
"item_optional": true,
"item_default": "@@LOCALSTATEDIR@@/@PACKAGE@/zone.sqlite3"
+ },
+ { "item_name": "stats_timeout_sec",
+ "item_type": "integer",
+ "item_optional": true,
+ "item_default": 180
}
],
"commands": [
@@ -14,6 +19,11 @@
"command_name": "shutdown",
"command_description": "Shut down authoritative DNS server",
"command_args": []
+ },
+ {
+ "command_name": "send_immediately",
+ "command_description": "send statistics data to stats module immediately",
+ "command_args": []
}
]
}
Modified: experiments/kambe-auth-stats/src/bin/auth/auth_srv.cc
==============================================================================
--- experiments/kambe-auth-stats/src/bin/auth/auth_srv.cc (original)
+++ experiments/kambe-auth-stats/src/bin/auth/auth_srv.cc Tue Nov 2 12:56:36 2010
@@ -50,6 +50,7 @@
#include <auth/common.h>
#include <auth/auth_srv.h>
#include <auth/asio_link.h>
+#include <boost/lexical_cast.hpp>
using namespace std;
@@ -107,10 +108,14 @@
// send statistics data to stats daemon
bool sendtoStats() const;
+ // timeout seconds
+ size_t timeout_sec_;
private:
- /// the query counters, just incremental
- unsigned long int udp_q_count_;
- unsigned long int tcp_q_count_;
+ // the query counters, just incremental
+ unsigned long long int udp_q_count_;
+ unsigned long long int tcp_q_count_;
+ // default timeout seconds
+ static const size_t DEFAULT_TIMEOUT_SEC_ = 180;
};
AuthSrvImpl::AuthSrvImpl(const bool use_cache,
@@ -119,7 +124,8 @@
xfrin_session_(NULL),
xfrout_connected_(false),
xfrout_client_(xfrout_client),
- udp_q_count_(0), tcp_q_count_(0)
+ timeout_sec_(DEFAULT_TIMEOUT_SEC_),
+ udp_q_count_(0x0LL), tcp_q_count_(0x0LL)
{
// cur_datasrc_ is automatically initialized by the default constructor,
// effectively being an empty (sqlite) data source. once ccsession is up
@@ -503,6 +509,22 @@
AuthSrvImpl::setDbFile(ConstElementPtr config) {
ConstElementPtr answer = isc::config::createAnswer();
+ // get send timeout secs from spec file
+ if (config && config->contains("stats_timeout_sec")) {
+ const size_t new_timeout_sec_ = config->get("stats_timeout_sec")->intValue();
+ if ( new_timeout_sec_ != timeout_sec_) {
+ if (verbose_mode_) {
+ cerr << "[b10-auth] stats sending timeout changed from " << timeout_sec_
+ << " into " << new_timeout_sec_ << endl;
+ }
+ timeout_sec_ = new_timeout_sec_;
+ }
+ } else if (config_session_ != NULL) {
+ bool is_default;
+ string item("stats_timeout_sec");
+ timeout_sec_ = config_session_->getValue(is_default, item)->intValue();
+ }
+
if (config && config->contains("database_file")) {
db_file_ = config->get("database_file")->stringValue();
} else if (config_session_ != NULL) {
@@ -609,10 +631,8 @@
static const string command_udp = "\"auth.queries.udp\"";
static const string command_tcp = "\"auth.queries.tcp\"";
static const string command_foot = "} } ] }";
- char udp_q_count_str_[256] = "";
- char tcp_q_count_str_[256] = "";
- sprintf(udp_q_count_str_, "%ld", udp_q_count_);
- sprintf(tcp_q_count_str_, "%ld", tcp_q_count_);
+ string udp_q_count_str_ = boost::lexical_cast<string>(udp_q_count_);
+ string tcp_q_count_str_ = boost::lexical_cast<string>(tcp_q_count_);
string command_str = command_head
+ command_udp + ":" + udp_q_count_str_ + ","
@@ -639,6 +659,12 @@
}
return (false);
}
+ } catch (const SessionTimeout& st) {
+ if (verbose_mode_) {
+ cerr << "[b10-auth] failed to send statistics: caught SessionTimeout: "
+ << st.what() << endl;
+ }
+ return (false);
} catch (const Exception& ex) {
if (verbose_mode_) {
cerr << "[b10-auth] failed to send statistics: "
@@ -654,3 +680,9 @@
{
return (impl_->sendtoStats());
}
+
+size_t
+AuthSrv::getTimeoutSec() const
+{
+ return (impl_->timeout_sec_);
+}
Modified: experiments/kambe-auth-stats/src/bin/auth/auth_srv.h
==============================================================================
--- experiments/kambe-auth-stats/src/bin/auth/auth_srv.h (original)
+++ experiments/kambe-auth-stats/src/bin/auth/auth_srv.h Tue Nov 2 12:56:36 2010
@@ -206,6 +206,9 @@
// send statistics data to stats daemon
bool sendtoStats() const;
+ // get timeout seconds
+ size_t getTimeoutSec() const;
+
private:
AuthSrvImpl* impl_;
};
Modified: experiments/kambe-auth-stats/src/bin/auth/main.cc
==============================================================================
--- experiments/kambe-auth-stats/src/bin/auth/main.cc (original)
+++ experiments/kambe-auth-stats/src/bin/auth/main.cc Tue Nov 2 12:56:36 2010
@@ -81,6 +81,8 @@
answer = createAnswer(0, args);
} else if (command == "shutdown") {
io_service->stop();
+ } else if (command == "send_immediately") {
+ auth_server->sendtoStats();
}
return (answer);
More information about the bind10-changes
mailing list