From a10e1b7224c71d9984fe480a4d8de034981ba618 Mon Sep 17 00:00:00 2001
From: Subrata Banerjee <subrata.banerjee@bigswitch.com>
Date: Wed, 15 Feb 2012 23:24:40 -0800
Subject: [PATCH] Remove flow-cache package.

---
 .../core/internal/Controller.java             |  4 --
 .../flowcache/FlowCache.java                  | 55 -------------------
 .../forwarding/Forwarding.java                |  7 ++-
 .../routing/ForwardingBase.java               | 20 ++-----
 .../forwarding/ForwardingTest.java            |  3 -
 5 files changed, 10 insertions(+), 79 deletions(-)
 delete mode 100644 src/main/java/net/floodlightcontroller/flowcache/FlowCache.java

diff --git a/src/main/java/net/floodlightcontroller/core/internal/Controller.java b/src/main/java/net/floodlightcontroller/core/internal/Controller.java
index 4aacb7f10..17ade3fb5 100644
--- a/src/main/java/net/floodlightcontroller/core/internal/Controller.java
+++ b/src/main/java/net/floodlightcontroller/core/internal/Controller.java
@@ -65,7 +65,6 @@ import net.floodlightcontroller.counter.ICounter;
 import net.floodlightcontroller.counter.CounterStore.NetworkLayer;
 import net.floodlightcontroller.devicemanager.IDeviceManagerAware;
 import net.floodlightcontroller.devicemanager.internal.DeviceManagerImpl;
-import net.floodlightcontroller.flowcache.FlowCache;
 import net.floodlightcontroller.forwarding.Forwarding;
 import net.floodlightcontroller.jython.Server;
 import net.floodlightcontroller.packet.Ethernet;
@@ -174,7 +173,6 @@ public class Controller
     protected Forwarding forwarding;
     protected OFMessageFilterManager messageFilterManager;
     protected PktinProcessingTime pktinProcTime;
-    protected FlowCache flowCacheManager;
     private StaticFlowEntryPusher staticFlowEntryPusher;
     protected long ptWarningThresholdInNano;
     
@@ -1439,7 +1437,6 @@ public class Controller
         counterStore = new CounterStore();
         pktinProcTime = new PktinProcessingTime();
         routingEngine = new RoutingImpl();
-        flowCacheManager = new FlowCache();
         initStorageSource();
         
         topology.setFloodlightProvider(this);
@@ -1502,7 +1499,6 @@ public class Controller
         forwarding.setDeviceManager(deviceManager);
         forwarding.setRoutingEngine(routingEngine);
         forwarding.setTopology(topology);
-        forwarding.setFlowCacheMgr(flowCacheManager);
     }
     
     /**
diff --git a/src/main/java/net/floodlightcontroller/flowcache/FlowCache.java b/src/main/java/net/floodlightcontroller/flowcache/FlowCache.java
deleted file mode 100644
index c4b8881f7..000000000
--- a/src/main/java/net/floodlightcontroller/flowcache/FlowCache.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * 
- */
-package net.floodlightcontroller.flowcache;
-
-import org.openflow.protocol.OFFlowMod;
-import org.openflow.protocol.OFMatch;
-
-
-/**
- * @author subrata
- *
- */
-public class FlowCache {
-
-    public int     hitCnt;
-    public boolean flowCacheServiceOn;
-
-    // Constructor
-    public FlowCache() {
-        flowCacheServiceOn = false;
-    }
-
-    public boolean isFlowCacheServiceOn() {
-        return flowCacheServiceOn;
-    }
-
-    public void setFlowCacheServiceOn(boolean flowCacheServiceOn) {
-        this.flowCacheServiceOn = flowCacheServiceOn;
-    }
-
-    public int getHitCnt() {
-        return hitCnt;
-    }
-
-    public boolean addFlow(String applInst, OFMatch ofm, Long cookie,
-            short priority, byte action) {
-        hitCnt++;
-        return true;
-    }
-
-    public boolean addFlow(String string, OFFlowMod fm) {
-        hitCnt++;
-        return true;
-    }
-
-    public void startUp() {
-        // Service is off by default
-        flowCacheServiceOn = false;
-    }
-
-    public void shutDown() {
-        flowCacheServiceOn = false;
-    }
-}
diff --git a/src/main/java/net/floodlightcontroller/forwarding/Forwarding.java b/src/main/java/net/floodlightcontroller/forwarding/Forwarding.java
index 7fa76f2f9..373daec06 100644
--- a/src/main/java/net/floodlightcontroller/forwarding/Forwarding.java
+++ b/src/main/java/net/floodlightcontroller/forwarding/Forwarding.java
@@ -56,13 +56,14 @@ public class Forwarding extends ForwardingBase {
             // For now we treat multicast as broadcast
             doFlood(sw, pi, cntx);
         } else {
-            doForwardFlow(sw, pi, cntx);
+            doForwardFlow(sw, pi, cntx, false);
         }
         
         return Command.CONTINUE;
     }
     
-    protected void doForwardFlow(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx) {    
+    protected void doForwardFlow(IOFSwitch sw, OFPacketIn pi, 
+                FloodlightContext cntx, boolean reqeustFlowRemovedNotifn) {    
         OFMatch match = new OFMatch();
         match.loadFromPacket(pi.getPacketData(), pi.getInPort(), sw.getId());
 
@@ -153,7 +154,7 @@ public class Forwarding extends ForwardingBase {
                             }
                             pushRoute(route, match, 0,
                                       srcDap.getSwitchPort(), dstDap.getSwitchPort(), bufferId,
-                                      sw, pi, cntx);
+                                      sw, pi, cntx, reqeustFlowRemovedNotifn);
                         }
                     }
                     iSrcDaps++;
