From 1c51ce0f7c7bde8c572435ce393a31287189772b Mon Sep 17 00:00:00 2001 From: Kanzhe Jiang <kanzhe.jiang@bigswitch.com> Date: Wed, 25 Jul 2012 15:28:52 -0700 Subject: [PATCH] BSC-1892 and BSC-1891 --- .../flowcache/FCQueryObj.java | 32 +++++-- .../flowcache/FlowCacheQueryResp.java | 15 ++-- .../flowcache/FlowReconcileManager.java | 14 +-- .../flowcache/IFlowCacheService.java | 90 ------------------- .../flowcache/IFlowReconcileService.java | 10 ++- .../flowcache/FlowReconcileMgrTest.java | 13 +-- 6 files changed, 51 insertions(+), 123 deletions(-) diff --git a/src/main/java/net/floodlightcontroller/flowcache/FCQueryObj.java b/src/main/java/net/floodlightcontroller/flowcache/FCQueryObj.java index 058820b40..f78aaaeed 100644 --- a/src/main/java/net/floodlightcontroller/flowcache/FCQueryObj.java +++ b/src/main/java/net/floodlightcontroller/flowcache/FCQueryObj.java @@ -4,7 +4,6 @@ import java.util.Arrays; import net.floodlightcontroller.devicemanager.IDevice; import net.floodlightcontroller.flowcache.IFlowCacheService.FCQueryEvType; -import net.floodlightcontroller.flowcache.IFlowCacheService.FCQueryType; /** @@ -14,8 +13,6 @@ public class FCQueryObj { /** The caller of the flow cache query. */ public IFlowQueryHandler fcQueryHandler; - /** The query type. */ - public FCQueryType queryType; /** The application instance name. */ public String applInstName; /** The vlan Id. */ @@ -36,14 +33,37 @@ public class FCQueryObj { /** * Instantiates a new flow cache query object */ - public FCQueryObj() { - queryType = FCQueryType.UNKNOWN; + public FCQueryObj(IFlowQueryHandler fcQueryHandler, + String applInstName, + Short vlan, + IDevice srcDevice, + IDevice dstDevice, + String callerName, + FCQueryEvType evType, + Object callerOpaqueObj) { + this.fcQueryHandler = fcQueryHandler; + this.applInstName = applInstName; + this.srcDevice = srcDevice; + this.dstDevice = dstDevice; + this.callerName = callerName; + this.evType = evType; + this.callerOpaqueObj = callerOpaqueObj; + + if (vlan != null) { + this.vlans = new Short[] { vlan }; + } else { + if (srcDevice != null) { + this.vlans = srcDevice.getVlanId(); + } else if (dstDevice != null) { + this.vlans = dstDevice.getVlanId(); + } + } } @Override public String toString() { return "FCQueryObj [fcQueryCaller=" + fcQueryHandler - + ", queryType=" + queryType + ", applInstName=" + + ", applInstName=" + applInstName + ", vlans=" + Arrays.toString(vlans) + ", dstDevice=" + dstDevice + ", srcDevice=" + srcDevice + ", callerName=" + callerName + ", evType=" diff --git a/src/main/java/net/floodlightcontroller/flowcache/FlowCacheQueryResp.java b/src/main/java/net/floodlightcontroller/flowcache/FlowCacheQueryResp.java index cb15ee6bb..b01aedfe9 100644 --- a/src/main/java/net/floodlightcontroller/flowcache/FlowCacheQueryResp.java +++ b/src/main/java/net/floodlightcontroller/flowcache/FlowCacheQueryResp.java @@ -16,6 +16,12 @@ public class FlowCacheQueryResp { * query. */ public boolean moreFlag; + + /** + * Set to true if the response has been sent to handler + */ + public boolean hasSent; + /** * The flow list. If there are large number of flows to be returned * then they may be returned in multiple callbacks. @@ -32,6 +38,7 @@ public class FlowCacheQueryResp { qrFlowCacheObjList = new ArrayList<QRFlowCacheObj>(); queryObj = query; moreFlag = false; + hasSent = false; } /* (non-Javadoc) @@ -39,12 +46,8 @@ public class FlowCacheQueryResp { */ @Override public String toString() { - String s = queryObj.toString(); - if (moreFlag) { - s += "; moreFlasg=True"; - } else { - s += "; moreFlag=False"; - } + String s = queryObj.toString() + "; moreFlasg=" + moreFlag + + "; hasSent=" + hasSent; s += "; FlowCount=" + Integer.toString(qrFlowCacheObjList.size()); return s; } diff --git a/src/main/java/net/floodlightcontroller/flowcache/FlowReconcileManager.java b/src/main/java/net/floodlightcontroller/flowcache/FlowReconcileManager.java index f977dbc3e..e48f3adcc 100644 --- a/src/main/java/net/floodlightcontroller/flowcache/FlowReconcileManager.java +++ b/src/main/java/net/floodlightcontroller/flowcache/FlowReconcileManager.java @@ -33,10 +33,6 @@ public class FlowReconcileManager * need to be reconciled with the current configuration of the controller. */ protected ListenerDispatcher<OFType, IFlowReconcileListener> flowReconcileListeners; - - public OFMatchReconcile newOFMatchReconcile() { - return new OFMatchReconcile(); - } @Override public synchronized void addFlowReconcileListener(IFlowReconcileListener listener) { @@ -89,19 +85,23 @@ public class FlowReconcileManager } @Override - public void updateFlowForDestinationDevice(IDevice device, FCQueryEvType fcEvType){ + public void updateFlowForDestinationDevice(IDevice device, + IFlowQueryHandler handler, + FCQueryEvType fcEvType) { // NO-OP } @Override - public void updateFlowForSourceDevice(IDevice device, FCQueryEvType fcEvType){ + public void updateFlowForSourceDevice(IDevice device, + IFlowQueryHandler handler, + FCQueryEvType fcEvType) { // NO-OP } @Override public void flowQueryGenericHandler(FlowCacheQueryResp flowResp) { if (flowResp.queryObj.evType != FCQueryEvType.GET) { - OFMatchReconcile ofmRc = newOFMatchReconcile(); + OFMatchReconcile ofmRc = new OFMatchReconcile();; /* Re-provision these flows */ for (QRFlowCacheObj entry : flowResp.qrFlowCacheObjList) { /* reconcile the flows in entry */ diff --git a/src/main/java/net/floodlightcontroller/flowcache/IFlowCacheService.java b/src/main/java/net/floodlightcontroller/flowcache/IFlowCacheService.java index ad4890412..8e44ed330 100644 --- a/src/main/java/net/floodlightcontroller/flowcache/IFlowCacheService.java +++ b/src/main/java/net/floodlightcontroller/flowcache/IFlowCacheService.java @@ -6,7 +6,6 @@ import net.floodlightcontroller.core.FloodlightContext; import net.floodlightcontroller.core.FloodlightContextStore; import net.floodlightcontroller.core.IOFSwitch; import net.floodlightcontroller.devicemanager.SwitchPort; -import net.floodlightcontroller.devicemanager.IDevice; import net.floodlightcontroller.core.module.IFloodlightService; /** @@ -26,18 +25,6 @@ public interface IFlowCacheService extends IFloodlightService { "net.floodlightcontroller.flowcache.appName"; public static final String FLOWCACHE_APP_INSTANCE_NAME = "net.floodlightcontroller.flowcache.appInstanceName"; - - /** - * The Enum FCQueryType. - */ - public enum FCQueryType { - APPLINSTNAME, // The APPLINSTNAME. - APPLINSTNAME_VLAN, // The APPLINSTNAM e_ vlan. - ALLAPP_DESTDEVICE, // The destdevice for all application. - ALLAPP_SRCDEVICE, // The source device for all application. - ALLAPP_SRCDEVICE_DESTDEVICE, // The APPLINSTNAM srcdevic destdevice. - UNKNOWN, // The UNKNOWN. - } /** * The flow cache query event type indicating the event that triggered the @@ -97,71 +84,6 @@ public interface IFlowCacheService extends IFloodlightService { */ public void submitFlowCacheQuery(FCQueryObj query); - /** - * Get a new flow cache query object populated with the supplied parameters. - * The query type field id populated automatically based on the parameters - * passed. - * - * @param fcQueryCaller the caller of this API - * @param applInstName the application instance name - * @param callerOpaqueData opaque data passed by the caller which is - * returned unchanged in the corresponding callback. - * @return a new initialized flow cache query object - */ - public FCQueryObj newFCQueryObj(IFlowQueryHandler fcQueryHandler, - String applInstName, - String callerName, - FCQueryEvType evType, - Object callerOpaqueObj); - - /** - * Get a new flow cache query object populated with the supplied parameters. - * The query type field id populated automatically based on the parameters - * passed. - * - * @param fcQueryCaller the caller of this API - * @param applInstName the application instance name - * @param vlan VLAN ID - * @param callerOpaqueData opaque data passed by the caller which is - * returned unchanged in the corresponding callback. - * @return a new initialized flow cache query object - */ - public FCQueryObj newFCQueryObj(IFlowQueryHandler fcQueryHandler, - String applInstName, - short vlan, - String callerName, - FCQueryEvType evType, - Object callerOpaqueObj); - - /** - * Get a new flow cache query object populated with the supplied parameters. - * The query type field id populated automatically based on the parameters - * passed. - * - * @param fcQueryCaller the caller of this API - * @param applInstName the application instance name - * @param srcDevice source device object - * @param dstDevice destination device object - * @param callerOpaqueData opaque data passed by the caller which is - * returned unchanged in the corresponding callback. - * @return a new initialized flow cache query object - */ - public FCQueryObj newFCQueryObj(IFlowQueryHandler fcQueryHandler, - IDevice srcDevice, - IDevice dstDevice, - String callerName, - FCQueryEvType evType, - Object callerOpaqueObj); - - /** - * Get a new flow cache query object populated with the supplied parameters. - * The query type field id populated automatically based on the parameters - * passed. - * - * @return a new uninitialized flow cache query object - */ - public FCQueryObj newFCQueryObj(); - /** * Deactivates all flows in the flow cache for which the source switch * matches the given switchDpid. Note that the flows are NOT deleted @@ -245,18 +167,6 @@ public interface IFlowCacheService extends IFloodlightService { */ public boolean moveFlowToDifferentApplInstName(OFMatchReconcile ofMRc); - /** - * Move all the flows from their current application instance to a - * different application instance. This API can be used when all flows in - * an application instance move to a different application instance when - * the application instance configuration changes. - * - * @param curApplInstName current application instance name - * @param newApplInstName new application instance name - */ - public void moveFlowToDifferentApplInstName(String curApplInstName, - String newApplInstName); - /** * Delete all flow from the specified switch * @param sw diff --git a/src/main/java/net/floodlightcontroller/flowcache/IFlowReconcileService.java b/src/main/java/net/floodlightcontroller/flowcache/IFlowReconcileService.java index 387c7d57c..f48c4e085 100644 --- a/src/main/java/net/floodlightcontroller/flowcache/IFlowReconcileService.java +++ b/src/main/java/net/floodlightcontroller/flowcache/IFlowReconcileService.java @@ -43,10 +43,13 @@ public interface IFlowReconcileService extends IFloodlightService { * new attachment point * * @param device device that has moved + * @param handler handler to process the flows * @param fcEvType Event type that triggered the update * */ - public void updateFlowForDestinationDevice(IDevice device, FCQueryEvType fcEvType); + public void updateFlowForDestinationDevice(IDevice device, + IFlowQueryHandler handler, + FCQueryEvType fcEvType); /** * Updates the flows from a device @@ -56,10 +59,13 @@ public interface IFlowReconcileService extends IFloodlightService { * new attachment point * * @param device device where the flow originates + * @param handler handler to process the flows * @param fcEvType Event type that triggered the update * */ - public void updateFlowForSourceDevice(IDevice device, FCQueryEvType fcEvType); + public void updateFlowForSourceDevice(IDevice device, + IFlowQueryHandler handler, + FCQueryEvType fcEvType); /** * Generic flow query handler to insert FlowMods into the reconcile pipeline. diff --git a/src/test/java/net/floodlightcontroller/flowcache/FlowReconcileMgrTest.java b/src/test/java/net/floodlightcontroller/flowcache/FlowReconcileMgrTest.java index 542b9ccb5..fcf8e6798 100644 --- a/src/test/java/net/floodlightcontroller/flowcache/FlowReconcileMgrTest.java +++ b/src/test/java/net/floodlightcontroller/flowcache/FlowReconcileMgrTest.java @@ -18,17 +18,6 @@ import org.junit.Test; import org.openflow.protocol.OFStatisticsRequest; import org.openflow.protocol.OFType; -/** - * The Class FlowCacheTest. Tests flow cache operations for - * (a) adding a flow to the flow cache when flow mod is programmed - * (b) Deleting a flow from flow cache when flow mod removal mesg is received - * (c) Reprogramming a flow based on flows queried from flow cache when a - * device is moved. - * (d) Reprogramming a flow based on flows queried from flow cache when a - * link goes down. - * - * @author subrata - */ public class FlowReconcileMgrTest extends FloodlightTestCase { protected MockFloodlightProvider mockFloodlightProvider; @@ -81,7 +70,7 @@ public class FlowReconcileMgrTest extends FloodlightTestCase { flowReconcileMgr.addFlowReconcileListener(r2); flowReconcileMgr.addFlowReconcileListener(r3); - OFMatchReconcile ofmRcIn = flowReconcileMgr.newOFMatchReconcile(); + OFMatchReconcile ofmRcIn = new OFMatchReconcile(); try { flowReconcileMgr.reconcileFlow(ofmRcIn); } catch (RuntimeException e) { -- GitLab