Line data Source code
1 : /* 2 : * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. 3 : * Copyright Contributors to the OpenSDN project 4 : */ 5 : 6 : #ifndef ctrlplane__ctrl_node_h 7 : 8 : #define ctrlplane__ctrl_node_h 9 : 10 : #include <malloc.h> 11 : #include <string> 12 : #include "base/sandesh/process_info_types.h" 13 : #include "io/event_manager.h" 14 : #include "sandesh/sandesh_trace.h" 15 : 16 : class BgpServer; 17 : class BgpXmppChannelManager; 18 : class IFMapServer; 19 : class TaskTrigger; 20 : 21 : #define CONTROL_NODE_EXIT(message) \ 22 : do { \ 23 : LOG(ERROR, "Control-Node Terminated: " message); \ 24 : ControlNode::Exit(false); \ 25 : } while (false) 26 : 27 : class ControlNode { 28 : public: 29 : static void SetDefaultSchedulingPolicy(); 30 : static void SetHostname(const std::string name) { hostname_ = name; } 31 : static const std::string GetHostname() { return hostname_; } 32 : static const std::string &GetProgramName() { return prog_name_; } 33 : static void SetProgramName(const char *name) { prog_name_ = name; } 34 177 : static std::string GetSelfIp() { return self_ip_; } 35 : static void SetSelfIp(std::string ip) { self_ip_ = ip; } 36 : static void SetTestMode(const bool flag) { test_mode_ = flag; } 37 : static bool GetTestMode() { return test_mode_; } 38 : static void StartControlNodeInfoLogger( 39 : EventManager &evm, uint64_t period_msecs, const BgpServer *server, 40 : const BgpXmppChannelManager *xmpp_channel_mgr, 41 : const IFMapServer *ifmap_server, const string &build_info); 42 : static void Shutdown(); 43 : static void Exit(bool do_assert); 44 : static std::string GetProcessState(bool bgpHasSelfConfiguration, 45 : bool bgpIsAdminDown, bool configEndOfRibComputed, 46 : process::ProcessState::type *state, std::string *message); 47 : 48 : private: 49 : static bool ControlNodeInfoLogger(const BgpServer *server, 50 : const BgpXmppChannelManager *xmpp_channel_mgr, 51 : const IFMapServer *ifmap_server, const std::string &build_info); 52 : static bool ControlNodeInfoLogTimer(TaskTrigger *node_info_trigger); 53 : 54 : static std::string hostname_; 55 : static std::string prog_name_; 56 : static std::string self_ip_; 57 : static bool test_mode_; 58 : 59 : }; 60 : 61 : void ControlNodeShutdown(); 62 : 63 : #endif // ctrlplane__ctrl_node_h