blob: e11814bd913bc6c581e55182b19fcfe01a75c0de [file] [log] [blame]
HIGUCHI Yuta60a10142013-06-14 15:50:10 -07001package net.onrc.onos.ofcontroller.flowmanager;
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -08002
3import java.util.ArrayList;
4import java.util.Collection;
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -08005import java.util.EnumSet;
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -08006import java.util.HashMap;
Masayoshi Kobayashic9da09e2013-03-26 20:52:02 +00007import java.util.LinkedList;
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -08008import java.util.Map;
Pavlin Radoslavov0b22d0e2013-04-02 01:12:46 +00009import java.util.Random;
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -080010import java.util.concurrent.Executors;
11import java.util.concurrent.ScheduledExecutorService;
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -080012import java.util.concurrent.TimeUnit;
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -080013
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -080014import net.floodlightcontroller.core.IFloodlightProviderService;
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -080015import net.floodlightcontroller.core.IOFSwitch;
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -080016import net.floodlightcontroller.core.module.FloodlightModuleContext;
17import net.floodlightcontroller.core.module.FloodlightModuleException;
18import net.floodlightcontroller.core.module.IFloodlightModule;
19import net.floodlightcontroller.core.module.IFloodlightService;
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -080020import net.floodlightcontroller.restserver.IRestApiService;
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -080021import net.floodlightcontroller.util.OFMessageDamper;
Pavlin Radoslavov05378272013-10-19 23:23:05 -070022
23import net.onrc.onos.datagrid.IDatagridService;
Pankaj Berde38646d62013-06-21 11:34:04 -070024import net.onrc.onos.graph.GraphDBOperation;
HIGUCHI Yuta20514902013-06-12 11:24:16 -070025import net.onrc.onos.ofcontroller.core.INetMapStorage;
26import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowEntry;
27import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowPath;
Pavlin Radoslavove9a3ef92013-10-18 18:46:45 -070028import net.onrc.onos.ofcontroller.floodlightlistener.INetworkGraphService;
HIGUCHI Yuta60a10142013-06-14 15:50:10 -070029import net.onrc.onos.ofcontroller.flowmanager.web.FlowWebRoutable;
Pavlin Radoslavov1278ac72013-10-16 04:43:49 -070030import net.onrc.onos.ofcontroller.topology.ITopologyNetService;
Pavlin Radoslavov15954d42013-10-19 15:29:04 -070031import net.onrc.onos.ofcontroller.topology.Topology;
Pavlin Radoslavov661c86f2013-10-21 12:40:40 -070032import net.onrc.onos.ofcontroller.util.*;
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -080033
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -080034import org.openflow.protocol.OFType;
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -080035import org.slf4j.Logger;
36import org.slf4j.LoggerFactory;
37
admin944ef4f2013-10-08 17:48:37 -070038/**
HIGUCHI Yutaeb567aa2013-10-08 19:27:35 -070039 * Flow Manager class for handling the network flows.
admin944ef4f2013-10-08 17:48:37 -070040 */
Pavlin Radoslavov5adf1522013-04-04 17:43:41 -070041public class FlowManager implements IFloodlightModule, IFlowService, INetMapStorage {
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -080042
Pavlin Radoslavov661c86f2013-10-21 12:40:40 -070043 protected GraphDBOperation dbHandler;
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -080044
Jonathan Hart50a94982013-04-10 14:49:51 -070045 protected volatile IFloodlightProviderService floodlightProvider;
Pavlin Radoslavov1278ac72013-10-16 04:43:49 -070046 protected volatile ITopologyNetService topologyNetService;
Pavlin Radoslavov05378272013-10-19 23:23:05 -070047 protected volatile IDatagridService datagridService;
48 protected IRestApiService restApi;
Pavlin Radoslavov571cff92013-03-20 02:01:32 -070049 protected FloodlightModuleContext context;
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -080050
51 protected OFMessageDamper messageDamper;
52
Pavlin Radoslavov78c4e492013-03-12 17:17:48 -070053 //
54 // TODO: Values copied from elsewhere (class LearningSwitch).
55 // The local copy should go away!
56 //
57 protected static final int OFMESSAGE_DAMPER_CAPACITY = 50000; // TODO: find sweet spot
58 protected static final int OFMESSAGE_DAMPER_TIMEOUT = 250; // ms
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -080059
Pavlin Radoslavov0b22d0e2013-04-02 01:12:46 +000060 // Flow Entry ID generation state
61 private static Random randomGenerator = new Random();
62 private static int nextFlowEntryIdPrefix = 0;
63 private static int nextFlowEntryIdSuffix = 0;
64 private static long nextFlowEntryId = 0;
65
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -080066 /** The logger. */
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -080067 private static Logger log = LoggerFactory.getLogger(FlowManager.class);
68
69 // The periodic task(s)
Jonathan Hart50a94982013-04-10 14:49:51 -070070 private ScheduledExecutorService mapReaderScheduler;
71 private ScheduledExecutorService shortestPathReconcileScheduler;
Pavlin Radoslavov6fb76d12013-04-09 22:52:25 -070072
admin944ef4f2013-10-08 17:48:37 -070073 /**
74 * Periodic task for reading the Flow Entries and pushing changes
75 * into the switches.
76 */
Pavlin Radoslavov571cff92013-03-20 02:01:32 -070077 final Runnable mapReader = new Runnable() {
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -080078 public void run() {
Pavlin Radoslavova75caea2013-04-10 19:11:26 -070079 try {
80 runImpl();
81 } catch (Exception e) {
82 log.debug("Exception processing All Flow Entries from the Network MAP: ", e);
Pavlin Radoslavov661c86f2013-10-21 12:40:40 -070083 dbHandler.rollback();
Pavlin Radoslavova75caea2013-04-10 19:11:26 -070084 return;
85 }
86 }
87
88 private void runImpl() {
Pavlin Radoslavov42f02ba2013-04-03 20:07:30 -070089 long startTime = System.nanoTime();
90 int counterAllFlowEntries = 0;
91 int counterMyNotUpdatedFlowEntries = 0;
Pavlin Radoslavov42f02ba2013-04-03 20:07:30 -070092
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -080093 if (floodlightProvider == null) {
94 log.debug("FloodlightProvider service not found!");
95 return;
96 }
Masayoshi Kobayashic9da09e2013-03-26 20:52:02 +000097 Map<Long, IOFSwitch> mySwitches =
98 floodlightProvider.getSwitches();
Pankaj Berdebf51e4f2013-10-03 17:49:23 -070099 if (mySwitches.isEmpty()) {
Pankaj Berde85a877b2013-10-03 18:26:35 -0700100 log.trace("No switches controlled");
Pankaj Berdebf51e4f2013-10-03 17:49:23 -0700101 return;
102 }
Pavlin Radoslavov20d35a22013-04-05 10:16:15 -0700103 LinkedList<IFlowEntry> addFlowEntries =
104 new LinkedList<IFlowEntry>();
Masayoshi Kobayashic9da09e2013-03-26 20:52:02 +0000105 LinkedList<IFlowEntry> deleteFlowEntries =
106 new LinkedList<IFlowEntry>();
Pavlin Radoslavovdbaaf2e2013-03-29 04:25:55 -0700107
108 //
Pavlin Radoslavov50e532e2013-10-20 02:07:51 -0700109 // Fetch all Flow Entries which need to be updated and select
110 // only my Flow Entries that need to be updated into the
111 // switches.
Pavlin Radoslavov01391c92013-03-14 17:13:21 -0700112 //
Masayoshi Kobayashic9da09e2013-03-26 20:52:02 +0000113 Iterable<IFlowEntry> allFlowEntries =
Pavlin Radoslavov661c86f2013-10-21 12:40:40 -0700114 dbHandler.getAllSwitchNotUpdatedFlowEntries();
Pavlin Radoslavov01391c92013-03-14 17:13:21 -0700115 for (IFlowEntry flowEntryObj : allFlowEntries) {
Pavlin Radoslavov42f02ba2013-04-03 20:07:30 -0700116 counterAllFlowEntries++;
Masayoshi Kobayashic9da09e2013-03-26 20:52:02 +0000117
Pavlin Radoslavov6db8c6e2013-04-08 00:14:07 +0000118 String dpidStr = flowEntryObj.getSwitchDpid();
119 if (dpidStr == null)
120 continue;
121 Dpid dpid = new Dpid(dpidStr);
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800122 IOFSwitch mySwitch = mySwitches.get(dpid.value());
Masayoshi Kobayashic9da09e2013-03-26 20:52:02 +0000123 if (mySwitch == null)
124 continue; // Ignore the entry: not my switch
125
Pavlin Radoslavov20d35a22013-04-05 10:16:15 -0700126 IFlowPath flowObj =
Pavlin Radoslavov661c86f2013-10-21 12:40:40 -0700127 dbHandler.getFlowPathByFlowEntry(flowEntryObj);
Pavlin Radoslavov20d35a22013-04-05 10:16:15 -0700128 if (flowObj == null)
129 continue; // Should NOT happen
130 if (flowObj.getFlowId() == null)
131 continue; // Invalid entry
132
133 //
134 // NOTE: For now we process the DELETE before the ADD
135 // to cover the more common scenario.
136 // TODO: This is error prone and needs to be fixed!
137 //
Pavlin Radoslavov6db8c6e2013-04-08 00:14:07 +0000138 String userState = flowEntryObj.getUserState();
139 if (userState == null)
140 continue;
Pavlin Radoslavovec8e2e62013-04-04 18:18:29 -0700141 if (userState.equals("FE_USER_DELETE")) {
142 // An entry that needs to be deleted.
143 deleteFlowEntries.add(flowEntryObj);
Pavlin Radoslavov20d35a22013-04-05 10:16:15 -0700144 installFlowEntry(mySwitch, flowObj, flowEntryObj);
145 } else {
146 addFlowEntries.add(flowEntryObj);
Pavlin Radoslavovec8e2e62013-04-04 18:18:29 -0700147 }
Pavlin Radoslavov42f02ba2013-04-03 20:07:30 -0700148 counterMyNotUpdatedFlowEntries++;
Pavlin Radoslavov20d35a22013-04-05 10:16:15 -0700149 }
150
Pavlin Radoslavov20d35a22013-04-05 10:16:15 -0700151 //
152 // Process the Flow Entries that need to be added
153 //
154 for (IFlowEntry flowEntryObj : addFlowEntries) {
155 IFlowPath flowObj =
Pavlin Radoslavov661c86f2013-10-21 12:40:40 -0700156 dbHandler.getFlowPathByFlowEntry(flowEntryObj);
Pavlin Radoslavov20d35a22013-04-05 10:16:15 -0700157 if (flowObj == null)
158 continue; // Should NOT happen
159 if (flowObj.getFlowId() == null)
160 continue; // Invalid entry
Pavlin Radoslavov01391c92013-03-14 17:13:21 -0700161
Pavlin Radoslavov01391c92013-03-14 17:13:21 -0700162 Dpid dpid = new Dpid(flowEntryObj.getSwitchDpid());
Pavlin Radoslavov01391c92013-03-14 17:13:21 -0700163 IOFSwitch mySwitch = mySwitches.get(dpid.value());
Masayoshi Kobayashic9da09e2013-03-26 20:52:02 +0000164 if (mySwitch == null)
165 continue; // Shouldn't happen
Pavlin Radoslavovec8e2e62013-04-04 18:18:29 -0700166 installFlowEntry(mySwitch, flowObj, flowEntryObj);
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800167 }
Masayoshi Kobayashic9da09e2013-03-26 20:52:02 +0000168
169 //
Pavlin Radoslavov710e2a72013-04-08 02:31:05 +0000170 // Delete all Flow Entries marked for deletion from the
Pavlin Radoslavov44a3dcd2013-04-04 18:42:56 -0700171 // Network MAP.
Masayoshi Kobayashic9da09e2013-03-26 20:52:02 +0000172 //
173 // TODO: We should use the OpenFlow Barrier mechanism
174 // to check for errors, and delete the Flow Entries after the
175 // Barrier message is received.
176 //
177 while (! deleteFlowEntries.isEmpty()) {
178 IFlowEntry flowEntryObj = deleteFlowEntries.poll();
179 IFlowPath flowObj =
Pavlin Radoslavov661c86f2013-10-21 12:40:40 -0700180 dbHandler.getFlowPathByFlowEntry(flowEntryObj);
Masayoshi Kobayashic9da09e2013-03-26 20:52:02 +0000181 if (flowObj == null) {
182 log.debug("Did not find FlowPath to be deleted");
183 continue;
184 }
185 flowObj.removeFlowEntry(flowEntryObj);
Pavlin Radoslavov661c86f2013-10-21 12:40:40 -0700186 dbHandler.removeFlowEntry(flowEntryObj);
Masayoshi Kobayashic9da09e2013-03-26 20:52:02 +0000187 }
Pavlin Radoslavov0391b9d2013-03-29 11:54:25 -0700188
Pavlin Radoslavov661c86f2013-10-21 12:40:40 -0700189 dbHandler.commit();
Pavlin Radoslavov6fb76d12013-04-09 22:52:25 -0700190
Pavlin Radoslavov6fb76d12013-04-09 22:52:25 -0700191 long estimatedTime = System.nanoTime() - startTime;
192 double rate = 0.0;
193 if (estimatedTime > 0)
194 rate = ((double)counterAllFlowEntries * 1000000000) / estimatedTime;
195 String logMsg = "MEASUREMENT: Processed AllFlowEntries: " +
196 counterAllFlowEntries + " MyNotUpdatedFlowEntries: " +
197 counterMyNotUpdatedFlowEntries + " in " +
198 (double)estimatedTime / 1000000000 + " sec: " +
199 rate + " paths/s";
200 log.debug(logMsg);
201 }
202 };
203
admin944ef4f2013-10-08 17:48:37 -0700204 /**
205 * Periodic task for reading the Flow Paths and recomputing the
206 * shortest paths.
207 */
Pavlin Radoslavov6fb76d12013-04-09 22:52:25 -0700208 final Runnable shortestPathReconcile = new Runnable() {
209 public void run() {
Pavlin Radoslavova75caea2013-04-10 19:11:26 -0700210 try {
211 runImpl();
212 } catch (Exception e) {
213 log.debug("Exception processing All Flows from the Network MAP: ", e);
Pavlin Radoslavov661c86f2013-10-21 12:40:40 -0700214 dbHandler.rollback();
Pavlin Radoslavova75caea2013-04-10 19:11:26 -0700215 return;
216 }
217 }
218
219 private void runImpl() {
Pavlin Radoslavov6fb76d12013-04-09 22:52:25 -0700220 long startTime = System.nanoTime();
221 int counterAllFlowPaths = 0;
222 int counterMyFlowPaths = 0;
223
224 if (floodlightProvider == null) {
225 log.debug("FloodlightProvider service not found!");
226 return;
227 }
228 Map<Long, IOFSwitch> mySwitches =
229 floodlightProvider.getSwitches();
Pankaj Berdebf51e4f2013-10-03 17:49:23 -0700230 if (mySwitches.isEmpty()) {
Pankaj Berde85a877b2013-10-03 18:26:35 -0700231 log.trace("No switches controlled");
Pankaj Berdebf51e4f2013-10-03 17:49:23 -0700232 return;
233 }
Pavlin Radoslavov6fb76d12013-04-09 22:52:25 -0700234 LinkedList<IFlowPath> deleteFlows = new LinkedList<IFlowPath>();
235
Pavlin Radoslavov0391b9d2013-03-29 11:54:25 -0700236 //
237 // Fetch and recompute the Shortest Path for those
238 // Flow Paths this controller is responsible for.
239 //
Pavlin Radoslavov15954d42013-10-19 15:29:04 -0700240 Topology topology = topologyNetService.newDatabaseTopology();
Pavlin Radoslavov661c86f2013-10-21 12:40:40 -0700241 Iterable<IFlowPath> allFlowPaths = dbHandler.getAllFlowPaths();
Pavlin Radoslavov0391b9d2013-03-29 11:54:25 -0700242 for (IFlowPath flowPathObj : allFlowPaths) {
Pavlin Radoslavov42f02ba2013-04-03 20:07:30 -0700243 counterAllFlowPaths++;
Pavlin Radoslavov0391b9d2013-03-29 11:54:25 -0700244 if (flowPathObj == null)
245 continue;
Pavlin Radoslavov0391b9d2013-03-29 11:54:25 -0700246
Pavlin Radoslavov0391b9d2013-03-29 11:54:25 -0700247 String srcDpidStr = flowPathObj.getSrcSwitch();
Pavlin Radoslavov6db8c6e2013-04-08 00:14:07 +0000248 if (srcDpidStr == null)
Pavlin Radoslavov0391b9d2013-03-29 11:54:25 -0700249 continue;
Pavlin Radoslavov0391b9d2013-03-29 11:54:25 -0700250 Dpid srcDpid = new Dpid(srcDpidStr);
Pavlin Radoslavov2659a0b2013-04-03 20:30:40 -0700251 //
252 // Use the source DPID as a heuristic to decide
253 // which controller is responsible for maintaining the
254 // shortest path.
255 // NOTE: This heuristic is error-prone: if the switch
256 // goes away and no controller is responsible for that
257 // switch, then the original Flow Path is not cleaned-up
258 //
259 IOFSwitch mySwitch = mySwitches.get(srcDpid.value());
260 if (mySwitch == null)
261 continue; // Ignore: not my responsibility
262
Pavlin Radoslavov99d1b152013-04-09 22:57:33 -0700263 // Test the Data Path Summary string
264 String dataPathSummaryStr = flowPathObj.getDataPathSummary();
265 if (dataPathSummaryStr == null)
266 continue; // Could be invalid entry?
267 if (dataPathSummaryStr.isEmpty())
268 continue; // No need to maintain this flow
269
Pavlin Radoslavov710e2a72013-04-08 02:31:05 +0000270 //
271 // Test whether we need to complete the Flow cleanup,
272 // if the Flow has been deleted by the user.
273 //
274 String flowUserState = flowPathObj.getUserState();
275 if ((flowUserState != null)
276 && flowUserState.equals("FE_USER_DELETE")) {
277 Iterable<IFlowEntry> flowEntries = flowPathObj.getFlowEntries();
Yuta HIGUCHI2ded2dd2013-10-09 18:06:41 -0700278 final boolean empty = !flowEntries.iterator().hasNext();
Pavlin Radoslavov710e2a72013-04-08 02:31:05 +0000279 if (empty)
280 deleteFlows.add(flowPathObj);
281 }
282
Pavlin Radoslavov6db8c6e2013-04-08 00:14:07 +0000283 // Fetch the fields needed to recompute the shortest path
284 Short srcPortShort = flowPathObj.getSrcPort();
285 String dstDpidStr = flowPathObj.getDstSwitch();
286 Short dstPortShort = flowPathObj.getDstPort();
Pavlin Radoslavov204b2862013-07-12 14:15:36 -0700287 Long flowPathFlagsLong = flowPathObj.getFlowPathFlags();
Pavlin Radoslavov6db8c6e2013-04-08 00:14:07 +0000288 if ((srcPortShort == null) ||
289 (dstDpidStr == null) ||
Pavlin Radoslavov204b2862013-07-12 14:15:36 -0700290 (dstPortShort == null) ||
291 (flowPathFlagsLong == null)) {
Pavlin Radoslavov6db8c6e2013-04-08 00:14:07 +0000292 continue;
293 }
294
295 Port srcPort = new Port(srcPortShort);
296 Dpid dstDpid = new Dpid(dstDpidStr);
297 Port dstPort = new Port(dstPortShort);
298 SwitchPort srcSwitchPort = new SwitchPort(srcDpid, srcPort);
299 SwitchPort dstSwitchPort = new SwitchPort(dstDpid, dstPort);
Pavlin Radoslavov204b2862013-07-12 14:15:36 -0700300 FlowPathFlags flowPathFlags = new FlowPathFlags(flowPathFlagsLong);
Pavlin Radoslavov6db8c6e2013-04-08 00:14:07 +0000301
Pavlin Radoslavov2659a0b2013-04-03 20:30:40 -0700302 counterMyFlowPaths++;
303
Pavlin Radoslavov832aa652013-03-29 16:21:59 -0700304 //
Pavlin Radoslavov15954d42013-10-19 15:29:04 -0700305 // NOTE: Using here the regular getDatabaseShortestPath()
306 // method won't work here, because that method calls
307 // internally "conn.endTx(Transaction.COMMIT)", and that
308 // will invalidate all handlers to the Titan database.
Pavlin Radoslavov832aa652013-03-29 16:21:59 -0700309 // If we want to experiment with calling here
Pavlin Radoslavov15954d42013-10-19 15:29:04 -0700310 // getDatabaseShortestPath(), we need to refactor that code
Pavlin Radoslavov832aa652013-03-29 16:21:59 -0700311 // to avoid closing the transaction.
312 //
Pavlin Radoslavov0391b9d2013-03-29 11:54:25 -0700313 DataPath dataPath =
Pavlin Radoslavov15954d42013-10-19 15:29:04 -0700314 topologyNetService.getTopologyShortestPath(
315 topology,
316 srcSwitchPort,
317 dstSwitchPort);
Pavlin Radoslavov4a325822013-04-02 22:16:59 +0000318 if (dataPath == null) {
319 // We need the DataPath to compare the paths
320 dataPath = new DataPath();
321 dataPath.setSrcPort(srcSwitchPort);
322 dataPath.setDstPort(dstSwitchPort);
323 }
Pavlin Radoslavov204b2862013-07-12 14:15:36 -0700324 dataPath.applyFlowPathFlags(flowPathFlags);
Pavlin Radoslavov4a325822013-04-02 22:16:59 +0000325
Pavlin Radoslavov0391b9d2013-03-29 11:54:25 -0700326 String newDataPathSummaryStr = dataPath.dataPathSummary();
327 if (dataPathSummaryStr.equals(newDataPathSummaryStr))
328 continue; // Nothing changed
329
Pavlin Radoslavov20d35a22013-04-05 10:16:15 -0700330 reconcileFlow(flowPathObj, dataPath);
Pavlin Radoslavov0391b9d2013-03-29 11:54:25 -0700331 }
Pavlin Radoslavov710e2a72013-04-08 02:31:05 +0000332
333 //
334 // Delete all leftover Flows marked for deletion from the
335 // Network MAP.
336 //
337 while (! deleteFlows.isEmpty()) {
338 IFlowPath flowPathObj = deleteFlows.poll();
Pavlin Radoslavov661c86f2013-10-21 12:40:40 -0700339 dbHandler.removeFlowPath(flowPathObj);
Pavlin Radoslavov710e2a72013-04-08 02:31:05 +0000340 }
341
Pavlin Radoslavov15954d42013-10-19 15:29:04 -0700342 topologyNetService.dropTopology(topology);
Pavlin Radoslavov0391b9d2013-03-29 11:54:25 -0700343
Pavlin Radoslavov661c86f2013-10-21 12:40:40 -0700344 dbHandler.commit();
Pavlin Radoslavov571cff92013-03-20 02:01:32 -0700345
Pavlin Radoslavov42f02ba2013-04-03 20:07:30 -0700346 long estimatedTime = System.nanoTime() - startTime;
Pavlin Radoslavov1552f952013-04-04 17:51:22 -0700347 double rate = 0.0;
348 if (estimatedTime > 0)
349 rate = ((double)counterAllFlowPaths * 1000000000) / estimatedTime;
Pavlin Radoslavov6fb76d12013-04-09 22:52:25 -0700350 String logMsg = "MEASUREMENT: Processed AllFlowPaths: " +
Pavlin Radoslavov1552f952013-04-04 17:51:22 -0700351 counterAllFlowPaths + " MyFlowPaths: " +
352 counterMyFlowPaths + " in " +
353 (double)estimatedTime / 1000000000 + " sec: " +
354 rate + " paths/s";
Pavlin Radoslavov42f02ba2013-04-03 20:07:30 -0700355 log.debug(logMsg);
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800356 }
357 };
Pavlin Radoslavov571cff92013-03-20 02:01:32 -0700358
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800359
admin944ef4f2013-10-08 17:48:37 -0700360 /**
361 * Initialize the Flow Manager.
362 *
363 * @param conf the Graph Database configuration string.
364 */
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800365 @Override
366 public void init(String conf) {
Pavlin Radoslavov661c86f2013-10-21 12:40:40 -0700367 dbHandler = new GraphDBOperation(conf);
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800368 }
369
admin944ef4f2013-10-08 17:48:37 -0700370 /**
371 * Shutdown the Flow Manager operation.
372 */
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800373 public void finalize() {
Toshio Koide9fe1cb22013-06-13 13:51:11 -0700374 close();
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800375 }
376
admin944ef4f2013-10-08 17:48:37 -0700377 /**
378 * Shutdown the Flow Manager operation.
379 */
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800380 @Override
381 public void close() {
Pavlin Radoslavov661c86f2013-10-21 12:40:40 -0700382 dbHandler.close();
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800383 }
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -0800384
admin944ef4f2013-10-08 17:48:37 -0700385 /**
386 * Get the collection of offered module services.
387 *
388 * @return the collection of offered module services.
389 */
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -0800390 @Override
391 public Collection<Class<? extends IFloodlightService>> getModuleServices() {
392 Collection<Class<? extends IFloodlightService>> l =
393 new ArrayList<Class<? extends IFloodlightService>>();
394 l.add(IFlowService.class);
395 return l;
396 }
397
admin944ef4f2013-10-08 17:48:37 -0700398 /**
399 * Get the collection of implemented services.
400 *
401 * @return the collection of implemented services.
402 */
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -0800403 @Override
404 public Map<Class<? extends IFloodlightService>, IFloodlightService>
405 getServiceImpls() {
406 Map<Class<? extends IFloodlightService>,
Pavlin Radoslavove9a3ef92013-10-18 18:46:45 -0700407 IFloodlightService> m =
408 new HashMap<Class<? extends IFloodlightService>,
409 IFloodlightService>();
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -0800410 m.put(IFlowService.class, this);
411 return m;
412 }
413
admin944ef4f2013-10-08 17:48:37 -0700414 /**
415 * Get the collection of modules this module depends on.
416 *
417 * @return the collection of modules this module depends on.
418 */
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -0800419 @Override
420 public Collection<Class<? extends IFloodlightService>>
Pavlin Radoslavov50e532e2013-10-20 02:07:51 -0700421 getModuleDependencies() {
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -0800422 Collection<Class<? extends IFloodlightService>> l =
423 new ArrayList<Class<? extends IFloodlightService>>();
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800424 l.add(IFloodlightProviderService.class);
Pavlin Radoslavove9a3ef92013-10-18 18:46:45 -0700425 l.add(INetworkGraphService.class);
Pavlin Radoslavov05378272013-10-19 23:23:05 -0700426 l.add(IDatagridService.class);
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -0800427 l.add(IRestApiService.class);
428 return l;
429 }
430
admin944ef4f2013-10-08 17:48:37 -0700431 /**
432 * Initialize the module.
433 *
434 * @param context the module context to use for the initialization.
435 */
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -0800436 @Override
437 public void init(FloodlightModuleContext context)
438 throws FloodlightModuleException {
Pavlin Radoslavov571cff92013-03-20 02:01:32 -0700439 this.context = context;
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800440 floodlightProvider = context.getServiceImpl(IFloodlightProviderService.class);
Pavlin Radoslavov05378272013-10-19 23:23:05 -0700441 topologyNetService = context.getServiceImpl(ITopologyNetService.class);
442 datagridService = context.getServiceImpl(IDatagridService.class);
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -0800443 restApi = context.getServiceImpl(IRestApiService.class);
Pavlin Radoslavov05378272013-10-19 23:23:05 -0700444
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800445 messageDamper = new OFMessageDamper(OFMESSAGE_DAMPER_CAPACITY,
446 EnumSet.of(OFType.FLOW_MOD),
447 OFMESSAGE_DAMPER_TIMEOUT);
Pavlin Radoslavovddd01ba2013-07-03 15:40:44 -0700448
Pavlin Radoslavov50e532e2013-10-20 02:07:51 -0700449 this.init("");
450
admin944ef4f2013-10-08 17:48:37 -0700451 mapReaderScheduler = Executors.newScheduledThreadPool(1);
452 shortestPathReconcileScheduler = Executors.newScheduledThreadPool(1);
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -0800453 }
454
admin944ef4f2013-10-08 17:48:37 -0700455 /**
456 * Get the next Flow Entry ID to use.
457 *
458 * @return the next Flow Entry ID to use.
459 */
Pavlin Radoslavov661c86f2013-10-21 12:40:40 -0700460 public synchronized long getNextFlowEntryId() {
Pavlin Radoslavov0b22d0e2013-04-02 01:12:46 +0000461 //
462 // Generate the next Flow Entry ID.
463 // NOTE: For now, the higher 32 bits are random, and
464 // the lower 32 bits are sequential.
465 // In the future, we need a better allocation mechanism.
466 //
467 if ((nextFlowEntryIdSuffix & 0xffffffffL) == 0xffffffffL) {
468 nextFlowEntryIdPrefix = randomGenerator.nextInt();
469 nextFlowEntryIdSuffix = 0;
470 } else {
471 nextFlowEntryIdSuffix++;
472 }
473 long result = (long)nextFlowEntryIdPrefix << 32;
474 result = result | (0xffffffffL & nextFlowEntryIdSuffix);
475 return result;
476 }
477
admin944ef4f2013-10-08 17:48:37 -0700478 /**
479 * Startup module operation.
480 *
481 * @param context the module context to use for the startup.
482 */
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -0800483 @Override
484 public void startUp(FloodlightModuleContext context) {
admin944ef4f2013-10-08 17:48:37 -0700485 restApi.addRestletRoutable(new FlowWebRoutable());
Pavlin Radoslavov50e532e2013-10-20 02:07:51 -0700486
admin944ef4f2013-10-08 17:48:37 -0700487 // Initialize the Flow Entry ID generator
488 nextFlowEntryIdPrefix = randomGenerator.nextInt();
Pavlin Radoslavov50e532e2013-10-20 02:07:51 -0700489
admin944ef4f2013-10-08 17:48:37 -0700490 mapReaderScheduler.scheduleAtFixedRate(
491 mapReader, 3, 3, TimeUnit.SECONDS);
492 shortestPathReconcileScheduler.scheduleAtFixedRate(
493 shortestPathReconcile, 3, 3, TimeUnit.SECONDS);
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -0800494 }
495
496 /**
497 * Add a flow.
498 *
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -0800499 * @param flowPath the Flow Path to install.
500 * @param flowId the return-by-reference Flow ID as assigned internally.
Pavlin Radoslavovdbaaf2e2013-03-29 04:25:55 -0700501 * @param dataPathSummaryStr the data path summary string if the added
502 * flow will be maintained internally, otherwise null.
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -0800503 * @return true on success, otherwise false.
504 */
505 @Override
Pavlin Radoslavovdbaaf2e2013-03-29 04:25:55 -0700506 public boolean addFlow(FlowPath flowPath, FlowId flowId,
507 String dataPathSummaryStr) {
Pavlin Radoslavov661c86f2013-10-21 12:40:40 -0700508 return FlowDatabaseOperation.addFlow(this, dbHandler, flowPath, flowId,
509 dataPathSummaryStr);
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -0800510 }
511
512 /**
Pavlin Radoslavov9425f702013-04-04 19:55:07 -0700513 * Add a flow entry to the Network MAP.
514 *
515 * @param flowObj the corresponding Flow Path object for the Flow Entry.
516 * @param flowEntry the Flow Entry to install.
Pavlin Radoslavov20d35a22013-04-05 10:16:15 -0700517 * @return the added Flow Entry object on success, otherwise null.
Pavlin Radoslavov9425f702013-04-04 19:55:07 -0700518 */
Pavlin Radoslavov20d35a22013-04-05 10:16:15 -0700519 private IFlowEntry addFlowEntry(IFlowPath flowObj, FlowEntry flowEntry) {
Pavlin Radoslavov661c86f2013-10-21 12:40:40 -0700520 return FlowDatabaseOperation.addFlowEntry(this, dbHandler, flowObj,
521 flowEntry);
Pavlin Radoslavov9425f702013-04-04 19:55:07 -0700522 }
523
524 /**
Pavlin Radoslavovbaea9242013-05-08 00:20:09 +0000525 * Delete all previously added flows.
526 *
527 * @return true on success, otherwise false.
528 */
529 @Override
530 public boolean deleteAllFlows() {
Pavlin Radoslavov661c86f2013-10-21 12:40:40 -0700531 return FlowDatabaseOperation.deleteAllFlows(dbHandler);
Pavlin Radoslavovbaea9242013-05-08 00:20:09 +0000532 }
533
534 /**
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -0800535 * Delete a previously added flow.
536 *
537 * @param flowId the Flow ID of the flow to delete.
538 * @return true on success, otherwise false.
539 */
540 @Override
541 public boolean deleteFlow(FlowId flowId) {
Pavlin Radoslavov661c86f2013-10-21 12:40:40 -0700542 return FlowDatabaseOperation.deleteFlow(dbHandler, flowId);
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -0800543 }
544
545 /**
Pavlin Radoslavovbaea9242013-05-08 00:20:09 +0000546 * Clear the state for all previously added flows.
547 *
548 * @return true on success, otherwise false.
549 */
550 @Override
551 public boolean clearAllFlows() {
Pavlin Radoslavov661c86f2013-10-21 12:40:40 -0700552 return FlowDatabaseOperation.clearAllFlows(dbHandler);
Pavlin Radoslavovbaea9242013-05-08 00:20:09 +0000553 }
554
555 /**
Pavlin Radoslavov916832f2013-03-14 17:48:41 -0700556 * Clear the state for a previously added flow.
557 *
558 * @param flowId the Flow ID of the flow to clear.
559 * @return true on success, otherwise false.
560 */
561 @Override
562 public boolean clearFlow(FlowId flowId) {
Pavlin Radoslavov661c86f2013-10-21 12:40:40 -0700563 return FlowDatabaseOperation.clearFlow(dbHandler, flowId);
Pavlin Radoslavov916832f2013-03-14 17:48:41 -0700564 }
565
566 /**
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -0800567 * Get a previously added flow.
568 *
569 * @param flowId the Flow ID of the flow to get.
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800570 * @return the Flow Path if found, otherwise null.
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -0800571 */
572 @Override
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800573 public FlowPath getFlow(FlowId flowId) {
Pavlin Radoslavov661c86f2013-10-21 12:40:40 -0700574 return FlowDatabaseOperation.getFlow(dbHandler, flowId);
575 }
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800576
Pavlin Radoslavov661c86f2013-10-21 12:40:40 -0700577 /**
578 * Get all installed flows by all installers.
579 *
580 * @return the Flow Paths if found, otherwise null.
581 */
582 @Override
583 public ArrayList<FlowPath> getAllFlows() {
584 return FlowDatabaseOperation.getAllFlows(dbHandler);
Pavlin Radoslavov706df052013-03-06 10:49:07 -0800585 }
586
587 /**
588 * Get all previously added flows by a specific installer for a given
589 * data path endpoints.
590 *
591 * @param installerId the Caller ID of the installer of the flow to get.
592 * @param dataPathEndpoints the data path endpoints of the flow to get.
593 * @return the Flow Paths if found, otherwise null.
594 */
595 @Override
596 public ArrayList<FlowPath> getAllFlows(CallerId installerId,
597 DataPathEndpoints dataPathEndpoints) {
Pavlin Radoslavov661c86f2013-10-21 12:40:40 -0700598 return FlowDatabaseOperation.getAllFlows(dbHandler, installerId,
599 dataPathEndpoints);
Pavlin Radoslavov706df052013-03-06 10:49:07 -0800600 }
601
602 /**
603 * Get all installed flows by all installers for given data path endpoints.
604 *
605 * @param dataPathEndpoints the data path endpoints of the flows to get.
606 * @return the Flow Paths if found, otherwise null.
607 */
608 @Override
609 public ArrayList<FlowPath> getAllFlows(DataPathEndpoints dataPathEndpoints) {
Pavlin Radoslavov661c86f2013-10-21 12:40:40 -0700610 return FlowDatabaseOperation.getAllFlows(dbHandler, dataPathEndpoints);
Pavlin Radoslavov706df052013-03-06 10:49:07 -0800611 }
612
613 /**
admin944ef4f2013-10-08 17:48:37 -0700614 * Get summary of all installed flows by all installers in a given range.
Umesh Krishnaswamy57a32a92013-03-21 14:21:15 -0700615 *
admin944ef4f2013-10-08 17:48:37 -0700616 * @param flowId the Flow ID of the first flow in the flow range to get.
HIGUCHI Yutaeb567aa2013-10-08 19:27:35 -0700617 * @param maxFlows the maximum number of flows to be returned.
Umesh Krishnaswamy57a32a92013-03-21 14:21:15 -0700618 * @return the Flow Paths if found, otherwise null.
619 */
620 @Override
Pavlin Radoslavov50e532e2013-10-20 02:07:51 -0700621 public ArrayList<IFlowPath> getAllFlowsSummary(FlowId flowId,
622 int maxFlows) {
Pavlin Radoslavov661c86f2013-10-21 12:40:40 -0700623 return FlowDatabaseOperation.getAllFlowsSummary(dbHandler, flowId,
624 maxFlows);
Umesh Krishnaswamy57a32a92013-03-21 14:21:15 -0700625 }
626
627 /**
admin944ef4f2013-10-08 17:48:37 -0700628 * Get all Flows information, without the associated Flow Entries.
629 *
630 * @return all Flows information, without the associated Flow Entries.
631 */
632 public ArrayList<IFlowPath> getAllFlowsWithoutFlowEntries() {
Pavlin Radoslavov661c86f2013-10-21 12:40:40 -0700633 return FlowDatabaseOperation.getAllFlowsWithoutFlowEntries(dbHandler);
Pavlin Radoslavov99b12752013-04-04 17:28:06 -0700634 }
635
636 /**
Pavlin Radoslavovb9fe6b42013-03-27 16:25:05 -0700637 * Add and maintain a shortest-path flow.
638 *
Pavlin Radoslavov67b3ef32013-04-03 02:44:48 -0700639 * NOTE: The Flow Path argument does NOT contain flow entries.
Pavlin Radoslavovb9fe6b42013-03-27 16:25:05 -0700640 *
641 * @param flowPath the Flow Path with the endpoints and the match
642 * conditions to install.
Pavlin Radoslavove0575292013-03-28 05:35:25 -0700643 * @return the added shortest-path flow on success, otherwise null.
Pavlin Radoslavovb9fe6b42013-03-27 16:25:05 -0700644 */
645 @Override
Pavlin Radoslavove0575292013-03-28 05:35:25 -0700646 public FlowPath addAndMaintainShortestPathFlow(FlowPath flowPath) {
Pavlin Radoslavovb9fe6b42013-03-27 16:25:05 -0700647 //
Pavlin Radoslavov8b4b0592013-04-10 04:33:33 +0000648 // Don't do the shortest path computation here.
649 // Instead, let the Flow reconciliation thread take care of it.
Pavlin Radoslavovb9fe6b42013-03-27 16:25:05 -0700650 //
Pavlin Radoslavovb9fe6b42013-03-27 16:25:05 -0700651
Pavlin Radoslavov8b4b0592013-04-10 04:33:33 +0000652 // We need the DataPath to populate the Network MAP
653 DataPath dataPath = new DataPath();
654 dataPath.setSrcPort(flowPath.dataPath().srcPort());
655 dataPath.setDstPort(flowPath.dataPath().dstPort());
Pavlin Radoslavovb9fe6b42013-03-27 16:25:05 -0700656
657 //
658 // Prepare the computed Flow Path
659 //
Pavlin Radoslavove0575292013-03-28 05:35:25 -0700660 FlowPath computedFlowPath = new FlowPath();
661 computedFlowPath.setFlowId(new FlowId(flowPath.flowId().value()));
662 computedFlowPath.setInstallerId(new CallerId(flowPath.installerId().value()));
Pavlin Radoslavov204b2862013-07-12 14:15:36 -0700663 computedFlowPath.setFlowPathFlags(new FlowPathFlags(flowPath.flowPathFlags().flags()));
Pavlin Radoslavove0575292013-03-28 05:35:25 -0700664 computedFlowPath.setDataPath(dataPath);
Pavlin Radoslavov67b3ef32013-04-03 02:44:48 -0700665 computedFlowPath.setFlowEntryMatch(new FlowEntryMatch(flowPath.flowEntryMatch()));
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700666 computedFlowPath.setFlowEntryActions(new FlowEntryActions(flowPath.flowEntryActions()));
Pavlin Radoslavovb9fe6b42013-03-27 16:25:05 -0700667
Pavlin Radoslavove0575292013-03-28 05:35:25 -0700668 FlowId flowId = new FlowId();
Pavlin Radoslavov8b4b0592013-04-10 04:33:33 +0000669 String dataPathSummaryStr = dataPath.dataPathSummary();
Pavlin Radoslavovdbaaf2e2013-03-29 04:25:55 -0700670 if (! addFlow(computedFlowPath, flowId, dataPathSummaryStr))
Pavlin Radoslavove0575292013-03-28 05:35:25 -0700671 return null;
Pavlin Radoslavovb9fe6b42013-03-27 16:25:05 -0700672
673 // TODO: Mark the flow for maintenance purpose
674
Pavlin Radoslavove0575292013-03-28 05:35:25 -0700675 return (computedFlowPath);
Pavlin Radoslavovb9fe6b42013-03-27 16:25:05 -0700676 }
677
678 /**
Pavlin Radoslavov20d35a22013-04-05 10:16:15 -0700679 * Reconcile a flow.
680 *
681 * @param flowObj the flow that needs to be reconciliated.
682 * @param newDataPath the new data path to use.
683 * @return true on success, otherwise false.
684 */
685 public boolean reconcileFlow(IFlowPath flowObj, DataPath newDataPath) {
Pavlin Radoslavov20d35a22013-04-05 10:16:15 -0700686
687 //
688 // Set the incoming port matching and the outgoing port output
689 // actions for each flow entry.
690 //
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700691 int idx = 0;
Pavlin Radoslavov20d35a22013-04-05 10:16:15 -0700692 for (FlowEntry flowEntry : newDataPath.flowEntries()) {
693 // Set the incoming port matching
694 FlowEntryMatch flowEntryMatch = new FlowEntryMatch();
695 flowEntry.setFlowEntryMatch(flowEntryMatch);
696 flowEntryMatch.enableInPort(flowEntry.inPort());
697
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700698 //
699 // Set the actions
700 //
701 FlowEntryActions flowEntryActions = flowEntry.flowEntryActions();
702 //
703 // If the first Flow Entry, copy the Flow Path actions to it
704 //
705 if (idx == 0) {
706 String actionsStr = flowObj.getActions();
707 if (actionsStr != null) {
708 FlowEntryActions flowActions = new FlowEntryActions(actionsStr);
709 for (FlowEntryAction action : flowActions.actions())
710 flowEntryActions.addAction(action);
711 }
Pavlin Radoslavov20d35a22013-04-05 10:16:15 -0700712 }
Pavlin Radoslavov282f4ff2013-07-18 11:21:37 -0700713 idx++;
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700714 //
715 // Add the outgoing port output action
716 //
Pavlin Radoslavov20d35a22013-04-05 10:16:15 -0700717 FlowEntryAction flowEntryAction = new FlowEntryAction();
718 flowEntryAction.setActionOutput(flowEntry.outPort());
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700719 flowEntryActions.addAction(flowEntryAction);
Pavlin Radoslavov20d35a22013-04-05 10:16:15 -0700720 }
721
722 //
723 // Remove the old Flow Entries, and add the new Flow Entries
724 //
Pavlin Radoslavov20d35a22013-04-05 10:16:15 -0700725 Iterable<IFlowEntry> flowEntries = flowObj.getFlowEntries();
Pavlin Radoslavov20d35a22013-04-05 10:16:15 -0700726 for (IFlowEntry flowEntryObj : flowEntries) {
Pavlin Radoslavov20d35a22013-04-05 10:16:15 -0700727 flowEntryObj.setUserState("FE_USER_DELETE");
Pavlin Radoslavov6fb76d12013-04-09 22:52:25 -0700728 flowEntryObj.setSwitchState("FE_SWITCH_NOT_UPDATED");
Pavlin Radoslavov20d35a22013-04-05 10:16:15 -0700729 }
Pavlin Radoslavov20d35a22013-04-05 10:16:15 -0700730 for (FlowEntry flowEntry : newDataPath.flowEntries()) {
Pavlin Radoslavov6fb76d12013-04-09 22:52:25 -0700731 addFlowEntry(flowObj, flowEntry);
Pavlin Radoslavov20d35a22013-04-05 10:16:15 -0700732 }
733
734 //
735 // Set the Data Path Summary
736 //
737 String dataPathSummaryStr = newDataPath.dataPathSummary();
738 flowObj.setDataPathSummary(dataPathSummaryStr);
739
740 return true;
741 }
742
743 /**
Pavlin Radoslavovdbaaf2e2013-03-29 04:25:55 -0700744 * Reconcile all flows in a set.
745 *
746 * @param flowObjSet the set of flows that need to be reconciliated.
747 */
748 public void reconcileFlows(Iterable<IFlowPath> flowObjSet) {
749 if (! flowObjSet.iterator().hasNext())
750 return;
Pavlin Radoslavov0eeb15d2013-04-05 10:23:51 -0700751 // TODO: Not implemented/used yet.
Pavlin Radoslavovb9fe6b42013-03-27 16:25:05 -0700752 }
753
754 /**
Pavlin Radoslavovb9fe6b42013-03-27 16:25:05 -0700755 * Install a Flow Entry on a switch.
Pavlin Radoslavovb9fe6b42013-03-27 16:25:05 -0700756 *
Pavlin Radoslavov2b858f82013-03-28 11:37:37 -0700757 * @param mySwitch the switch to install the Flow Entry into.
Pavlin Radoslavovec8e2e62013-04-04 18:18:29 -0700758 * @param flowObj the flow path object for the flow entry to install.
759 * @param flowEntryObj the flow entry object to install.
760 * @return true on success, otherwise false.
Pavlin Radoslavovb9fe6b42013-03-27 16:25:05 -0700761 */
Pavlin Radoslavovec8e2e62013-04-04 18:18:29 -0700762 public boolean installFlowEntry(IOFSwitch mySwitch, IFlowPath flowObj,
763 IFlowEntry flowEntryObj) {
Pavlin Radoslavov661c86f2013-10-21 12:40:40 -0700764 return FlowSwitchOperation.installFlowEntry(
765 floodlightProvider.getOFMessageFactory(),
766 messageDamper, mySwitch, flowObj, flowEntryObj);
Pavlin Radoslavovb9fe6b42013-03-27 16:25:05 -0700767 }
768
769 /**
770 * Install a Flow Entry on a switch.
771 *
772 * @param mySwitch the switch to install the Flow Entry into.
Pavlin Radoslavov67b3ef32013-04-03 02:44:48 -0700773 * @param flowPath the flow path for the flow entry to install.
Pavlin Radoslavovb9fe6b42013-03-27 16:25:05 -0700774 * @param flowEntry the flow entry to install.
775 * @return true on success, otherwise false.
776 */
Pavlin Radoslavov67b3ef32013-04-03 02:44:48 -0700777 public boolean installFlowEntry(IOFSwitch mySwitch, FlowPath flowPath,
778 FlowEntry flowEntry) {
Pavlin Radoslavov661c86f2013-10-21 12:40:40 -0700779 return FlowSwitchOperation.installFlowEntry(
780 floodlightProvider.getOFMessageFactory(),
781 messageDamper, mySwitch, flowPath, flowEntry);
Pavlin Radoslavovb9fe6b42013-03-27 16:25:05 -0700782 }
783
784 /**
785 * Remove a Flow Entry from a switch.
786 *
Pavlin Radoslavov2b858f82013-03-28 11:37:37 -0700787 * @param mySwitch the switch to remove the Flow Entry from.
Pavlin Radoslavov67b3ef32013-04-03 02:44:48 -0700788 * @param flowPath the flow path for the flow entry to remove.
Pavlin Radoslavov6b6f4a82013-03-28 03:30:00 -0700789 * @param flowEntry the flow entry to remove.
790 * @return true on success, otherwise false.
Pavlin Radoslavovb9fe6b42013-03-27 16:25:05 -0700791 */
Pavlin Radoslavov67b3ef32013-04-03 02:44:48 -0700792 public boolean removeFlowEntry(IOFSwitch mySwitch, FlowPath flowPath,
793 FlowEntry flowEntry) {
Pavlin Radoslavov6b6f4a82013-03-28 03:30:00 -0700794 //
795 // The installFlowEntry() method implements both installation
796 // and removal of flow entries.
797 //
Pavlin Radoslavov67b3ef32013-04-03 02:44:48 -0700798 return (installFlowEntry(mySwitch, flowPath, flowEntry));
Pavlin Radoslavovb9fe6b42013-03-27 16:25:05 -0700799 }
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -0800800}