33 agent_(new
Agent()), agent_param_(NULL), trigger_(),
34 enable_controller_(true) {
44 agent_->db()->ClearFactoryRegistry();
52 (
const std::string &config_file,
const std::string &
program_name) {
53 agent_param_->Init(config_file, program_name);
57 return Module::VROUTER_AGENT;
62 return g_vns_constants.ModuleNames.find(module)->second;
70 return g_vns_constants.INSTANCE_ID_DEFAULT;
74 boost::system::error_code ec;
75 Ip4Address ip = Ip4Address::from_string(
"127.0.0.1", ec);
76 if (ec.value() != 0) {
81 agent_->set_vrouter_server_ip(ip);
83 agent_->set_pkt_interface_name(
"pkt0");
85 agent_->set_vrouter_server_ip(ip);
87 agent_->set_pkt_interface_name(
"unix");
95 agent_->set_agent_init(
this);
107 agent_->set_module_name(module_name);
108 std::vector<std::string> v_slo_destinations =
agent_param_->
109 get_slo_destination();
111 if (log_property_file.size()) {
166 agent_->SetResourceManagerReady();
177 agent_->set_init_done(
true);
250 oper_->RegisterDBClients();
296 vrf_table->CreateStaticVrf(
agent_->fabric_vrf_name());
297 vrf_table->CreateFabricPolicyVrf(
agent_->fabric_policy_vrf_name());
298 VrfEntry *vrf = vrf_table->FindVrfFromName(
agent_->fabric_vrf_name());
301 fabric_policy_vrf_name());
304 agent_->set_fabric_vrf(vrf);
305 agent_->set_fabric_policy_vrf(policy_vrf);
308 agent_->set_fabric_inet4_multicast_table
325 if (
agent_->router_id_configured() ==
false) {
327 "Router ID not configured. Connection to controller postponed");
329 LOG(DEBUG,
"Router ID configured. Connection to controller initiated");
331 agent_->controller()->Connect();
335 if (
agent_->controller()) {
336 agent_->controller()->EnableWorkQueue();
356 uint32_t execute_delay = (20 * 1000);
357 uint32_t schedule_delay = (20 * 1000);
365 (schedule_delay * 2));
367 (schedule_delay * 2));
369 (schedule_delay * 2));
387 agent_->controller()->Cleanup();
388 agent_->controller()->DisConnect();
420 agent_->oper_db()->DeleteRoutes();
436 boost::uuids::nil_uuid(),
437 agent_->vhost_interface_name()));
439 req.
data.reset(data);
440 agent_->interface_table()->Enqueue(&req);
447 agent_->vrf_table()->DeleteStaticVrf(
agent_->fabric_policy_vrf_name());
449 agent_->vrf_table()->DeleteStaticVrf(
agent_->fabric_policy_vrf_name());
455 agent_->set_vhost_interface(NULL);
464 agent_->vrf_table()->DeleteStaticVrf(
agent_->fabric_vrf_name());
470 agent_->nexthop_table()->set_discard_nh(NULL);
484 uint32_t count,
int msec) {
485 while ((table->
Size() > count) && (msec > 0)) {
491 return (table->
Size() == count);
526 if (
agent_->oper_db() &&
agent_->oper_db()->agent_profile()) {
527 agent_->oper_db()->agent_profile()->Shutdown();
539 agent_->oper_db()->Shutdown();
543 agent_->cfg()->Shutdown();
617 agent_->event_manager()->Shutdown();
virtual void ProcessOptions(const std::string &config_file, const std::string &program_name)
virtual std::string InstanceId()
log4cplus::LogLevel SandeshLevelTolog4Level(SandeshLevel::type slevel)
virtual void CreateInterfaces()
static void RunInTaskContext(AgentInit *init, uint32_t task_id, TaskFnPtr fn)
const int log_files_count() const
virtual void CreateNextHops()
static bool ProfileShutdownInternal(AgentInit *init)
virtual void KSyncShutdownBase()
std::unique_ptr< EventNotifier > event_notifier_
The TaskScheduler keeps track of what tasks are currently schedulable. When a task is enqueued it is ...
AgentRouteTable * GetInet4MulticastRouteTable() const
static SandeshLevel::type StringToLevel(std::string level)
AgentRouteTable * GetEvpnRouteTable() const
virtual void InitLoggingBase()
virtual void DeleteDBEntriesBase()
const std::vector< std::string > & get_sample_destination()
std::unique_ptr< AgentConfig > cfg_
NextHopTable * nexthop_table() const
virtual void InitLogging()
Platform platform() const
#define kTaskSessionStatsCollectorEvent
virtual void CreatePeers()
string program_name(string filename)
static void SetLoggingParams(bool enable_local_log, std::string category, std::string level, bool enable_trace_print=false, bool enable_flow_log=false, bool enable_session_syslog=false)
static bool IoShutdownInternal(AgentInit *init)
std::unique_ptr< DBRequestData > data
static bool StatsCollectorShutdownInternal(AgentInit *init)
virtual void VgwShutdownBase()
virtual void CreateModules()
InetUnicastAgentRouteTable * GetInet4UnicastRouteTable() const
virtual size_t Size() const
AgentDBEntry * FindActiveEntry(const DBEntry *key)
virtual void VgwShutdown()
InetUnicastAgentRouteTable * GetInet4MplsUnicastRouteTable() const
void CreateResourceManager()
std::unique_ptr< VNController > controller_
std::unique_ptr< ResourceManager > resource_manager_
std::unique_ptr< Agent > agent_
static bool VgwShutdownInternal(AgentInit *init)
std::unique_ptr< OperDB > oper_
static bool FlushFlowsInternal(AgentInit *init)
virtual void DeleteRoutes()
std::unique_ptr< TaskTrigger > trigger_
static bool UveShutdownInternal(AgentInit *init)
static bool WaitForDbCount(DBTableBase *table, AgentInit *init, uint32_t count, int msec)
boost::function< bool(void)> TaskFnPtr
#define kTaskSessionStatsCollector
virtual void FlushFlows()
virtual void StatsCollectorShutdown()
virtual void RegisterDBClientsBase()
void set_discard_nh(NextHop *nh)
virtual void WaitForIdle()=0
static bool DeleteRoutesInternal(AgentInit *init)
void EnableLatencyThresholds(uint32_t execute, uint32_t schedule)
Enable logging of tasks exceeding configured latency.
virtual void RegisterDBClients()
#define AGENT_SHUTDOWN_TASKNAME
virtual void FlowStatsCollectorShutdownBase()
#define VROUTER_SERVER_PORT
virtual void InitDoneBase()
virtual void CreatePeersBase()
static const uint32_t kRpfDiscardIndex
virtual void DeleteRoutesBase()
std::unique_ptr< AgentStats > stats_
static TaskScheduler * GetInstance()
virtual void IoShutdown()
void set_l2_receive_nh(NextHop *nh)
std::unique_ptr< DBRequestKey > key
virtual void CreateVrfBase()
static bool PktShutdownInternal(AgentInit *init)
virtual std::string ModuleName()
AgentRouteTable * GetBridgeRouteTable() const
static bool ServicesShutdownInternal(AgentInit *init)
virtual void InitCollectorBase()
virtual void CreateModulesBase()
virtual void CreateDBTables()
virtual void UveShutdown()
boost::asio::ip::address_v4 Ip4Address
#define kTaskFlowStatsCollector
virtual void PktShutdownBase()
uint32_t tbb_exec_delay() const
void set_stats(AgentStats *stats)
const std::string log_file() const
void set_event_notifier(EventNotifier *mgr)
virtual void FlushFlowsBase()
virtual void PktShutdown()
virtual void FlowStatsCollectorShutdown()
static bool FlowStatsCollectorShutdownInternal(AgentInit *init)
virtual std::string AgentName()
uint32_t tbb_schedule_delay() const
virtual void ConnectToController()
virtual void CreateNextHopsBase()
virtual void ServicesShutdown()
virtual void InitCollector()
virtual void CreateInterfacesBase()
static bool ModulesShutdownInternal(AgentInit *init)
virtual void CreateDBTablesBase()
virtual void ModulesShutdownBase()
#define LOG(_Level, _Msg)
virtual void ProfileShutdownBase()
virtual void KSyncShutdown()
AgentParam * agent_param_
const std::vector< std::string > & get_slo_destination()
virtual void ConnectToControllerBase()
static void set_logger_appender(const std::string &file_name, long max_file_size, int max_backup_index, const std::string &syslog_facility, const std::vector< std::string > &destn, const std::string &ident, bool is_sampled_logger)
virtual void FactoryInit()=0
const std::string & log_level() const
virtual void ModulesShutdown()
const std::string & log_category() const
static bool KSyncShutdownInternal(AgentInit *init)
void SetLatencyThreshold(const std::string &name, uint32_t execute, uint32_t schedule)
virtual void ServicesShutdownBase()
virtual void UveShutdownBase()
const std::string syslog_facility() const
void SetResourceManagerReady()
const std::string & log_property_file() const
const long log_file_size() const
virtual void InitModulesBase()
void PostValidateLogConfig() const
static bool FlushTable(AgentDBTable *table)
const std::string & agent_name() const
virtual void StatsCollectorShutdownBase()
#define AGENT_INIT_TASKNAME
VirtualGatewayConfigTable * vgw_config_table() const
static void set_send_to_collector_flags(const std::vector< std::string > &sampled_destination, const std::vector< std::string > &slo_destination)
static void CreateVrfIndependentNextHop(Agent *agent)
void InitDone(Agent *agent)
virtual void InitModules()