blob: 6314a775359596e7157df495ef43f09d7209b754 [file] [log] [blame]
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -08001package net.floodlightcontroller.threadpool;
2
3import java.util.ArrayList;
4import java.util.Collection;
5import java.util.HashMap;
6import java.util.Map;
7import java.util.concurrent.Executors;
8import java.util.concurrent.ScheduledExecutorService;
9
10import net.floodlightcontroller.core.module.FloodlightModuleContext;
11import net.floodlightcontroller.core.module.FloodlightModuleException;
12import net.floodlightcontroller.core.module.IFloodlightModule;
13import net.floodlightcontroller.core.module.IFloodlightService;
14
15public class ThreadPool implements IThreadPoolService, IFloodlightModule {
16 protected ScheduledExecutorService executor = null;
Ray Milkey269ffb92014-04-03 14:43:30 -070017
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080018 // IThreadPoolService
19
20 @Override
21 public ScheduledExecutorService getScheduledExecutor() {
22 return executor;
23 }
Ray Milkey269ffb92014-04-03 14:43:30 -070024
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080025 // IFloodlightModule
Ray Milkey269ffb92014-04-03 14:43:30 -070026
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080027 @Override
28 public Collection<Class<? extends IFloodlightService>> getModuleServices() {
Ray Milkey269ffb92014-04-03 14:43:30 -070029 Collection<Class<? extends IFloodlightService>> l =
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080030 new ArrayList<Class<? extends IFloodlightService>>();
31 l.add(IThreadPoolService.class);
32 return l;
33 }
34
35 @Override
36 public Map<Class<? extends IFloodlightService>, IFloodlightService>
Ray Milkey269ffb92014-04-03 14:43:30 -070037 getServiceImpls() {
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080038 Map<Class<? extends IFloodlightService>,
Ray Milkey269ffb92014-04-03 14:43:30 -070039 IFloodlightService> m =
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080040 new HashMap<Class<? extends IFloodlightService>,
Ray Milkey269ffb92014-04-03 14:43:30 -070041 IFloodlightService>();
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080042 m.put(IThreadPoolService.class, this);
43 // We are the class that implements the service
44 return m;
45 }
46
47 @Override
48 public Collection<Class<? extends IFloodlightService>>
Ray Milkey269ffb92014-04-03 14:43:30 -070049 getModuleDependencies() {
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080050 // No dependencies
51 return null;
52 }
53
54 @Override
55 public void init(FloodlightModuleContext context)
Ray Milkey269ffb92014-04-03 14:43:30 -070056 throws FloodlightModuleException {
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080057 executor = Executors.newScheduledThreadPool(15);
58 }
59
60 @Override
61 public void startUp(FloodlightModuleContext context) {
62 // no-op
63 }
64}