OpenSDN source code
config_stale_cleaner.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 Juniper Networks, Inc. All rights reserved.
3  * Copyright Contributors to the OpenSDN project
4  */
5 
6 #include <cfg/cfg_init.h>
7 #include <cfg/cfg_types.h>
8 #include <port_ipc/port_ipc_types.h>
9 #include "config_stale_cleaner.h"
10 #include "port_ipc_handler.h"
11 #include "port_subscribe_table.h"
12 
14  agent_(agent),
15  timeout_(kConfigStaleTimeout), audit_callback_(callback) {
16 }
17 
19  // clean up the running timers
20  for (std::set<Timer *>::iterator it = running_timer_list_.begin();
21  it != running_timer_list_.end(); ++it) {
23  }
24 }
25 
27  // create timer, to be deleted on completion
28  Timer *timer =
30  *(agent_->event_manager())->io_service(), "Stale cleanup timer",
31  TaskScheduler::GetInstance()->GetTaskId("db::DBTable"), 0, true);
32  running_timer_list_.insert(timer);
33  timer->Start(timeout_,
34  boost::bind(&ConfigStaleCleaner::StaleEntryTimeout, this,
35  version, timer));
36 }
37 
39  if (!audit_callback_.empty()) {
41  }
42  running_timer_list_.erase(timer);
43  return false;
44 }
45 
47 
49  ConfigStaleCleaner(agent, NULL) {
50 }
51 
53 }
54 
55 bool
57  PortSubscribeTable *table =
59  if (!table) {
60  return false;
61  }
62 
63  CONFIG_TRACE(PortInfo, "InterfaceConfigStaleCleaner Walk invoked.");
64  table->StaleWalk(version);
65  return false;
66 }
#define CONFIG_TRACE(obj,...)
Definition: cfg_init.h:237
Definition: agent.h:361
PortIpcHandler * port_ipc_handler() const
Definition: agent.cc:1009
EventManager * event_manager() const
Definition: agent.h:1106
boost::function< void(uint32_t)> TimerCallback
std::set< Timer * > running_timer_list_
virtual bool StaleEntryTimeout(int32_t version, Timer *timer)
TimerCallback audit_callback_
ConfigStaleCleaner(Agent *agent, TimerCallback callback)
virtual void StartStaleCleanTimer(int32_t version)
virtual bool OnInterfaceConfigStaleTimeout(int32_t version)
PortSubscribeTable * port_subscribe_table() const
void StaleWalk(uint64_t version)
int GetTaskId(const std::string &name)
Definition: task.cc:884
static TaskScheduler * GetInstance()
Definition: task.cc:574
static bool DeleteTimer(Timer *Timer)
Definition: timer.cc:222
static Timer * CreateTimer(boost::asio::io_context &service, const std::string &name, int task_id=Timer::GetTimerTaskId(), int task_instance=Timer::GetTimerInstanceId(), bool delete_on_completion=false)
Definition: timer.cc:201
Definition: timer.h:58
bool Start(int time, Handler handler, ErrorHandler error_handler=NULL)
Definition: timer.cc:108