Browse Source

Modified configuration variable "statistics-interval" to accept interval in seconds.

Upper limit for the value is also introduced; 86400 seconds.
Yoshitaka Aharen 14 years ago
parent
commit
2931606d7c
4 changed files with 18 additions and 9 deletions
  1. 1 1
      src/bin/auth/auth.spec.pre.in
  2. 8 3
      src/bin/auth/auth_srv.cc
  3. 5 5
      src/bin/auth/auth_srv.h
  4. 4 0
      src/bin/auth/config.cc

+ 1 - 1
src/bin/auth/auth.spec.pre.in

@@ -56,7 +56,7 @@
       { "item_name": "statistics-interval",
         "item_type": "integer",
         "item_optional": true,
-        "item_default": 60000
+        "item_default": 60
       }
     ],
     "commands": [

+ 8 - 3
src/bin/auth/auth_srv.cc

@@ -352,7 +352,7 @@ AuthSrv::setMemoryDataSrc(const isc::dns::RRClass& rrclass,
 
 uint32_t
 AuthSrv::getStatisticsTimerInterval() const {
-    return (impl_->statistics_timer_.getInterval());
+    return (impl_->statistics_timer_.getInterval() / 1000);
 }
 
 void
@@ -360,19 +360,24 @@ AuthSrv::setStatisticsTimerInterval(uint32_t interval) {
     if (interval == impl_->statistics_timer_.getInterval()) {
         return;
     }
+    if (interval > 86400) {
+        // It can't be occur since the value is checked in
+        // statisticsIntervalConfig::build().
+        isc_throw(InvalidParameter, "Too long interval: " << interval);
+    }
     if (interval == 0) {
         impl_->statistics_timer_.cancel();
     } else {
         impl_->statistics_timer_.setup(boost::bind(&AuthSrv::submitStatistics,
                                                    this),
-                                       interval);
+                                       interval * 1000);
     }
     if (impl_->verbose_mode_) {
         if (interval == 0) {
             cerr << "[b10-auth] Disabled statistics timer" << endl;
         } else {
             cerr << "[b10-auth] Set statistics timer to " << interval
-                 << " milliseconds" << endl;
+                 << " seconds" << endl;
         }
     }
 }

+ 5 - 5
src/bin/auth/auth_srv.h

@@ -308,8 +308,7 @@ public:
     /// is shutdown.
     void setStatisticsSession(isc::cc::AbstractSession* statistics_session);
 
-    /// Return the interval of periodic submission of statistics in
-    /// milliseconds.
+    /// Return the interval of periodic submission of statistics in seconds.
     ///
     /// If the statistics submission is disabled, it returns 0.
     ///
@@ -319,15 +318,16 @@ public:
     /// Set the interval of periodic submission of statistics.
     ///
     /// If the specified value is non 0, the \c AuthSrv object will submit
-    /// its statistics to the statistics module every \c interval milliseconds.
+    /// its statistics to the statistics module every \c interval seconds.
     /// If it's 0, and \c AuthSrv currently submits statistics, the submission
-    /// will be disabled.
+    /// will be disabled. \c interval must be equal to or shorter than 86400
+    /// seconds (1 day).
     ///
     /// This method should normally not throw an exception; however, its
     /// underlying library routines may involve resource allocation, and
     /// when it fails it would result in a corresponding standard exception.
     ///
-    /// \param interval The submission interval in milliseconds if non 0;
+    /// \param interval The submission interval in seconds if non 0;
     /// or a value of 0 to disable the submission.
     void setStatisticsTimerInterval(uint32_t interval);
 

+ 4 - 0
src/bin/auth/config.cc

@@ -182,6 +182,10 @@ public:
             isc_throw(AuthConfigError, "negative statistics-interval value: "
                       << config_interval);
         }
+        if (config_interval > 86400) {
+            isc_throw(AuthConfigError, "too long statistics-interval value: "
+                      << config_interval);
+        }
         interval_ = config_interval;
     }
     virtual void commit() {