blob: aa426a73fcd40df448bdb60d64e7ddcd8fdf894a [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;
17
18 // IThreadPoolService
19
20 @Override
21 public ScheduledExecutorService getScheduledExecutor() {
22 return executor;
23 }
24
25 // IFloodlightModule
26
27 @Override
28 public Collection<Class<? extends IFloodlightService>> getModuleServices() {
29 Collection<Class<? extends IFloodlightService>> l =
30 new ArrayList<Class<? extends IFloodlightService>>();
31 l.add(IThreadPoolService.class);
32 return l;
33 }
34
35 @Override
36 public Map<Class<? extends IFloodlightService>, IFloodlightService>
37 getServiceImpls() {
38 Map<Class<? extends IFloodlightService>,
39 IFloodlightService> m =
40 new HashMap<Class<? extends IFloodlightService>,
41 IFloodlightService>();
42 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>>
49 getModuleDependencies() {
50 // No dependencies
51 return null;
52 }
53
54 @Override
55 public void init(FloodlightModuleContext context)
56 throws FloodlightModuleException {
57 executor = Executors.newScheduledThreadPool(15);
58 }
59
60 @Override
61 public void startUp(FloodlightModuleContext context) {
62 // no-op
63 }
64}