(一)SDN 控制器 NOX 源码分析之—— nox_main.cc
2015-06-15 13:25
507 查看
nox_main.cc
Application_list parse_application_list(int optind, int argc, char** argv)
从NOX启动命令行中获得启动程序的名字以及所带参数,返回(程序名,参数)的列表
void hello(const char* program_name)
打印NOX版本信息以及编译事件
void usage(const char* program_name)
打印NOX的使用方法
int daemon()
使程序成为守护进程
static void finish_booting(Kernel*, const Application_list&)
将需要加载的应用程序模块加载到kernel中完成NOX最终引导
void shutdown(int param)
由信号param引起的关闭NOX
Kernel::init(info_file, argc, argv)
启动NOX内核,info_file记录了NOX控制器启动的次数,以及控制器的UUID(universally unique identifier of this NOX instance)
Kernel::get_instance()
启动取得NOX 的Kernel实例,这个实例全局只有一个
kernel->set_argument(app.first, app.second);
向NOX的kernel传递模块名以及模块的参数
Component_context* event_dispatcher_context =
new Static_component_context(
boost::bind(&Event_dispatcher::instantiate, _1, n_threads),
typeid(Event_dispatcher).name(),
"event-dispatcher",
platform_config_path);
添加事件分发器
Static_component_context为静态组件上下文环境类,继承自组件上下文环境类,构造函数的参数为:
1、输入组件上下文获得对应组件实例的方法;
2、组件的类名;
3、组件模块名;
4、模块配置文件路径
kernel->install(event_dispatcher_context, INSTALLED);
给内核加载组件,参数为组件上下文对象和要达到的加载状态
Component_context* dso_deployer_context =
new Static_component_context(
boost::bind(&DSO_deployer::instantiate, _1, lib_dirs),
typeid(DSO_deployer).name(),
"dso-deployer",
platform_config_path);
kernel->install(dso_deployer_context, INSTALLED);
添加动态组件部署器
Component_context* connection_manager_context =
new Static_component_context(
boost::bind(&Connection_manager::instantiate, _1, interfaces),
typeid(Connection_manager).name(),
"connection-manager",
platform_config_path);
kernel->install(connection_manager_context, INSTALLED);
添加连接管理器,管理网络连接
static void finish_booting(Kernel* kernel, const Application_list& applications)
将已经设置到内核中的应用组件启动
Event_dispatcher* ed =
dynamic_cast<Event_dispatcher*>(event_dispatcher_context->get_instance());
取得事件分发器的实例。每一个上下文类都有一个get_instance()的方法用来得到相应的实例对象
post_shutdown = boost::bind(&Event_dispatcher::post, ed, shutdown_event);
bind的一种用法,用来将类方法导出为一个外部方法,bind(&类名::方法名,此类的对象指针,参数)
ed->register_handler(Shutdown_event::static_get_name(),
boost::bind(&remove_pid_file, pid_file, _1),
9998);
为事件分发器注册句柄,参数为(事件名,处理方法,同事件发生时的调用次序(或优先级))
ed->join_all();
事件分发器的方法,用途为: Join the threads until the end of execution
(转载请注明出处:/article/8588335.html)
Application_list parse_application_list(int optind, int argc, char** argv)
从NOX启动命令行中获得启动程序的名字以及所带参数,返回(程序名,参数)的列表
void hello(const char* program_name)
打印NOX版本信息以及编译事件
void usage(const char* program_name)
打印NOX的使用方法
int daemon()
使程序成为守护进程
static void finish_booting(Kernel*, const Application_list&)
将需要加载的应用程序模块加载到kernel中完成NOX最终引导
void shutdown(int param)
由信号param引起的关闭NOX
Kernel::init(info_file, argc, argv)
启动NOX内核,info_file记录了NOX控制器启动的次数,以及控制器的UUID(universally unique identifier of this NOX instance)
Kernel::get_instance()
启动取得NOX 的Kernel实例,这个实例全局只有一个
kernel->set_argument(app.first, app.second);
向NOX的kernel传递模块名以及模块的参数
Component_context* event_dispatcher_context =
new Static_component_context(
boost::bind(&Event_dispatcher::instantiate, _1, n_threads),
typeid(Event_dispatcher).name(),
"event-dispatcher",
platform_config_path);
添加事件分发器
Static_component_context为静态组件上下文环境类,继承自组件上下文环境类,构造函数的参数为:
1、输入组件上下文获得对应组件实例的方法;
2、组件的类名;
3、组件模块名;
4、模块配置文件路径
kernel->install(event_dispatcher_context, INSTALLED);
给内核加载组件,参数为组件上下文对象和要达到的加载状态
Component_context* dso_deployer_context =
new Static_component_context(
boost::bind(&DSO_deployer::instantiate, _1, lib_dirs),
typeid(DSO_deployer).name(),
"dso-deployer",
platform_config_path);
kernel->install(dso_deployer_context, INSTALLED);
添加动态组件部署器
Component_context* connection_manager_context =
new Static_component_context(
boost::bind(&Connection_manager::instantiate, _1, interfaces),
typeid(Connection_manager).name(),
"connection-manager",
platform_config_path);
kernel->install(connection_manager_context, INSTALLED);
添加连接管理器,管理网络连接
static void finish_booting(Kernel* kernel, const Application_list& applications)
将已经设置到内核中的应用组件启动
Event_dispatcher* ed =
dynamic_cast<Event_dispatcher*>(event_dispatcher_context->get_instance());
取得事件分发器的实例。每一个上下文类都有一个get_instance()的方法用来得到相应的实例对象
post_shutdown = boost::bind(&Event_dispatcher::post, ed, shutdown_event);
bind的一种用法,用来将类方法导出为一个外部方法,bind(&类名::方法名,此类的对象指针,参数)
ed->register_handler(Shutdown_event::static_get_name(),
boost::bind(&remove_pid_file, pid_file, _1),
9998);
为事件分发器注册句柄,参数为(事件名,处理方法,同事件发生时的调用次序(或优先级))
ed->join_all();
事件分发器的方法,用途为: Join the threads until the end of execution
(转载请注明出处:/article/8588335.html)
相关文章推荐
- Rails学习总结(1)
- 人工智能独立攻克生物领域120年的未解之谜
- Servlet--ServletException类,UnavailableException类
- Servlet--ServletException类,UnavailableException类
- Leetcode_220 Contains Duplicate III
- xhzengAIB/MessageDisplayKit
- 从浏览器中检测、安装、启动Air程序
- 硬件raid和软件raid说明、设置及维护
- Sublime Test 解决 报please wait a bit while pyV8 binary 错误
- 人工智能论坛
- 人工智能论坛
- Capistrano 3 实现Rails 自动化部署
- 再谈应用环境下的TIME_WAIT和CLOSE_WAIT
- 发现大量的TIME_WAIT解决办法
- DELET语句与REFERENCE约束“FK_news_category”冲突,该冲突发生于数据库“newssystem”,表dbo.news,column 'caId'语句终止
- LeetCode70:Climbing Stairs
- 记录一篇人工智能的内容!
- Daily mood12
- HDU Repair the Wall (贪心)
- HDOJ 1022 Train Problem I