Added getFactory() method to IOFSwitch to get a message factory appropriate
for the switch's OpenFlow version.
This prevents users of the switch having to discriminate what factory to use
based on the switch OpenFlow version.
Change-Id: Iac0454856e35f4429649a6f116da34f4c048f25d
diff --git a/src/main/java/net/onrc/onos/core/flowprogrammer/FlowPusher.java b/src/main/java/net/onrc/onos/core/flowprogrammer/FlowPusher.java
index 419dc43..a02f0d5 100644
--- a/src/main/java/net/onrc/onos/core/flowprogrammer/FlowPusher.java
+++ b/src/main/java/net/onrc/onos/core/flowprogrammer/FlowPusher.java
@@ -33,7 +33,6 @@
import org.projectfloodlight.openflow.protocol.OFFlowMod;
import org.projectfloodlight.openflow.protocol.OFMessage;
import org.projectfloodlight.openflow.protocol.OFType;
-import org.projectfloodlight.openflow.protocol.OFVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -245,7 +244,6 @@
private FloodlightModuleContext context = null;
private IThreadPoolService threadPool = null;
private IFloodlightProviderService floodlightProvider = null;
- protected Map<OFVersion, OFFactory> ofFactoryMap = null;
// Map of threads versus dpid
private Map<Long, FlowPusherThread> threadMap = null;
@@ -405,9 +403,6 @@
.getServiceImpl(IFloodlightProviderService.class);
this.threadPool = context.getServiceImpl(IThreadPoolService.class);
- ofFactoryMap = new HashMap<>();
- ofFactoryMap.put(OFVersion.OF_10, floodlightProvider.getOFMessageFactory_10());
- ofFactoryMap.put(OFVersion.OF_13, floodlightProvider.getOFMessageFactory_13());
floodlightProvider.addOFMessageListener(OFType.BARRIER_REPLY, this);
}
@@ -415,12 +410,6 @@
* Begin processing queue.
*/
public void start() {
- // TODO BOC
- // if (factory == null) {
- // log.error("FlowPusher not yet initialized.");
- // return;
- // }
-
threadMap = new HashMap<Long, FlowPusherThread>();
for (long i = 0; i < numberThread; ++i) {
FlowPusherThread thread = new FlowPusherThread();
@@ -612,7 +601,7 @@
//
// Create the OpenFlow Flow Modification Entry to push
//
- OFFlowMod fm = flowEntry.buildFlowMod(ofFactoryMap.get(sw.getOFVersion()));
+ OFFlowMod fm = flowEntry.buildFlowMod(sw.getFactory());
// log.trace("Pushing flow mod {}", fm);
return addMessageImpl(sw, fm, priority);
}
@@ -682,7 +671,7 @@
}
protected OFBarrierRequest createBarrierRequest(IOFSwitch sw) {
- OFFactory factory = ofFactoryMap.get(sw.getOFVersion());
+ OFFactory factory = sw.getFactory();
if (factory == null) {
log.error("No OF Message Factory for switch {} with OFVersion {}", sw,
sw.getOFVersion());