13#include <boost/enable_shared_from_this.hpp>
17#include <unordered_set>
110 void createTimer(
const unsigned int seconds,
unsigned int origin) {
118 shared_from_this(), origin),
132 if (
timer_mgr_->isTimerRegistered(timer_name)) {
142 std::ostringstream timer_name;
143 timer_name <<
"network-state-timer-" << origin;
144 return (timer_name.str());
180 impl_->setDisableService(
true, origin);
186 impl_->delayedEnable(origin);
192 impl_->resetForDbConnection();
198 impl_->createTimer(seconds, origin);
204 return (!impl_->globally_disabled_);
209 for (
auto origin : impl_->disabled_by_origin_) {
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
A generic exception that is thrown when a function is not implemented.
Implementation of the NetworkState class.
void resetForDbConnection()
Reset internal counters for a database connection origin.
std::string getTimerName(unsigned int origin) const
Creates a unique timer name from the origin.
void setDisableService(const bool disable, unsigned int origin)
Sets appropriate disabled or enabled DHCP service state for the respective origin.
NetworkState::ServerType server_type_
Server type.
NetworkState::Subnets disabled_subnets_
A list of subnets for which the DHCP service has been disabled.
NetworkStateImpl(const NetworkState::ServerType &server_type)
Constructor.
bool globally_disabled_
A flag indicating if DHCP service is globally disabled.
TimerMgrPtr timer_mgr_
A pointer to the common timer manager.
void delayedEnable(unsigned int origin)
Enables DHCP service for an origin.
uint32_t disabled_by_db_connection_
Flag which indicates the state has been disabled by a DB connection loss.
std::unordered_set< unsigned int > disabled_by_origin_
A set of requests to disable the service by origin.
NetworkState::Networks disabled_networks_
A list of networks for which the DHCP service has been disabled.
void createTimer(const unsigned int seconds, unsigned int origin)
Creates a timer counting the time when delayedEnable should be automatically called.
~NetworkStateImpl()
Destructor.
void destroyTimer(unsigned int origin)
Destroys a timer if present.
static const unsigned int DB_CONNECTION
The network state is being altered by the DB connection recovery mechanics.
void selectiveDisable(const NetworkState::Subnets &subnets)
Disable DHCP service for selected subnets.
std::set< SubnetID > Subnets
Type of the container holding collection of subnet identifiers.
std::set< std::string > Networks
Type of the container holding collection of shared network names.
bool isDelayedEnableService() const
Checks if delayed enabling of DHCP services is scheduled.
void resetForDbConnection()
Reset internal counters for database connection.
void selectiveEnable(const NetworkState::Subnets &subnets)
Enable DHCP service for selected subnets.
NetworkState(const ServerType &server_type)
Constructor.
void enableService(unsigned int origin)
Enable the DHCP service state for respective transition origin.
ServerType
DHCP server type.
void disableService(unsigned int origin)
Disable the DHCP service state for respective transition origin.
bool isServiceEnabled() const
Checks if the DHCP service is globally enabled.
void delayedEnableService(const unsigned int seconds, unsigned int origin)
Schedules enabling DHCP service in the future.
Manages a pool of asynchronous interval timers.
static const TimerMgrPtr & instance()
Returns pointer to the sole instance of the TimerMgr.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< TimerMgr > TimerMgrPtr
Type definition of the shared pointer to TimerMgr.
Defines the logger used by the top-level component of kea-lfc.
RAII lock object to protect the code in the same scope with a mutex.