13#include <boost/enable_shared_from_this.hpp> 
   17#include <unordered_set> 
   74        for (
auto const& origin : disabled_by_origin) {
 
 
   89        for (
auto const& origin : disabled_by_origin) {
 
 
  105        for (
auto const& origin : disabled_by_origin) {
 
 
  135    void createTimer(
const unsigned int seconds, 
unsigned int origin) {
 
  143                                            shared_from_this(), origin),
 
 
  157        if (
timer_mgr_->isTimerRegistered(timer_name)) {
 
 
  167        std::ostringstream timer_name;
 
  168        timer_name << 
"network-state-timer-" << origin;
 
  169        return (timer_name.str());
 
 
  178        bool disabled_by_user = 
false;
 
  183        for (
auto const& origin : ordered) {
 
  185                disabled_by_user = 
true;
 
  198        result->set(
"disabled-by-local-command", local_origin);
 
  199        result->set(
"disabled-by-remote-command", remote_origin);
 
  200        result->set(
"disabled-by-db-connection", db_origin);
 
 
 
  231    impl_->setDisableService(
true, origin);
 
 
  237    impl_->delayedEnable(origin);
 
 
  243    impl_->resetForDbConnection();
 
 
  249    impl_->resetForLocalCommands();
 
 
  255    impl_->resetForRemoteCommands();
 
 
  261    impl_->createTimer(seconds, origin);
 
 
  267    return (!impl_->globally_disabled_);
 
 
  272    for (
auto const& origin : impl_->disabled_by_origin_) {
 
 
  302    return (impl_->toElement());
 
 
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.
static ElementPtr create(const Position &pos=ZERO_POSITION())
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
static ElementPtr createList(const Position &pos=ZERO_POSITION())
Creates an empty ListElement type ElementPtr.
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::Subnets disabled_subnets_
A list of subnets for which the DHCP service has been disabled.
virtual ElementPtr toElement() const
The network state as Element.
void resetForRemoteCommands()
Reset origin for remote commands.
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.
NetworkStateImpl()
Constructor.
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.
void resetForLocalCommands()
Reset origin for local commands.
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.
NetworkState()
Constructor.
virtual isc::data::ElementPtr toElement() const
The network state as Element.
static const unsigned int USER_COMMAND
Origin of the network state transition.
std::set< std::string > Networks
Type of the container holding collection of shared network names.
static const unsigned int HA_LOCAL_COMMAND
The network state is being altered by an HA internal command.
bool isDelayedEnableService() const
Checks if delayed enabling of DHCP services is scheduled.
static const unsigned int HA_REMOTE_COMMAND
The network state is being altered by a "dhcp-disable" or "dhcp-enable" command sent by a HA partner.
void resetForDbConnection()
Reset internal counters for database connection.
void resetForLocalCommands()
Reset origins for local commands.
void selectiveEnable(const NetworkState::Subnets &subnets)
Enable DHCP service for selected subnets.
void enableService(unsigned int origin)
Enable the DHCP service state for respective transition origin.
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.
void resetForRemoteCommands()
Reset origins for remote commands.
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< Element > ElementPtr
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.
Abstract class for configuration Cfg_* classes.
RAII lock object to protect the code in the same scope with a mutex.