diff --git a/src/main/java/net/floodlightcontroller/routing/ForwardingBase.java b/src/main/java/net/floodlightcontroller/routing/ForwardingBase.java
index fc739318c..4245607b4 100644
--- a/src/main/java/net/floodlightcontroller/routing/ForwardingBase.java
+++ b/src/main/java/net/floodlightcontroller/routing/ForwardingBase.java
@@ -33,7 +33,6 @@ import net.floodlightcontroller.devicemanager.Device;
 import net.floodlightcontroller.devicemanager.DeviceNetworkAddress;
 import net.floodlightcontroller.devicemanager.IDeviceManager;
 import net.floodlightcontroller.devicemanager.IDeviceManagerAware;
-import net.floodlightcontroller.flowcache.FlowCache;
 import net.floodlightcontroller.packet.Ethernet;
 import net.floodlightcontroller.routing.IRoutingEngine;
 import net.floodlightcontroller.routing.IRoutingDecision;
@@ -65,7 +64,6 @@ public abstract class ForwardingBase implements IOFMessageListener, IDeviceManag
     protected IDeviceManager deviceManager;
     protected IRoutingEngine routingEngine;
     protected ITopology topology;
-    protected FlowCache flowCacheMgr;
     protected CounterStore counterStore;
     
     // flow-mod - for use in the cookie
@@ -143,10 +141,11 @@ public abstract class ForwardingBase implements IOFMessageListener, IDeviceManag
     public boolean pushRoute(Route route, OFMatch match, Integer wildcard_hints,
             SwitchPortTuple srcSwPort,
             SwitchPortTuple dstSwPort, int bufferId,
-            IOFSwitch srcSwitch, OFPacketIn pi, FloodlightContext cntx) {
+            IOFSwitch srcSwitch, OFPacketIn pi, FloodlightContext cntx,
+            boolean reqeustFlowRemovedNotifn) {
         long cookie = AppCookie.makeCookie(FORWARDING_APP_ID, 0);
         return pushRoute(route, match, wildcard_hints, srcSwPort, dstSwPort, 
-                bufferId, srcSwitch, pi, cookie, cntx);
+                bufferId, srcSwitch, pi, cookie, cntx, reqeustFlowRemovedNotifn);
     }
     
     /**
@@ -163,7 +162,8 @@ public abstract class ForwardingBase implements IOFMessageListener, IDeviceManag
                           SwitchPortTuple srcSwPort,
                           SwitchPortTuple dstSwPort, int bufferId,
                           IOFSwitch srcSwitch, OFPacketIn pi, long cookie, 
-                          FloodlightContext cntx) {
+                          FloodlightContext cntx,
+                          boolean reqeustFlowRemovedNotifn) {
         
         boolean srcSwitchIncluded = false;
         OFFlowMod fm = (OFFlowMod) floodlightProvider.getOFMessageFactory().getMessage(OFType.FLOW_MOD);
@@ -235,7 +235,7 @@ public abstract class ForwardingBase implements IOFMessageListener, IDeviceManag
         // Set the flag to request flow-mod removal notifications only for the 
         // source switch. The removal message is used to maintain the flow
         // cache. Don't set the flag for ARP messages - TODO generalize check
-        if ((flowCacheMgr.isFlowCacheServiceOn()) &&
+        if ((reqeustFlowRemovedNotifn) &&
             (match.getDataLayerType() != Ethernet.TYPE_ARP)) {
             fm.setFlags(OFFlowMod.OFPFF_SEND_FLOW_REM);
             match.setWildcards(fm.getMatch().getWildcards());
@@ -387,14 +387,6 @@ public abstract class ForwardingBase implements IOFMessageListener, IDeviceManag
         this.counterStore = counterStore;
     }
 
-    public FlowCache getFlowCacheMgr() {
-        return flowCacheMgr;
-    }
-
-    public void setFlowCacheMgr(FlowCache flowCacheMgr) {
-        this.flowCacheMgr = flowCacheMgr;
-    }
-
     @Override
     public void deviceAdded(Device device) {
         // NOOP
diff --git a/src/test/java/net/floodlightcontroller/forwarding/ForwardingTest.java b/src/test/java/net/floodlightcontroller/forwarding/ForwardingTest.java
index bd4d43dd4..63e2a05f2 100644
--- a/src/test/java/net/floodlightcontroller/forwarding/ForwardingTest.java
+++ b/src/test/java/net/floodlightcontroller/forwarding/ForwardingTest.java
@@ -48,7 +48,6 @@ import net.floodlightcontroller.routing.Route;
 import net.floodlightcontroller.test.FloodlightTestCase;
 import net.floodlightcontroller.topology.ITopology;
 import net.floodlightcontroller.topology.SwitchPortTuple;
-import net.floodlightcontroller.flowcache.FlowCache;
 import net.floodlightcontroller.forwarding.Forwarding;
 
 import org.easymock.Capture;
@@ -96,8 +95,6 @@ public class ForwardingTest extends FloodlightTestCase {
         forwarding.setDeviceManager(deviceManager);
         forwarding.setRoutingEngine(routingEngine);
         forwarding.setTopology(topology);
-        FlowCache flowCache = new FlowCache();
-        forwarding.setFlowCacheMgr(flowCache);
 
         // Mock switches
         sw1 = EasyMock.createNiceMock(IOFSwitch.class);
-- 
GitLab