Floodlight controller 线程池模型
来源:互联网 发布:ipv6网络设计 编辑:程序博客网 时间:2024/05/18 03:52
官方文档对于ThreadPool的描述是:ThreadPool is a Floodlight module wrapper for a Java's ScheduledExecutorService. It can be used to have threads be run at specific times or periodically. 所以只要对并发编程有点基础,就很容易理解,它实现了俩接口:1)IThreadPoolService规范的是得到ScheduledExecutorService的方法,2)IFloodlightModule则是将实现类作为模块来管理(默认启动),好处是方便其他模块很容易的指明依赖。看代码就很容易明白。
public interface IThreadPoolService extends IFloodlightService {
/**
* Get the master scheduled thread pool executor maintained by the
* ThreadPool provider. This can be used by other modules as a centralized
* way to schedule tasks.
* @return
*/
public ScheduledExecutorService getScheduledExecutor();
}
public interface IFloodlightModule {
/**
* Return the list of interfaces that this module implements.
* All interfaces must inherit IFloodlightService
* @return
*/
public Collection<Class<? extends IFloodlightService>> getModuleServices();
/**
* Instantiate (as needed) and return objects that implement each
* of the services exported by this module. The map returned maps
* the implemented service to the object. The object could be the
* same object or different objects for different exported services.
* @return The map from service interface class to service implementation
*/
public Map<Class<? extends IFloodlightService>,
IFloodlightService> getServiceImpls();
/**
* Get a list of Modules that this module depends on. The module system
* will ensure that each these dependencies is resolved before the
* subsequent calls to init().
* @return The Collection of IFloodlightServices that this module depends
* on.
*/
public Collection<Class<? extends IFloodlightService>> getModuleDependencies();
/**
* This is a hook for each module to do its <em> internal</em> initialization,
* e.g., call setService(context.getService("Service"))
*
* All module dependencies are resolved when this is called, but not every module
* is initialized.
*
* @param context
* @throws FloodlightModuleException
*/
void init(FloodlightModuleContext context) throws FloodlightModuleException;
/**
* This is a hook for each module to do its <em> external</em> initializations,
* e.g., register for callbacks or query for state in other modules
*
* It is expected that this function will not block and that modules that want
* non - event driven CPU will spawn their own threads.
*
* @param context
*/
void startUp(FloodlightModuleContext context);
}
public class ThreadPool implements IThreadPoolService, IFloodlightModule {
protected ScheduledExecutorService executor = null ;
// IThreadPoolService
@Override
public ScheduledExecutorService getScheduledExecutor() {
return executor ;
}
// IFloodlightModule
@Override
public Collection<Class<? extends IFloodlightService>> getModuleServices() {
Collection<Class<? extends IFloodlightService>> l = new ArrayList<Class<? extends IFloodlightService>>();
l.add(IThreadPoolService. class );
return l;
}
@Override
public Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls() {
Map<Class<? extends IFloodlightService>, IFloodlightService> m = new HashMap<Class<? extends IFloodlightService>, IFloodlightService>();
m.put(IThreadPoolService. class , this );
// We are the class that implements the service
return m;
}
@Override
public Collection<Class<? extends IFloodlightService>> getModuleDependencies() {
// No dependencies
return null ;
}
@Override
public void init(FloodlightModuleContext context)
throws FloodlightModuleException {
executor = Executors. newScheduledThreadPool(15);
// parameter - the number of threads to keep in the pool, even if they are idle.
}
@Override
public void startUp(FloodlightModuleContext context) {
// no-op
}
}
1 0
- Floodlight controller 线程池模型
- Floodlight Controller 路由原理
- floodlight & nox controller 安装
- Floodlight(controller)+OpenFlow交换机:环境搭建
- Floodlight controller和OF SW交互流程图
- java线程模型 线程池
- ICE线程池模型
- 线程池网络模型
- 线程池服务模型
- 线程池网络服务模型
- 线程池模型
- 生产者/消费者模型、读写模型、线程池
- 服务器网络模型(3)---工作线程与线程池模型
- 线程池模型[初级版]
- xmpp mina模型线程池
- 线程池模型[初级版]
- 两个线程池模型Demo
- MVC模型(Model+View+Controller)
- CodeForces 1C Ancient Berland Circus
- 利用共享内存来恢复玩家数据
- jdk中的unicode工具
- UI系列_roration旋转动画
- The difference between read, readline, readlines in Python
- Floodlight controller 线程池模型
- elastic search 中读取数据问题
- MonkeyTalk自动化之——IOS agent
- 传播易7月发力 微信大号营销成为前锋
- Evaluate Reverse Polish Notation
- 负载均衡
- 浅谈三层结构
- hdu 2578
- poj 2230——Watchcow