|
@@ -120,12 +120,14 @@ CfgMgr::clear() {
|
|
|
void
|
|
|
CfgMgr::commit() {
|
|
|
|
|
|
+
|
|
|
+ ensureCurrentAllocated();
|
|
|
+
|
|
|
// First we need to remove statistics. The new configuration can have fewer
|
|
|
// subnets. Also, it may change subnet-ids. So we need to remove them all
|
|
|
// and add it back.
|
|
|
- removeStatistics();
|
|
|
+ configuration_->removeStatistics();
|
|
|
|
|
|
- ensureCurrentAllocated();
|
|
|
if (!configs_.back()->sequenceEquals(*configuration_)) {
|
|
|
configuration_ = configs_.back();
|
|
|
// Keep track of the maximum size of the configs history. Before adding
|
|
@@ -138,7 +140,7 @@ CfgMgr::commit() {
|
|
|
}
|
|
|
|
|
|
// Now we need to set the statistics back.
|
|
|
- updateStatistics();
|
|
|
+ configuration_->updateStatistics();
|
|
|
}
|
|
|
|
|
|
void
|
|
@@ -198,40 +200,6 @@ CfgMgr::getStagingCfg() {
|
|
|
return (configs_.back());
|
|
|
}
|
|
|
|
|
|
-void
|
|
|
-CfgMgr::removeStatistics() {
|
|
|
- const Subnet4Collection* subnets = getCurrentCfg()->getCfgSubnets4()->getAll();
|
|
|
-
|
|
|
- // For each subnet currently configured, remove the statistic
|
|
|
- for (Subnet4Collection::const_iterator subnet = subnets->begin();
|
|
|
- subnet != subnets->end(); ++subnet) {
|
|
|
-
|
|
|
- /// @todo: Once stat contexts are implemented, we'll need to remove all
|
|
|
- /// statistics from the subnet[subnet-id] context.
|
|
|
- std::stringstream stat1;
|
|
|
- stat1 << "subnet[" << (*subnet)->getID() << "].total-addresses";
|
|
|
- StatsMgr::instance().del(stat1.str());
|
|
|
-
|
|
|
- std::stringstream stat2;
|
|
|
- stat2 << "subnet[" << (*subnet)->getID() << "].assigned-addresses";
|
|
|
- isc::stats::StatsMgr::instance().del(stat2.str());
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-void
|
|
|
-CfgMgr::updateStatistics() {
|
|
|
- const Subnet4Collection* subnets = getCurrentCfg()->getCfgSubnets4()->getAll();
|
|
|
-
|
|
|
- for (Subnet4Collection::const_iterator subnet = subnets->begin();
|
|
|
- subnet != subnets->end(); ++subnet) {
|
|
|
- std::stringstream name;
|
|
|
- name << "subnet[" << (*subnet)->getID() << "].total-addresses";
|
|
|
-
|
|
|
- StatsMgr::instance().setValue(name.str(),
|
|
|
- static_cast<int64_t>((*subnet)->getPoolCapacity(Lease::TYPE_V4)));
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
CfgMgr::CfgMgr()
|
|
|
: datadir_(DHCP_DATA_DIR), echo_v4_client_id_(true),
|
|
|
d2_client_mgr_(), verbose_mode_(false) {
|