blob: 8bf34a83caaeb342bf11ede3ef3afa4d1cee0902 [file] [log] [blame]
Toshio Koidea03915e2014-07-01 18:39:52 -07001package net.onrc.onos.core.matchaction;
2
Ray Milkey18b44ac2014-08-22 08:29:47 -07003import java.util.ArrayList;
4import java.util.Collection;
Toshio Koidea03915e2014-07-01 18:39:52 -07005import java.util.EventListener;
Ray Milkey18b44ac2014-08-22 08:29:47 -07006import java.util.HashMap;
Ray Milkeyc127a5a2014-08-20 11:22:12 -07007import java.util.List;
Ray Milkey18b44ac2014-08-22 08:29:47 -07008import java.util.Map;
Brian O'Connordee2e6b2014-08-12 11:34:51 -07009import java.util.Set;
Toshio Koide77ec9982014-08-27 16:57:43 -070010
Ray Milkey626a2b12014-09-02 11:19:06 -070011import net.floodlightcontroller.core.IFloodlightProviderService;
12import net.floodlightcontroller.core.module.FloodlightModuleContext;
13import net.floodlightcontroller.core.module.FloodlightModuleException;
14import net.floodlightcontroller.core.module.IFloodlightModule;
15import net.floodlightcontroller.core.module.IFloodlightService;
Jonathan Hart763fb7e2014-09-02 15:06:46 -070016import net.floodlightcontroller.restserver.IRestApiService;
Ray Milkey626a2b12014-09-02 11:19:06 -070017import net.onrc.onos.api.flowmanager.ConflictDetectionPolicy;
18import net.onrc.onos.core.datagrid.IDatagridService;
19import net.onrc.onos.core.flowprogrammer.IFlowPusherService;
Jonathan Hart763fb7e2014-09-02 15:06:46 -070020import net.onrc.onos.core.matchaction.web.MatchActionWebRoutable;
Ray Milkey626a2b12014-09-02 11:19:06 -070021import net.onrc.onos.core.registry.IControllerRegistryService;
22import net.onrc.onos.core.util.IdGenerator;
23
24import org.slf4j.Logger;
25import org.slf4j.LoggerFactory;
26
Toshio Koidea03915e2014-07-01 18:39:52 -070027/**
Ray Milkey18b44ac2014-08-22 08:29:47 -070028 * Floodlight module for Match Action service.
Toshio Koidea03915e2014-07-01 18:39:52 -070029 */
Ray Milkey18b44ac2014-08-22 08:29:47 -070030
31public class MatchActionModule implements MatchActionFloodlightService, IFloodlightModule {
Toshio Koidea03915e2014-07-01 18:39:52 -070032
Ray Milkey18b44ac2014-08-22 08:29:47 -070033 private static final Logger log = LoggerFactory
34 .getLogger(MatchActionModule.class);
35 private MatchActionComponent matchActionComponent;
Ray Milkeyc127a5a2014-08-20 11:22:12 -070036
Ray Milkey18b44ac2014-08-22 08:29:47 -070037 @Override
38 public Collection<Class<? extends IFloodlightService>> getModuleServices() {
39 List<Class<? extends IFloodlightService>> services = new ArrayList<>();
40 log.info("get module services");
41 services.add(MatchActionFloodlightService.class);
42 return services;
43 }
44
45 @Override
46 public Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls() {
47 Map<Class<? extends IFloodlightService>, IFloodlightService> impls =
48 new HashMap<>();
49 impls.put(MatchActionFloodlightService.class, this);
50 return impls;
51 }
52
53 @Override
54 public Collection<Class<? extends IFloodlightService>> getModuleDependencies() {
55 List<Class<? extends IFloodlightService>> dependencies = new ArrayList<>();
56 dependencies.add(IDatagridService.class);
57 dependencies.add(IFlowPusherService.class);
58 dependencies.add(IFloodlightProviderService.class);
Ray Milkey626a2b12014-09-02 11:19:06 -070059 dependencies.add(IControllerRegistryService.class);
Jonathan Hart763fb7e2014-09-02 15:06:46 -070060 dependencies.add(IRestApiService.class);
Ray Milkey18b44ac2014-08-22 08:29:47 -070061 return dependencies;
62 }
63
64 @Override
65 public void init(FloodlightModuleContext context) throws FloodlightModuleException {
Ray Milkey18b44ac2014-08-22 08:29:47 -070066 final IDatagridService datagrid = context.getServiceImpl(IDatagridService.class);
67 final IFlowPusherService pusher = context.getServiceImpl(IFlowPusherService.class);
68 final IFloodlightProviderService provider = context.getServiceImpl(IFloodlightProviderService.class);
Ray Milkey626a2b12014-09-02 11:19:06 -070069 final IControllerRegistryService registry = context.getServiceImpl(IControllerRegistryService.class);
Jonathan Hart763fb7e2014-09-02 15:06:46 -070070 final IRestApiService restApi = context.getServiceImpl(IRestApiService.class);
71
72 restApi.addRestletRoutable(new MatchActionWebRoutable());
Ray Milkey18b44ac2014-08-22 08:29:47 -070073
Ray Milkey626a2b12014-09-02 11:19:06 -070074 matchActionComponent = new MatchActionComponent(datagrid, pusher, provider, registry);
Brian O'Connor7e2d9142014-09-02 17:24:27 -070075 }
76
77 @Override
78 public void startUp(FloodlightModuleContext context) throws FloodlightModuleException {
Ray Milkey18b44ac2014-08-22 08:29:47 -070079 matchActionComponent.start();
Ray Milkeyc127a5a2014-08-20 11:22:12 -070080 }
81
Toshio Koidea03915e2014-07-01 18:39:52 -070082 @Override
83 public boolean addMatchAction(MatchAction matchAction) {
Ray Milkey18b44ac2014-08-22 08:29:47 -070084 return matchActionComponent.addMatchAction(matchAction);
Toshio Koidea03915e2014-07-01 18:39:52 -070085 }
86
87 @Override
Brian O'Connordee2e6b2014-08-12 11:34:51 -070088 public Set<MatchAction> getMatchActions() {
Brian O'Connor7e2d9142014-09-02 17:24:27 -070089 return matchActionComponent.getMatchActions();
Toshio Koidea03915e2014-07-01 18:39:52 -070090 }
91
92 @Override
Ray Milkey18b44ac2014-08-22 08:29:47 -070093 public boolean executeOperations(MatchActionOperations operations) {
Brian O'Connor7e2d9142014-09-02 17:24:27 -070094 matchActionComponent.installMatchActionOperations(operations);
95 return false; // TODO define return value semantics
Toshio Koidea03915e2014-07-01 18:39:52 -070096 }
97
98 @Override
99 public void setConflictDetectionPolicy(ConflictDetectionPolicy policy) {
Ray Milkeya313cde2014-09-05 09:02:52 -0700100 throw new UnsupportedOperationException("conflict detection not implemented yet");
Toshio Koidea03915e2014-07-01 18:39:52 -0700101 }
102
103 @Override
104 public ConflictDetectionPolicy getConflictDetectionPolicy() {
Toshio Koidea03915e2014-07-01 18:39:52 -0700105 return null;
106 }
107
108 @Override
Sho SHIMIZU7cd8a422014-08-27 16:05:21 -0700109 public IdGenerator<MatchActionId> getMatchActionIdGenerator() {
Ray Milkey626a2b12014-09-02 11:19:06 -0700110 return matchActionComponent.getMatchActionIdGenerator();
Toshio Koide77ec9982014-08-27 16:57:43 -0700111 }
112
113 @Override
Sho SHIMIZU7cd8a422014-08-27 16:05:21 -0700114 public IdGenerator<MatchActionOperationsId> getMatchActionOperationsIdGenerator() {
Ray Milkey626a2b12014-09-02 11:19:06 -0700115 return matchActionComponent.getMatchActionOperationsIdGenerator();
Toshio Koide77ec9982014-08-27 16:57:43 -0700116 }
117
118 @Override
Toshio Koidea03915e2014-07-01 18:39:52 -0700119 public void addEventListener(EventListener listener) {
Brian O'Connorab3e9e62014-09-09 23:45:55 -0700120 // TODO
121 log.warn("Could not add MatchAction EventListener: {}", listener);
Toshio Koidea03915e2014-07-01 18:39:52 -0700122 }
123
124 @Override
125 public void removeEventListener(EventListener listener) {
Brian O'Connorab3e9e62014-09-09 23:45:55 -0700126 // TODO
127 log.warn("Could not remove MatchAction EventListener: {}", listener);
Toshio Koidea03915e2014-07-01 18:39:52 -0700128 }
129}