From: Kalvin Hom Date: Mon, 22 Apr 2013 18:47:02 +0000 (-0700) Subject: Split ForwardingRulesManager into X-Git-Tag: releasepom-0.1.0~542 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=30c334b11097201c8f8a68263bc01efb869c778b Split ForwardingRulesManager into API and Implementation Bundles Change-Id: I8137aedbbcefe3ed8f17b032cf81830d39f96e32 Signed-off-by: Kalvin Hom --- diff --git a/opendaylight/distribution/opendaylight/pom.xml b/opendaylight/distribution/opendaylight/pom.xml index 8a74689398..f05c95bb8c 100644 --- a/opendaylight/distribution/opendaylight/pom.xml +++ b/opendaylight/distribution/opendaylight/pom.xml @@ -40,7 +40,8 @@ ../../configuration/implementation ../../routing/dijkstra_implementation ../../arphandler - ../../forwardingrulesmanager + ../../forwardingrulesmanager/api + ../../forwardingrulesmanager/implementation ../../hosttracker ../../containermanager/api ../../containermanager/implementation diff --git a/opendaylight/forwardingrulesmanager/pom.xml b/opendaylight/forwardingrulesmanager/api/pom.xml similarity index 92% rename from opendaylight/forwardingrulesmanager/pom.xml rename to opendaylight/forwardingrulesmanager/api/pom.xml index 27c3b1ecc1..6b639e3c63 100644 --- a/opendaylight/forwardingrulesmanager/pom.xml +++ b/opendaylight/forwardingrulesmanager/api/pom.xml @@ -6,7 +6,7 @@ org.opendaylight.controller commons.opendaylight 1.4.0-SNAPSHOT - ../commons/opendaylight + ../../commons/opendaylight org.opendaylight.controller @@ -49,12 +49,9 @@ org.eclipse.osgi.framework.console, org.osgi.framework - - org.opendaylight.controller.forwardingrulesmanager.internal.Activator - - + org.opendaylight.controller.hosttracker - + diff --git a/opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowConfig.java b/opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowConfig.java similarity index 94% rename from opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowConfig.java rename to opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowConfig.java index bf5062985d..b11b5f3dbc 100644 --- a/opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowConfig.java +++ b/opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowConfig.java @@ -1,4 +1,3 @@ - /* * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. * @@ -76,8 +75,8 @@ public class FlowConfig implements Serializable { private String status; /* - * The order of the object data defined below is used directly in the UI built using JSP. - * Hence try to keep the order in a more logical way. + * The order of the object data defined below is used directly in the UI + * built using JSP. Hence try to keep the order in a more logical way. */ @XmlElement private String installInHw; @@ -216,14 +215,14 @@ public class FlowConfig implements Serializable { public void setInstallInHw(boolean inHw) { installInHw = inHw ? "true" : "false"; } - + public String getInstallInHw() { - return installInHw; + return installInHw; } public boolean isInternalFlow() { // Controller generated static flows have name starting with "**" - return (this.name != null && this.name.startsWith("**")); + return (this.name != null && this.name.startsWith("**")); } public String getName() { @@ -608,14 +607,14 @@ public class FlowConfig implements Serializable { } } - log.debug("Get Nexthop address = {} Type = {}", address, setNHType.toString()); + log.debug("Get Nexthop address = " + address + " Type = " + + setNHType.toString()); if (setNHType == SetNextHopType.RESOLVE_L2RW) { try { return InetAddress.getByName(address); } catch (Exception e) { - log - .debug("Exception during nextHopAddress resolution : ", - e); + log.debug("Exception during nextHopAddress resolution : " + + e.getMessage()); } } } @@ -641,10 +640,9 @@ public class FlowConfig implements Serializable { .compile("([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}"); Matcher mm = macPattern.matcher(mac); if (!mm.matches()) { - log - .debug( - "Ethernet address {} is not valid. Example: 00:05:b9:7c:81:5f", - mac); + log.debug( + "Ethernet address {} is not valid. Example: 00:05:b9:7c:81:5f", + mac); return false; } return true; @@ -657,8 +655,7 @@ public class FlowConfig implements Serializable { } if (sw == null) { - log - .debug("switch info is not available. Skip checking if port is part of a switch or not."); + log.debug("switch info is not available. Skip checking if port is part of a switch or not."); return true; } @@ -713,11 +710,11 @@ public class FlowConfig implements Serializable { // Check against each container's flow Flow flow = this.getFlow(); - // Configuration is rejected if it conflicts with _all_ the container flows + // Configuration is rejected if it conflicts with _all_ the container + // flows for (ContainerFlow cFlow : cFlowList) { if (cFlow.allowsFlow(flow)) { - log - .trace("Config is congruent with at least one container flow"); + log.trace("Config is congruent with at least one container flow"); return false; } } @@ -756,8 +753,7 @@ public class FlowConfig implements Serializable { } } if (sw == null) { - resultStr - .append(String.format("Node %s not found", node)); + resultStr.append(String.format("Node %s not found", node)); return false; } } else { @@ -783,8 +779,7 @@ public class FlowConfig implements Serializable { if (isPortValid(sw, port) == false) { resultStr .append(String - .format( - "Ingress port %d is not valid for the Switch", + .format("Ingress port %d is not valid for the Switch", port)); if ((container != null) && !container.getName().equals( @@ -843,8 +838,7 @@ public class FlowConfig implements Serializable { if ((dlSrc != null) && !isL2AddressValid(dlSrc)) { resultStr .append(String - .format( - "Ethernet source address %s is not valid. Example: 00:05:b9:7c:81:5f", + .format("Ethernet source address %s is not valid. Example: 00:05:b9:7c:81:5f", dlSrc)); return false; } @@ -852,8 +846,7 @@ public class FlowConfig implements Serializable { if ((dlDst != null) && !isL2AddressValid(dlDst)) { resultStr .append(String - .format( - "Ethernet destination address %s is not valid. Example: 00:05:b9:7c:81:5f", + .format("Ethernet destination address %s is not valid. Example: 00:05:b9:7c:81:5f", dlDst)); return false; } @@ -929,8 +922,7 @@ public class FlowConfig implements Serializable { if (isPortValid(sw, port) == false) { resultStr .append(String - .format( - "Output port %d is not valid for this switch", + .format("Output port %d is not valid for this switch", port)); if ((container != null) && !container.getName().equals( @@ -965,8 +957,8 @@ public class FlowConfig implements Serializable { if (sstr.matches()) { if (!NetUtils.isIPv4AddressValid(sstr.group(1))) { resultStr.append(String.format( - "IP source address %s is not valid", sstr - .group(1))); + "IP source address %s is not valid", + sstr.group(1))); return false; } continue; @@ -1007,8 +999,7 @@ public class FlowConfig implements Serializable { && !isVlanPriorityValid(sstr.group(1))) { resultStr .append(String - .format( - "Vlan priority %s is not in the range 0 - 7", + .format("Vlan priority %s is not in the range 0 - 7", sstr.group(1))); return false; } @@ -1023,8 +1014,7 @@ public class FlowConfig implements Serializable { && !isL2AddressValid(sstr.group(1))) { resultStr .append(String - .format( - "Ethernet source address %s is not valid. Example: 00:05:b9:7c:81:5f", + .format("Ethernet source address %s is not valid. Example: 00:05:b9:7c:81:5f", sstr.group(1))); return false; } @@ -1039,8 +1029,7 @@ public class FlowConfig implements Serializable { && !isL2AddressValid(sstr.group(1))) { resultStr .append(String - .format( - "Ethernet destination address %s is not valid. Example: 00:05:b9:7c:81:5f", + .format("Ethernet destination address %s is not valid. Example: 00:05:b9:7c:81:5f", sstr.group(1))); return false; } @@ -1055,8 +1044,7 @@ public class FlowConfig implements Serializable { && !isTOSBitsValid(sstr.group(1))) { resultStr .append(String - .format( - "IP ToS bits %s is not in the range 0 - 63", + .format("IP ToS bits %s is not in the range 0 - 63", sstr.group(1))); return false; } @@ -1085,8 +1073,7 @@ public class FlowConfig implements Serializable { && !isTpPortValid(sstr.group(1))) { resultStr .append(String - .format( - "Transport destination port %s is not valid", + .format("Transport destination port %s is not valid", sstr.group(1))); return false; } @@ -1115,8 +1102,8 @@ public class FlowConfig implements Serializable { return false; } } catch (NumberFormatException e) { - resultStr.append(String.format("Invalid number format %s", e - .getMessage())); + resultStr.append(String.format("Invalid number format %s", + e.getMessage())); return false; } @@ -1124,25 +1111,26 @@ public class FlowConfig implements Serializable { } public FlowEntry getFlowEntry() { - return new FlowEntry(FlowConfig.staticFlowsGroup, this.name, this - .getFlow(), this.getNode()); + return new FlowEntry(FlowConfig.staticFlowsGroup, this.name, + this.getFlow(), this.getNode()); } public Flow getFlow() { Match match = new Match(); if (this.ingressPort != null) { - match.setField(MatchType.IN_PORT, NodeConnectorCreator - .createOFNodeConnector(Short.parseShort(ingressPort), - getNode())); + match.setField( + MatchType.IN_PORT, + NodeConnectorCreator.createOFNodeConnector( + Short.parseShort(ingressPort), getNode())); } if (this.dlSrc != null) { - match.setField(MatchType.DL_SRC, HexEncode - .bytesFromHexString(this.dlSrc)); + match.setField(MatchType.DL_SRC, + HexEncode.bytesFromHexString(this.dlSrc)); } if (this.dlDst != null) { - match.setField(MatchType.DL_DST, HexEncode - .bytesFromHexString(this.dlDst)); + match.setField(MatchType.DL_DST, + HexEncode.bytesFromHexString(this.dlDst)); } if (this.etherType != null) { match.setField(MatchType.DL_TYPE, Integer.decode(etherType) @@ -1152,8 +1140,8 @@ public class FlowConfig implements Serializable { match.setField(MatchType.DL_VLAN, Short.parseShort(this.vlanId)); } if (this.vlanPriority != null) { - match.setField(MatchType.DL_VLAN_PR, Byte - .parseByte(this.vlanPriority)); + match.setField(MatchType.DL_VLAN_PR, + Byte.parseByte(this.vlanPriority)); } if (this.nwSrc != null) { String parts[] = this.nwSrc.split("/"); @@ -1178,8 +1166,8 @@ public class FlowConfig implements Serializable { match.setField(MatchType.NW_DST, ip, mask); } if (this.protocol != null) { - match.setField(MatchType.NW_PROTO, IPProtocols - .getProtocolNumberByte(this.protocol)); + match.setField(MatchType.NW_PROTO, + IPProtocols.getProtocolNumberByte(this.protocol)); } if (this.tosBits != null) { match.setField(MatchType.NW_TOS, Byte.parseByte(this.tosBits)); @@ -1246,9 +1234,9 @@ public class FlowConfig implements Serializable { } /* - * Parses the actions string and return the List of SAL Action - * No syntax check run, as this function will be called when the - * config validation check has already been performed + * Parses the actions string and return the List of SAL Action No syntax + * check run, as this function will be called when the config validation + * check has already been performed */ private List getActionList() { List actionList = new ArrayList(); @@ -1265,8 +1253,8 @@ public class FlowConfig implements Serializable { if (n.group(1) != null) { short ofPort = Short.parseShort(n.group(1)); actionList.add(new Output(NodeConnectorCreator - .createOFNodeConnector(ofPort, this - .getNode()))); + .createOFNodeConnector(ofPort, + this.getNode()))); } } } @@ -1319,8 +1307,8 @@ public class FlowConfig implements Serializable { ActionType.SET_VLAN_ID.toString() + "=(.*)").matcher( actiongrp); if (sstr.matches()) { - actionList.add(new SetVlanId(Short - .parseShort(sstr.group(1)))); + actionList.add(new SetVlanId( + Short.parseShort(sstr.group(1)))); continue; } diff --git a/opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowEntry.java b/opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowEntry.java similarity index 89% rename from opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowEntry.java rename to opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowEntry.java index aaf34a6a3f..091ebb0d3a 100644 --- a/opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowEntry.java +++ b/opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowEntry.java @@ -1,4 +1,3 @@ - /* * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. * @@ -22,10 +21,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Represents a flow applications request Forwarding Rules Manager to install - * on a network node. A FlowEntry is constituted of a flow (match + actions), - * the target network node, and the flow name. It also includes a group name. - * For instance the flows constituting a policy all share the same group name. + * Represents a flow applications request Forwarding Rules Manager to install on + * a network node. A FlowEntry is constituted of a flow (match + actions), the + * target network node, and the flow name. It also includes a group name. For + * instance the flows constituting a policy all share the same group name. */ public class FlowEntry implements Cloneable, Serializable { protected static final Logger logger = LoggerFactory @@ -54,7 +53,7 @@ public class FlowEntry implements Cloneable, Serializable { /** * Return the actual Flow contained in this entry - * + * * @return the flow */ public Flow getFlow() { @@ -115,13 +114,12 @@ public class FlowEntry implements Cloneable, Serializable { /** * Merges the current Flow with the passed Container Flow - * - * Note: Container Flow merging is not an injective function. - * Be m1 and m2 two different matches, and be f() the flow merge - * function, such that y1 = f(m1) and y2 = f(m2) are the two merged - * matches, we may have: y1 = y2 - * - * + * + * Note: Container Flow merging is not an injective function. Be m1 and m2 + * two different matches, and be f() the flow merge function, such that y1 = + * f(m1) and y2 = f(m2) are the two merged matches, we may have: y1 = y2 + * + * * @param containerFlow * @return this merged FlowEntry */ diff --git a/opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowEntryInstall.java b/opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowEntryInstall.java similarity index 88% rename from opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowEntryInstall.java rename to opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowEntryInstall.java index ac0a4cccd4..dfe331ad5f 100644 --- a/opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowEntryInstall.java +++ b/opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowEntryInstall.java @@ -1,4 +1,3 @@ - /* * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. * @@ -15,15 +14,15 @@ import org.opendaylight.controller.sal.core.ContainerFlow; import org.opendaylight.controller.sal.core.Node; /** - * The flow database object representing the flow entry to install on - * the network node. It contains the original flow entry FRM was - * requested to install, the container flow with which that entry had - * to be merged and the resultant merged flow entry, which is the - * one that was eventually installed on the network node - * - * Note: If the container flow is null, the install entry will be a clone - * of the original entry - * + * The flow database object representing the flow entry to install on the + * network node. It contains the original flow entry FRM was requested to + * install, the container flow with which that entry had to be merged and the + * resultant merged flow entry, which is the one that was eventually installed + * on the network node + * + * Note: If the container flow is null, the install entry will be a clone of the + * original entry + * */ public class FlowEntryInstall { private FlowEntry original; diff --git a/opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/IForwardingRulesManager.java b/opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/IForwardingRulesManager.java similarity index 57% rename from opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/IForwardingRulesManager.java rename to opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/IForwardingRulesManager.java index 60d74295ee..d0efe4a83f 100644 --- a/opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/IForwardingRulesManager.java +++ b/opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/IForwardingRulesManager.java @@ -1,4 +1,3 @@ - /* * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. * @@ -19,42 +18,46 @@ import org.opendaylight.controller.sal.utils.Status; /** * Interface that describes methods for installing or removing forwarding rules * and to access to the flows database. - * + * */ public interface IForwardingRulesManager { /** - * It requests FRM to install the passed Flow Entry. FRM will request - * the SDN protocol plugin to install the flow on the network node. - * Based on the result of this operation FRM will update its database - * accordingly and will return the proper {@code Status} code. + * It requests FRM to install the passed Flow Entry. FRM will request the + * SDN protocol plugin to install the flow on the network node. Based on the + * result of this operation FRM will update its database accordingly and + * will return the proper {@code Status} code. * - * @param flow the flow entry to install - * @return the {@code Status} object indicating the result of this action. - */ + * @param flow + * the flow entry to install + * @return the {@code Status} object indicating the result of this action. + */ public Status installFlowEntry(FlowEntry flow); /** - * It requests FRM to remove the passed Flow Entry. FRM will request - * the SDN protocol plugin to uninstall the flow from the network node. - * Based on the result of this operation FRM will update its database - * accordingly and will return the proper {@code Status} code. + * It requests FRM to remove the passed Flow Entry. FRM will request the SDN + * protocol plugin to uninstall the flow from the network node. Based on the + * result of this operation FRM will update its database accordingly and + * will return the proper {@code Status} code. * - * @param flow the flow entry to uninstall + * @param flow + * the flow entry to uninstall * @return the {@code Status} object indicating the result of this action */ public Status uninstallFlowEntry(FlowEntry flow); /** * It requests FRM to replace the currently installed Flow Entry with the - * new one. It is up to the SDN protocol plugin to decide how to convey - * this message to the network node. It could be a delete + add or a single - * modify message depending on the SDN protocol specifications - * If the current flow is equal to the new one it will be a no op and - * success code is returned. + * new one. It is up to the SDN protocol plugin to decide how to convey this + * message to the network node. It could be a delete + add or a single + * modify message depending on the SDN protocol specifications If the + * current flow is equal to the new one it will be a no op and success code + * is returned. * - * @param current the current flow entry to modify - * @param newone the new flow entry which will replace the current one + * @param current + * the current flow entry to modify + * @param newone + * the new flow entry which will replace the current one * @return the {@code Status} object indicating the result of this action */ public Status modifyFlowEntry(FlowEntry current, FlowEntry newone); @@ -63,15 +66,15 @@ public interface IForwardingRulesManager { * It requests the FRM to replace the currently installed Flow Entry with * the new one. The currently installed entry is derived by the Match * portion of the passed Flow. FRM looks in its database for a previously - * installed FlowEntry which Match equals the Match of the passed Flow. - * If it finds it, it will request the SDN protocol plugin to replace the - * existing flow with the new one on the network node. If it does not - * find it, it will request plugin to add the new flow. If the passed entry - * is not valid an error code is returned. - * If the existing flow is equal to the passed one it will be a no op and - * success code is returned. + * installed FlowEntry which Match equals the Match of the passed Flow. If + * it finds it, it will request the SDN protocol plugin to replace the + * existing flow with the new one on the network node. If it does not find + * it, it will request plugin to add the new flow. If the passed entry is + * not valid an error code is returned. If the existing flow is equal to the + * passed one it will be a no op and success code is returned. * - * @param newone the new flow entry to install + * @param newone + * the new flow entry to install * @return the {@code Status} object indicating the result of this action */ public Status modifyOrAddFlowEntry(FlowEntry newone); @@ -79,64 +82,81 @@ public interface IForwardingRulesManager { /** * Check whether the passed flow entry conflicts with the Container flows * - * @param flow the flow entry to test + * @param flow + * the flow entry to test * @return true if conflicts, false otherwise */ public boolean checkFlowEntryConflict(FlowEntry flow); /** - * Returns the list of Flow entries across network nodes which are part of the - * same flow group, policy - * - * @param group the group name + * Returns the list of Flow entries across network nodes which are part of + * the same flow group, policy + * + * @param group + * the group name * @return the list of flow entries belonging to the specified group */ public List getFlowEntriesForGroup(String group); /** - * Add a list of output port to the flow with the specified name on the specified network node - * - * @param node the network node - * @param flowName the flow name - * @param dstPort the list of ports to be added to the flow output actions + * Add a list of output port to the flow with the specified name on the + * specified network node + * + * @param node + * the network node + * @param flowName + * the flow name + * @param dstPort + * the list of ports to be added to the flow output actions */ public void addOutputPort(Node node, String flowName, List dstPort); /** - * Remove a list of output port from the flow with the specified name on the specified network node - * - * @param node the network node - * @param flowName the flow name - * @param dstPortthe list of ports to be removed from the flow output actions + * Remove a list of output port from the flow with the specified name on the + * specified network node + * + * @param node + * the network node + * @param flowName + * the flow name + * @param dstPortthe + * list of ports to be removed from the flow output actions */ public void removeOutputPort(Node node, String flowName, List dstPort); /** - * Replace the current output port in the specified flow with the specified one - * - * @param node the network node - * @param groupName the group name - * @param flowName the flow name - * @param dstPort the new output action port + * Replace the current output port in the specified flow with the specified + * one + * + * @param node + * the network node + * @param groupName + * the group name + * @param flowName + * the flow name + * @param dstPort + * the new output action port */ public void replaceOutputPort(Node node, String flowName, NodeConnector outPort); /** * Returns the output port configured on the specified flow - * - * @param node the network node - * @param flowName the flow name + * + * @param node + * the network node + * @param flowName + * the flow name * @return the output action port for the specified flow */ public NodeConnector getOutputPort(Node node, String flowName); /** - * Returns all the troubleshooting information that applications - * have set along with the policy they have configured through - * forwarding rules manger. + * Returns all the troubleshooting information that applications have set + * along with the policy they have configured through forwarding rules + * manger. * * @return the collection of troubleshooting objects */ @@ -144,60 +164,69 @@ public interface IForwardingRulesManager { /** * Set the troubleshooting information for the policy - * - * @param policyname the flow group name - * @param o the object containing the troubleshooting information - * @param add true for adding, false for removing + * + * @param policyname + * the flow group name + * @param o + * the object containing the troubleshooting information + * @param add + * true for adding, false for removing */ public void setTSPolicyData(String policyName, Object o, boolean add); /** - * Returns the troubleshooting information that was set for the specified policy + * Returns the troubleshooting information that was set for the specified + * policy * - * @param groupName the flows group name + * @param groupName + * the flows group name * @return the troubleshooting info object */ public Object getTSPolicyData(String policyName); /** - * Returns the specifications of all the flows configured for all the + * Returns the specifications of all the flows configured for all the * switches on the current container - * + * * @return the list of flow configurations present in the database */ public List getStaticFlows(); /** - * Returns the specifications of all the flows configured for - * the given switch on the current container - * - * @param node the network node identifier - * @return the list of {@code FlowConfig} objects + * Returns the specifications of all the flows configured for the given + * switch on the current container + * + * @param node + * the network node identifier + * @return the list of {@code FlowConfig} objects */ public List getStaticFlows(Node node); /** - * Returns the specification of the flow configured for the given - * network node on the current container - * - * @param name the flow name - * @param n the netwrok node identifier + * Returns the specification of the flow configured for the given network + * node on the current container + * + * @param name + * the flow name + * @param n + * the netwrok node identifier * @return the {@code FlowConfig} object */ public FlowConfig getStaticFlow(String name, Node n); /** - * Returns the list of names of flows configured for the given - * Network node on the current container - * - * @param node the network node identifier + * Returns the list of names of flows configured for the given Network node + * on the current container + * + * @param node + * the network node identifier * @return the list of flow names */ public List getStaticFlowNamesForNode(Node node); /** * Returns the list of Node(s) for which a static flow has been configured - * + * * @return the list of network nodes */ public List getListNodeWithConfiguredFlows(); @@ -210,59 +239,70 @@ public interface IForwardingRulesManager { public Status saveConfig(); /** - * Add a flow specified by the {@code FlowConfig} object on the current container + * Add a flow specified by the {@code FlowConfig} object on the current + * container * - * @param config the {@code FlowConfig} object representing the static flow - * @param restore if set to true, the config object validation will be skipped. - * Used only internally, always set it to false. + * @param config + * the {@code FlowConfig} object representing the static flow + * @param restore + * if set to true, the config object validation will be skipped. + * Used only internally, always set it to false. * @return the {@code Status} object indicating the result of this action. */ public Status addStaticFlow(FlowConfig config, boolean restore); /** - * Remove a flow specified by the {@code FlowConfig} object on the current container + * Remove a flow specified by the {@code FlowConfig} object on the current + * container * - * @param config the {@code FlowConfig} object representing the static flow + * @param config + * the {@code FlowConfig} object representing the static flow * @return the {@code Status} object indicating the result of this action */ public Status removeStaticFlow(FlowConfig config); /** - * Replace the flow identified by the {@code FlowConfig.name} name for - * the {@code FlowConfig.node} network node with the new flow specified - * by {@code FlowConfig} object - * - * @param config the {@code FlowConfig} object + * Replace the flow identified by the {@code FlowConfig.name} name for the + * {@code FlowConfig.node} network node with the new flow specified by + * {@code FlowConfig} object + * + * @param config + * the {@code FlowConfig} object * @returnthe {@code Status} object indicating the result of this action */ public Status modifyStaticFlow(FlowConfig config); /** * Remove the flow specified by name on the passed network node - * - * @param name for the static flow - * @param node on which the flow is attached + * + * @param name + * for the static flow + * @param node + * on which the flow is attached * @return the {@code Status} object indicating the result of this action */ public Status removeStaticFlow(String name, Node node); /** - * Toggle the installation status of the specified configured flow - * If the flow configuration status is active, this call will - * change the flow status to inactive and vice-versa - * - * @param configObject the {@code FlowConfig} object + * Toggle the installation status of the specified configured flow If the + * flow configuration status is active, this call will change the flow + * status to inactive and vice-versa + * + * @param configObject + * the {@code FlowConfig} object * @return the {@code Status} object indicating the result of this action */ public Status toggleStaticFlowStatus(FlowConfig configObject); - + /** - * Toggle the installation status of the specified configured flow - * If the flow configuration status is active, this call will - * change the flow status to inactive and vice-versa - * - * @param name for the static flow - * @param node on which the flow is attached + * Toggle the installation status of the specified configured flow If the + * flow configuration status is active, this call will change the flow + * status to inactive and vice-versa + * + * @param name + * for the static flow + * @param node + * on which the flow is attached * @return the {@code Status} object indicating the result of this action */ public Status toggleStaticFlowStatus(String name, Node node); diff --git a/opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/IForwardingRulesManagerAware.java b/opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/IForwardingRulesManagerAware.java similarity index 57% rename from opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/IForwardingRulesManagerAware.java rename to opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/IForwardingRulesManagerAware.java index df37063218..e2ccdd60c3 100644 --- a/opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/IForwardingRulesManagerAware.java +++ b/opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/IForwardingRulesManagerAware.java @@ -1,4 +1,3 @@ - /* * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. * @@ -9,20 +8,22 @@ package org.opendaylight.controller.forwardingrulesmanager; - /** - * The interface which describes the methods forwarding rules manager - * will call for notifying the listeners of policy installation updates. - * + * The interface which describes the methods forwarding rules manager will call + * for notifying the listeners of policy installation updates. + * */ public interface IForwardingRulesManagerAware { - /** - * Inform the listeners that a troubleshooting information was - * added or removed for the specified policy. - * - * @param policyName the policy affected - * @param add true if the troubleshooting information was added, false otherwise - */ + /** + * Inform the listeners that a troubleshooting information was added or + * removed for the specified policy. + * + * @param policyName + * the policy affected + * @param add + * true if the troubleshooting information was added, false + * otherwise + */ public void policyUpdate(String policyName, boolean add); } diff --git a/opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/PortGroup.java b/opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/PortGroup.java similarity index 73% rename from opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/PortGroup.java rename to opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/PortGroup.java index 1e457beef4..5acd3e2ebc 100644 --- a/opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/PortGroup.java +++ b/opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/PortGroup.java @@ -1,4 +1,3 @@ - /* * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. * @@ -13,13 +12,13 @@ import java.util.HashSet; import java.util.Set; /** - * PortGroup is a simple data-structure to represent any arbitrary group of ports - * on a Switch (that is represented using its switch-ID). - * - * PortGroup is used by PortGroupProvider application to signal a set of ports that - * represent a configured PortGroupConfig. - * - * + * PortGroup is a simple data-structure to represent any arbitrary group of + * ports on a Switch (that is represented using its switch-ID). + * + * PortGroup is used by PortGroupProvider application to signal a set of ports + * that represent a configured PortGroupConfig. + * + * */ public class PortGroup { private long matrixSwitchId; @@ -27,9 +26,11 @@ public class PortGroup { /** * PortGroup Constructor using Switch and Ports. - * - * @param matrixSwitchId Switch Id that represents an openflow Switch - * @param ports Set of short values representing openflow port-ids. + * + * @param matrixSwitchId + * Switch Id that represents an openflow Switch + * @param ports + * Set of short values representing openflow port-ids. */ public PortGroup(long matrixSwitchId, Set ports) { super(); @@ -39,8 +40,9 @@ public class PortGroup { /** * PortGroup Constructor using Switch. - * - * @param matrixSwitchId Switch-Id that represents an openflow Switch + * + * @param matrixSwitchId + * Switch-Id that represents an openflow Switch */ public PortGroup(long matrixSwitchId) { this.matrixSwitchId = matrixSwitchId; @@ -49,7 +51,7 @@ public class PortGroup { /** * Returns the switchId representing the Switch that makes this PortGroup. - * + * * @return long switchId */ public long getMatrixSwitchId() { @@ -58,8 +60,9 @@ public class PortGroup { /** * Assigns a Switch to this PortGroup - * - * @param matrixSwitchId Switch-Id that represents an openflow Switch + * + * @param matrixSwitchId + * Switch-Id that represents an openflow Switch */ public void setMatrixSwitchId(long matrixSwitchId) { this.matrixSwitchId = matrixSwitchId; @@ -67,7 +70,7 @@ public class PortGroup { /** * Returns the Set of Ports that makes this PortGroup. - * + * * @return Set of short values representing openflow port-ids. */ public Set getPorts() { @@ -76,8 +79,9 @@ public class PortGroup { /** * Assigns a set of openflow ports to this PortGroup - * - * @param ports Set of short values representing openflow port-ids. + * + * @param ports + * Set of short values representing openflow port-ids. */ public void setPorts(Set ports) { this.ports = ports; @@ -85,8 +89,9 @@ public class PortGroup { /** * Adds a port to this PortGroup - * - * @param port Short value of a openflow port. + * + * @param port + * Short value of a openflow port. */ public void addPort(short port) { ports.add(port); diff --git a/opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/PortGroupChangeListener.java b/opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/PortGroupChangeListener.java similarity index 60% rename from opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/PortGroupChangeListener.java rename to opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/PortGroupChangeListener.java index 3479f29b67..7c8ade5b89 100644 --- a/opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/PortGroupChangeListener.java +++ b/opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/PortGroupChangeListener.java @@ -1,4 +1,3 @@ - /* * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. * @@ -14,18 +13,24 @@ import java.util.Map; import org.opendaylight.controller.sal.core.Node; /** - * PortGroupChangeListener listens to the PortGroup updates provided by the PortGroupProvider. - * - * + * PortGroupChangeListener listens to the PortGroup updates provided by the + * PortGroupProvider. + * + * */ public interface PortGroupChangeListener { /** - * This method is invoked by PortGroupProvider whenever it detects a change in PortGroup - * membership for a given PortGroupConfig. - * - * @param config Port Group Configuration - * @param portGroupData HashMap of Node id to PortGroup that represents the updated ports as detected by PortGroupProvider. - * @param add true indicates that the PortGroup is added. False indicates that the PortGroup is removed. + * This method is invoked by PortGroupProvider whenever it detects a change + * in PortGroup membership for a given PortGroupConfig. + * + * @param config + * Port Group Configuration + * @param portGroupData + * HashMap of Node id to PortGroup that represents the updated + * ports as detected by PortGroupProvider. + * @param add + * true indicates that the PortGroup is added. False indicates + * that the PortGroup is removed. */ void portGroupChanged(PortGroupConfig config, Map portGroupData, boolean add); diff --git a/opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/PortGroupConfig.java b/opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/PortGroupConfig.java similarity index 80% rename from opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/PortGroupConfig.java rename to opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/PortGroupConfig.java index 39683d4dfe..164f26484e 100644 --- a/opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/PortGroupConfig.java +++ b/opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/PortGroupConfig.java @@ -1,4 +1,3 @@ - /* * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. * @@ -15,14 +14,14 @@ import java.util.ArrayList; import java.util.List; /** - * PortGroupConfig class represents the User's Configuration with a Opaque Regular Expression - * String that is parsed and handled by PortGroupProvider. - * - * Typically, the opaque matchString will be a Regular Expression String supported by a particular - * PortGroupProvider based on Customer requirements. - * - * - * + * PortGroupConfig class represents the User's Configuration with a Opaque + * Regular Expression String that is parsed and handled by PortGroupProvider. + * + * Typically, the opaque matchString will be a Regular Expression String + * supported by a particular PortGroupProvider based on Customer requirements. + * + * + * */ public class PortGroupConfig implements Serializable { private static final long serialVersionUID = 1L; @@ -40,11 +39,13 @@ public class PortGroupConfig implements Serializable { } /** - * Constructor to create a Port Group Configuration using a Group Name and an Opaque - * String that is managed by PortGroupProvider. - * - * @param name Group Name representing a Port Group configuration - * @param matchString An Opaque String managed by PortGroupProvider + * Constructor to create a Port Group Configuration using a Group Name and + * an Opaque String that is managed by PortGroupProvider. + * + * @param name + * Group Name representing a Port Group configuration + * @param matchString + * An Opaque String managed by PortGroupProvider */ public PortGroupConfig(String name, String matchString) { super(); @@ -54,7 +55,7 @@ public class PortGroupConfig implements Serializable { /** * Returns the user configured PortGroup Configuration name. - * + * * @return Configuration Name */ public String getName() { @@ -63,7 +64,9 @@ public class PortGroupConfig implements Serializable { /** * Assigns a name to the configuration - * @param name configuration name + * + * @param name + * configuration name */ public void setName(String name) { this.name = name; @@ -71,6 +74,7 @@ public class PortGroupConfig implements Serializable { /** * Returns the Opaque string + * * @return */ public String getMatchString() { @@ -79,17 +83,18 @@ public class PortGroupConfig implements Serializable { /** * Assigns an opaque String to the Configuration. - * - * @param matchString Opaque string handled by PortGroupProvider + * + * @param matchString + * Opaque string handled by PortGroupProvider */ public void setMatchString(String matchString) { this.matchString = matchString; } /** - * Returns the names of all the configurable fields in PortGroupConfig. - * This method is typically used by NorthBound apis. - * + * Returns the names of all the configurable fields in PortGroupConfig. This + * method is typically used by NorthBound apis. + * * @return List of Field names that can be configured. */ public static List getFieldsNames() { @@ -97,7 +102,7 @@ public class PortGroupConfig implements Serializable { for (Field fld : PortGroupConfig.class.getDeclaredFields()) { fieldList.add(fld.getName()); } - //remove static field(s) + // remove static field(s) fieldList.remove(0); fieldList.remove(0); @@ -105,10 +110,12 @@ public class PortGroupConfig implements Serializable { } /** - * Returns the names of all the configurable fields in PortGroupConfig in human readable format for UI purposes. - * This method is typically used by Web/UI apis. - * - * @return List of Human readable Strings that corresponds to the configurable field names. + * Returns the names of all the configurable fields in PortGroupConfig in + * human readable format for UI purposes. This method is typically used by + * Web/UI apis. + * + * @return List of Human readable Strings that corresponds to the + * configurable field names. */ public static List getPrettyFieldsNames() { List fieldList = new ArrayList(); diff --git a/opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/PortGroupProvider.java b/opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/PortGroupProvider.java similarity index 52% rename from opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/PortGroupProvider.java rename to opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/PortGroupProvider.java index df6618c6fd..37cbcd17e6 100644 --- a/opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/PortGroupProvider.java +++ b/opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/PortGroupProvider.java @@ -1,4 +1,3 @@ - /* * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. * @@ -14,48 +13,59 @@ import java.util.Map; import org.opendaylight.controller.sal.core.Node; /** - * PortGroupProvider interface provides all the necessary blueprint for a custom application to implement - * in order to provide Port Grouping Service. Custom Application that implements this interface will have - * to handle the opaque match criteria passed to it via PortGroupConfig. - * - * - * + * PortGroupProvider interface provides all the necessary blueprint for a custom + * application to implement in order to provide Port Grouping Service. Custom + * Application that implements this interface will have to handle the opaque + * match criteria passed to it via PortGroupConfig. + * + * + * */ public interface PortGroupProvider { /** - * This method is invoked by the Controller towards the Provider when a new port group is configured. - * - * @param config New PortGroupConfig object created by user Configuration. + * This method is invoked by the Controller towards the Provider when a new + * port group is configured. + * + * @param config + * New PortGroupConfig object created by user Configuration. * @return true if successful. false otherwise. */ public boolean createPortGroupConfig(PortGroupConfig config); /** - * This method is invoked by the Controller towards the Provider when an existing port group is deleted. - * - * @param config Existing Port Group Configuration deleted by the user. + * This method is invoked by the Controller towards the Provider when an + * existing port group is deleted. + * + * @param config + * Existing Port Group Configuration deleted by the user. * @return true if successful. false otherwise. */ public boolean deletePortGroupConfig(PortGroupConfig config); /** - * Returns the complete mapping database corresponds to a PortGroup Configuration. - * Its the PortGroupProvider Application's responsibility to manage the Switches & the Set of its Ports that - * correspond to each of the Configuration and return it to the Controller when requested. - * - * @param config User Configuration + * Returns the complete mapping database corresponds to a PortGroup + * Configuration. Its the PortGroupProvider Application's responsibility to + * manage the Switches & the Set of its Ports that correspond to each of the + * Configuration and return it to the Controller when requested. + * + * @param config + * User Configuration * @see PortGroupConfig - * @return Database of Switch-Id to PortGroup mapping that corresponds to the Port Group User Configuration. + * @return Database of Switch-Id to PortGroup mapping that corresponds to + * the Port Group User Configuration. */ public Map getPortGroupData(PortGroupConfig config); /** - * Returns PortGroup data for a given Switch and user Configuration. - * Its the PortGroupProvider Application's responsibility to manage the Switches & the Set of its Ports that - * correspond to each of the Configuration and return it to the Controller when requested. - * - * @param config User Configuration - * @param matrixSwitchId Switch Id that represents an openflow Switch + * Returns PortGroup data for a given Switch and user Configuration. Its the + * PortGroupProvider Application's responsibility to manage the Switches & + * the Set of its Ports that correspond to each of the Configuration and + * return it to the Controller when requested. + * + * @param config + * User Configuration + * @param matrixSwitchId + * Switch Id that represents an openflow Switch * @see PortGroupConfig * @return PortGroup data for a given Openflow switch. * @see PortGroup @@ -64,33 +74,41 @@ public interface PortGroupProvider { long matrixSwitchId); /** - * Registers a Listener for Port Group membership changes based on Custom application algorithm. - * @param listener A Controller module that listens to events from the Custom Port Grouping Application. + * Registers a Listener for Port Group membership changes based on Custom + * application algorithm. + * + * @param listener + * A Controller module that listens to events from the Custom + * Port Grouping Application. */ public void registerPortGroupChange(PortGroupChangeListener listener); /** - * Application returns an Usage string for the Match Criteria User Configuration. - * Controller provides an opportunity for application to implement Custom Algorithm for Port Grouping. - * This method exposes the custom algorithm to the user so that the user can configure the matchString - * regular expression in PortGroupConfig appropriately. - * + * Application returns an Usage string for the Match Criteria User + * Configuration. Controller provides an opportunity for application to + * implement Custom Algorithm for Port Grouping. This method exposes the + * custom algorithm to the user so that the user can configure the + * matchString regular expression in PortGroupConfig appropriately. + * * @return Usage string. */ public String getApplicationDrivenMatchCriteriaUsage(); /** - * Returns the name of the Custom Application that implements PortGroupProvider interface. - * + * Returns the name of the Custom Application that implements + * PortGroupProvider interface. + * * @return Provider Name */ public String getProviderName(); /** - * Controller uses this method to check with the Provider supports the matchCriteria String configured by the User. - * + * Controller uses this method to check with the Provider supports the + * matchCriteria String configured by the User. + * * @param matchCriteria - * @return true if the Provider supports the matchCriteria String. false otherwise. + * @return true if the Provider supports the matchCriteria String. false + * otherwise. */ public boolean isMatchCriteriaSupported(String matchCriteria); } diff --git a/opendaylight/forwardingrulesmanager/src/test/java/org/opendaylight/controller/forwardingrulesmanager/frmTest.java b/opendaylight/forwardingrulesmanager/api/src/test/java/org/opendaylight/controller/forwardingrulesmanager/frmTest.java similarity index 80% rename from opendaylight/forwardingrulesmanager/src/test/java/org/opendaylight/controller/forwardingrulesmanager/frmTest.java rename to opendaylight/forwardingrulesmanager/api/src/test/java/org/opendaylight/controller/forwardingrulesmanager/frmTest.java index dd2fd229bd..0b11d13f3c 100644 --- a/opendaylight/forwardingrulesmanager/src/test/java/org/opendaylight/controller/forwardingrulesmanager/frmTest.java +++ b/opendaylight/forwardingrulesmanager/api/src/test/java/org/opendaylight/controller/forwardingrulesmanager/frmTest.java @@ -1,4 +1,3 @@ - /* * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. * @@ -41,33 +40,35 @@ import org.opendaylight.controller.sal.utils.NodeCreator; public class frmTest { - @Test - public void testFlowEntryInstall() throws UnknownHostException{ - Node node = NodeCreator.createOFNode(1L); - FlowEntry pol = new FlowEntry("polTest", null, getSampleFlowV6(node), - node); - FlowEntry pol2 = new FlowEntry("polTest2", null, getSampleFlowV6(node), - node); - FlowEntryInstall fei = new FlowEntryInstall(pol, null); - FlowEntryInstall fei2 = new FlowEntryInstall(pol, null); - FlowEntryInstall fei3 = new FlowEntryInstall(pol2, null); - Assert.assertTrue(fei.getOriginal().equals(pol)); - Assert.assertTrue(fei.getInstall().equals(pol)); - Assert.assertTrue(fei.getFlowName().equals(pol.getFlowName())); - Assert.assertTrue(fei.getGroupName().equals(pol.getGroupName())); - Assert.assertTrue(fei.getNode().equals(pol.getNode())); - Assert.assertFalse(fei.isDeletePending()); - fei.toBeDeleted(); - Assert.assertTrue(fei.isDeletePending()); - Assert.assertNull(fei.getContainerFlow()); - Assert.assertTrue(fei.equalsByNodeAndName(pol.getNode(), pol.getFlowName())); - - Assert.assertTrue(fei.equals(fei2)); - fei2.getOriginal().setFlowName("polTest2"); - Assert.assertFalse(fei.equals(null)); - Assert.assertFalse(fei.equals(fei3)); - - } + @Test + public void testFlowEntryInstall() throws UnknownHostException { + Node node = NodeCreator.createOFNode(1L); + FlowEntry pol = new FlowEntry("polTest", null, getSampleFlowV6(node), + node); + FlowEntry pol2 = new FlowEntry("polTest2", null, getSampleFlowV6(node), + node); + FlowEntryInstall fei = new FlowEntryInstall(pol, null); + FlowEntryInstall fei2 = new FlowEntryInstall(pol, null); + FlowEntryInstall fei3 = new FlowEntryInstall(pol2, null); + Assert.assertTrue(fei.getOriginal().equals(pol)); + Assert.assertTrue(fei.getInstall().equals(pol)); + Assert.assertTrue(fei.getFlowName().equals(pol.getFlowName())); + Assert.assertTrue(fei.getGroupName().equals(pol.getGroupName())); + Assert.assertTrue(fei.getNode().equals(pol.getNode())); + Assert.assertFalse(fei.isDeletePending()); + fei.toBeDeleted(); + Assert.assertTrue(fei.isDeletePending()); + Assert.assertNull(fei.getContainerFlow()); + Assert.assertTrue(fei.equalsByNodeAndName(pol.getNode(), + pol.getFlowName())); + + Assert.assertTrue(fei.equals(fei2)); + fei2.getOriginal().setFlowName("polTest2"); + Assert.assertFalse(fei.equals(null)); + Assert.assertFalse(fei.equals(fei3)); + + } + @Test public void testFlowEntryCreation() throws UnknownHostException { Node node = NodeCreator.createOFNode(1L); @@ -102,7 +103,6 @@ public class frmTest { Assert.assertTrue(pol.equals(pol2)); } - @Test public void testFlowEntryCloning() throws UnknownHostException { Node node = NodeCreator.createOFNode(1L); @@ -126,7 +126,7 @@ public class frmTest { match.setField(MatchType.DL_TYPE, EtherTypes.IPv4.shortValue()); List actionList = new ArrayList(); - //actionList.add(new Drop()); + // actionList.add(new Drop()); Flow flow = new Flow(match, actionList); FlowEntry pol1 = new FlowEntry("m1", "same", flow, node1); @@ -165,21 +165,21 @@ public class frmTest { FlowEntry entry = new FlowEntry("polTest", null, getSampleFlowV6(node), node); - //testing equal function + // testing equal function Assert.assertFalse(frmC.equals(null)); Assert.assertTrue(frmC.equals(frmC)); Assert.assertTrue(frmC.equals(frmC3)); Assert.assertFalse(frmC.equals(entry)); FlowConfig flowC = createSampleFlowConfig(); Assert.assertFalse(frmC.equals(flowC)); - //testing installInHW + // testing installInHW Assert.assertTrue(frmC.installInHw()); frmC.setInstallInHw(false); Assert.assertFalse(frmC.installInHw()); frmC.setInstallInHw(true); Assert.assertTrue(frmC.installInHw()); - //testing general set and get methods + // testing general set and get methods ArrayList actions = createSampleActionList(); frmC.setActions(actions); Assert.assertFalse(frmC.equals(frmC3)); @@ -256,20 +256,16 @@ public class frmTest { Assert.assertFalse(frmC.equals(flowC)); frmC.setProtocol(IPProtocols.TCP.toString()); - Assert.assertTrue(frmC.getProtocol().equals( - IPProtocols.TCP.toString())); + Assert.assertTrue(frmC.getProtocol().equals(IPProtocols.TCP.toString())); Assert.assertFalse(frmC.equals(frmC3)); frmC3.setProtocol(IPProtocols.TCP.toString()); Assert.assertFalse(frmC.equals(flowC)); - frmC.setNode(Node.fromString(Node.NodeIDType.OPENFLOW, - "1")); - Assert.assertTrue(frmC.getNode() - .equals(Node.fromString(Node.NodeIDType.OPENFLOW, - "1"))); + frmC.setNode(Node.fromString(Node.NodeIDType.OPENFLOW, "1")); + Assert.assertTrue(frmC.getNode().equals( + Node.fromString(Node.NodeIDType.OPENFLOW, "1"))); Assert.assertFalse(frmC.equals(frmC3)); - frmC3.setNode(Node.fromString(Node.NodeIDType.OPENFLOW, - "1")); + frmC3.setNode(Node.fromString(Node.NodeIDType.OPENFLOW, "1")); Assert.assertFalse(frmC.equals(flowC)); frmC.setTosBits("0"); @@ -313,7 +309,7 @@ public class frmTest { Assert.assertFalse(frmC.equals(frmC3)); frmC3.setHardTimeout("1000"); - // Assert.assertFalse(frmC.equals(flowC)); + // Assert.assertFalse(frmC.equals(flowC)); Assert.assertTrue(actions.equals(frmC.getActions())); FlowConfig frmC2 = new FlowConfig(frmC); @@ -323,7 +319,7 @@ public class frmTest { Assert.assertFalse(frmC2.equals(frmC)); frmC2.setDynamic(true); Assert.assertTrue(frmC2.equals(frmC)); - //Assert.assertFalse(frmC2.equals(frmC3)); + // Assert.assertFalse(frmC2.equals(frmC3)); flowC.setDynamic(true); Assert.assertTrue(flowC.equals(frmC)); Assert.assertTrue(flowC.isStatusSuccessful()); @@ -342,65 +338,61 @@ public class frmTest { Assert.assertTrue(id.toString().equals("1")); } - + @Test - public void testFlowConfigNextHopValidity() throws UnknownHostException{ - FlowConfig fc = new FlowConfig(); - Assert.assertFalse(fc.isOutputNextHopValid(null)); - Assert.assertFalse(fc.isOutputNextHopValid("abc")); - Assert.assertFalse(fc.isOutputNextHopValid("1.1.1")); - Assert.assertFalse(fc.isOutputNextHopValid("1.1.1.1/49")); - - Assert.assertTrue(fc.isOutputNextHopValid("1.1.1.1")); - Assert.assertTrue(fc.isOutputNextHopValid("1.1.1.1/32")); - Assert.assertTrue(fc.isOutputNextHopValid("2001:420:281:1004:407a:57f4:4d15:c355")); - + public void testFlowConfigNextHopValidity() throws UnknownHostException { + FlowConfig fc = new FlowConfig(); + Assert.assertFalse(fc.isOutputNextHopValid(null)); + Assert.assertFalse(fc.isOutputNextHopValid("abc")); + Assert.assertFalse(fc.isOutputNextHopValid("1.1.1")); + Assert.assertFalse(fc.isOutputNextHopValid("1.1.1.1/49")); + + Assert.assertTrue(fc.isOutputNextHopValid("1.1.1.1")); + Assert.assertTrue(fc.isOutputNextHopValid("1.1.1.1/32")); + Assert.assertTrue(fc + .isOutputNextHopValid("2001:420:281:1004:407a:57f4:4d15:c355")); + } - + @Test - public void testFlowConfigEqualities() throws UnknownHostException{ - FlowConfig fc = new FlowConfig(); - FlowConfig fc2 = new FlowConfig(); - fc.setName("flow1"); - fc.setNode(Node.fromString(Node.NodeIDType.OPENFLOW, - "1")); - Assert.assertFalse(fc.onNode(Node.fromString(Node.NodeIDType.OPENFLOW, - "0"))); - Assert.assertTrue(fc.onNode(Node.fromString(Node.NodeIDType.OPENFLOW, - "1"))); - - Assert.assertTrue(fc.isByNameAndNodeIdEqual( - "flow1", - Node.fromString(Node.NodeIDType.OPENFLOW, "1"))); - Assert.assertFalse(fc.isByNameAndNodeIdEqual( - "flow1", - Node.fromString(Node.NodeIDType.OPENFLOW, "0"))); - Assert.assertFalse(fc.isByNameAndNodeIdEqual( - "flow2", - Node.fromString(Node.NodeIDType.OPENFLOW, "1"))); - - Assert.assertFalse(fc.isByNameAndNodeIdEqual(fc2)); - fc2.setName("flow1"); - Assert.assertFalse(fc.isByNameAndNodeIdEqual(fc2)); - fc2.setNode(Node.fromString(Node.NodeIDType.OPENFLOW, - "0")); - Assert.assertFalse(fc.isByNameAndNodeIdEqual(fc2)); - fc2.setNode(Node.fromString(Node.NodeIDType.OPENFLOW, - "1")); - Assert.assertTrue(fc.isByNameAndNodeIdEqual(fc2)); + public void testFlowConfigEqualities() throws UnknownHostException { + FlowConfig fc = new FlowConfig(); + FlowConfig fc2 = new FlowConfig(); + fc.setName("flow1"); + fc.setNode(Node.fromString(Node.NodeIDType.OPENFLOW, "1")); + Assert.assertFalse(fc.onNode(Node.fromString(Node.NodeIDType.OPENFLOW, + "0"))); + Assert.assertTrue(fc.onNode(Node.fromString(Node.NodeIDType.OPENFLOW, + "1"))); + + Assert.assertTrue(fc.isByNameAndNodeIdEqual("flow1", + Node.fromString(Node.NodeIDType.OPENFLOW, "1"))); + Assert.assertFalse(fc.isByNameAndNodeIdEqual("flow1", + Node.fromString(Node.NodeIDType.OPENFLOW, "0"))); + Assert.assertFalse(fc.isByNameAndNodeIdEqual("flow2", + Node.fromString(Node.NodeIDType.OPENFLOW, "1"))); + + Assert.assertFalse(fc.isByNameAndNodeIdEqual(fc2)); + fc2.setName("flow1"); + Assert.assertFalse(fc.isByNameAndNodeIdEqual(fc2)); + fc2.setNode(Node.fromString(Node.NodeIDType.OPENFLOW, "0")); + Assert.assertFalse(fc.isByNameAndNodeIdEqual(fc2)); + fc2.setNode(Node.fromString(Node.NodeIDType.OPENFLOW, "1")); + Assert.assertTrue(fc.isByNameAndNodeIdEqual(fc2)); } - + @Test - public void testStatusToggle() throws UnknownHostException{ - FlowConfig fc = new FlowConfig(); - fc.toggleStatus(); - Assert.assertTrue(fc.installInHw()); - fc.toggleStatus(); - Assert.assertFalse(fc.installInHw()); - fc.toggleStatus(); - Assert.assertTrue(fc.installInHw()); - + public void testStatusToggle() throws UnknownHostException { + FlowConfig fc = new FlowConfig(); + fc.toggleStatus(); + Assert.assertTrue(fc.installInHw()); + fc.toggleStatus(); + Assert.assertFalse(fc.installInHw()); + fc.toggleStatus(); + Assert.assertTrue(fc.installInHw()); + } + @Test public void testGetFlowEntry() throws UnknownHostException { FlowConfig fc2 = createSampleFlowConfig(); @@ -442,8 +434,7 @@ public class frmTest { Assert.assertFalse(fc.isValid(null, sb)); Assert.assertTrue(sb.toString().contains("Node is null")); - fc.setNode(Node.fromString(Node.NodeIDType.OPENFLOW, - "1")); + fc.setNode(Node.fromString(Node.NodeIDType.OPENFLOW, "1")); Assert.assertTrue(fc.isValid(null, sb)); fc.setPriority("-1"); @@ -463,9 +454,7 @@ public class frmTest { fc.setCookie("100"); fc.setIngressPort("-1"); Assert.assertFalse(fc.isValid(null, sb)); - Assert - .assertTrue(sb.toString().contains( - "is not valid for the Switch")); + Assert.assertTrue(sb.toString().contains("is not valid for the Switch")); fc.setIngressPort("100"); Assert.assertTrue(fc.isValid(null, sb)); @@ -613,15 +602,12 @@ public class frmTest { private FlowConfig createSampleFlowConfig() throws UnknownHostException { ArrayList actions; actions = createSampleActionList(); - //actions.add(ActionType.CONTROLLER.toString()); - FlowConfig flowConfig = - new FlowConfig("true", "Config1", - Node.fromString(Node.NodeIDType.OPENFLOW, - "1"), "100", "0", "60", "2", "100", - "0", "0x0800", "00:A0:C9:14:C8:29", - "00:A0:C9:22:AB:11", IPProtocols.TCP.toString(), "0", - "1.2.3.4", "2.2.2.2", "8080", "100", "300", "1000", - actions); + // actions.add(ActionType.CONTROLLER.toString()); + FlowConfig flowConfig = new FlowConfig("true", "Config1", + Node.fromString(Node.NodeIDType.OPENFLOW, "1"), "100", "0", + "60", "2", "100", "0", "0x0800", "00:A0:C9:14:C8:29", + "00:A0:C9:22:AB:11", IPProtocols.TCP.toString(), "0", + "1.2.3.4", "2.2.2.2", "8080", "100", "300", "1000", actions); return flowConfig; } @@ -633,19 +619,19 @@ public class frmTest { actions.add(ActionType.FLOOD.toString()); actions.add(ActionType.SW_PATH.toString()); actions.add(ActionType.HW_PATH.toString()); - actions.add(ActionType.SET_VLAN_PCP.toString()+"=1"); - actions.add(ActionType.SET_VLAN_ID.toString()+"=1"); + actions.add(ActionType.SET_VLAN_PCP.toString() + "=1"); + actions.add(ActionType.SET_VLAN_ID.toString() + "=1"); actions.add(ActionType.POP_VLAN.toString()); - actions.add(ActionType.SET_DL_SRC.toString()+"=00:A0:C1:AB:22:11"); - actions.add(ActionType.SET_DL_DST.toString()+"=00:B1:C1:00:AA:BB"); - actions.add(ActionType.SET_NW_SRC.toString()+"=1.1.1.1"); - actions.add(ActionType.SET_NW_DST.toString()+"=2.2.2.2"); + actions.add(ActionType.SET_DL_SRC.toString() + "=00:A0:C1:AB:22:11"); + actions.add(ActionType.SET_DL_DST.toString() + "=00:B1:C1:00:AA:BB"); + actions.add(ActionType.SET_NW_SRC.toString() + "=1.1.1.1"); + actions.add(ActionType.SET_NW_DST.toString() + "=2.2.2.2"); actions.add(ActionType.CONTROLLER.toString()); - actions.add(ActionType.SET_NW_TOS.toString()+"1"); - actions.add(ActionType.SET_TP_SRC.toString()+"60"); - actions.add(ActionType.SET_TP_DST.toString()+"8080"); - actions.add(ActionType.SET_NEXT_HOP.toString()+"=1.1.1.1"); - + actions.add(ActionType.SET_NW_TOS.toString() + "1"); + actions.add(ActionType.SET_TP_SRC.toString() + "60"); + actions.add(ActionType.SET_TP_DST.toString() + "8080"); + actions.add(ActionType.SET_NEXT_HOP.toString() + "=1.1.1.1"); + return actions; } diff --git a/opendaylight/forwardingrulesmanager/implementation/pom.xml b/opendaylight/forwardingrulesmanager/implementation/pom.xml new file mode 100644 index 0000000000..2c0bc9319c --- /dev/null +++ b/opendaylight/forwardingrulesmanager/implementation/pom.xml @@ -0,0 +1,103 @@ + + + 4.0.0 + + org.opendaylight.controller + commons.opendaylight + 1.4.0-SNAPSHOT + ../../commons/opendaylight + + + org.opendaylight.controller + forwardingrulesmanager.implementation + 0.4.0-SNAPSHOT + bundle + + + + + org.apache.felix + maven-bundle-plugin + 2.3.6 + true + + + + + + + + org.opendaylight.controller.clustering.services, + org.opendaylight.controller.configuration, + org.opendaylight.controller.hosttracker, + org.opendaylight.controller.hosttracker.hostAware, + org.opendaylight.controller.switchmanager, + org.opendaylight.controller.sal.action, + org.opendaylight.controller.sal.core, + org.opendaylight.controller.sal.flowprogrammer, + org.opendaylight.controller.sal.match, + org.opendaylight.controller.sal.utils, + org.opendaylight.controller.sal.packet, + org.opendaylight.controller.forwardingrulesmanager, + javax.xml.bind.annotation, + javax.xml.bind, + org.apache.felix.dm, + org.apache.commons.lang3.builder, + org.osgi.service.component, + org.slf4j, + org.eclipse.osgi.framework.console, + org.osgi.framework + + + org.opendaylight.controller.forwardingrulesmanager.internal.Activator + + + org.opendaylight.controller.hosttracker + + + + + + + + + + + org.opendaylight.controller + hosttracker + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + configuration + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + clustering.services + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + switchmanager + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + sal + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + forwardingrulesmanager + 0.4.0-SNAPSHOT + + + junit + junit + 4.8.1 + test + + + diff --git a/opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/Activator.java b/opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/Activator.java similarity index 67% rename from opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/Activator.java rename to opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/Activator.java index 8578e8492e..70ae1f1fd7 100644 --- a/opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/Activator.java +++ b/opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/Activator.java @@ -1,4 +1,3 @@ - /* * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. * @@ -39,32 +38,31 @@ public class Activator extends ComponentActivatorAbstractBase { .getLogger(Activator.class); /** - * Function called when the activator starts just after some - * initializations are done by the - * ComponentActivatorAbstractBase. - * + * Function called when the activator starts just after some initializations + * are done by the ComponentActivatorAbstractBase. + * */ public void init() { } /** - * Function called when the activator stops just before the - * cleanup done by ComponentActivatorAbstractBase - * + * Function called when the activator stops just before the cleanup done by + * ComponentActivatorAbstractBase + * */ public void destroy() { } /** - * Function that is used to communicate to dependency manager the - * list of known implementations for services inside a container - * - * + * Function that is used to communicate to dependency manager the list of + * known implementations for services inside a container + * + * * @return An array containing all the CLASS objects that will be - * instantiated in order to get an fully working implementation - * Object + * instantiated in order to get an fully working implementation + * Object */ public Object[] getImplementations() { Object[] res = { ForwardingRulesManagerImpl.class }; @@ -72,17 +70,19 @@ public class Activator extends ComponentActivatorAbstractBase { } /** - * Function that is called when configuration of the dependencies - * is required. - * - * @param c dependency manager Component object, used for - * configuring the dependencies exported and imported - * @param imp Implementation class that is being configured, - * needed as long as the same routine can configure multiple - * implementations - * @param containerName The containerName being configured, this allow - * also optional per-container different behavior if needed, usually - * should not be the case though. + * Function that is called when configuration of the dependencies is + * required. + * + * @param c + * dependency manager Component object, used for configuring the + * dependencies exported and imported + * @param imp + * Implementation class that is being configured, needed as long + * as the same routine can configure multiple implementations + * @param containerName + * The containerName being configured, this allow also optional + * per-container different behavior if needed, usually should not + * be the case though. */ public void configureInstance(Component c, Object imp, String containerName) { if (imp.equals(ForwardingRulesManagerImpl.class)) { @@ -113,27 +113,31 @@ public class Activator extends ComponentActivatorAbstractBase { c.setInterface(interfaces, props); - c.add(createContainerServiceDependency(containerName).setService( - IFlowProgrammerService.class).setCallbacks( - "setFlowProgrammerService", "unsetFlowProgrammerService") + c.add(createContainerServiceDependency(containerName) + .setService(IFlowProgrammerService.class) + .setCallbacks("setFlowProgrammerService", + "unsetFlowProgrammerService").setRequired(true)); + + c.add(createContainerServiceDependency(containerName) + .setService(IClusterContainerServices.class) + .setCallbacks("setClusterContainerService", + "unsetClusterContainerService").setRequired(true)); + c.add(createContainerServiceDependency(containerName) + .setService(ISwitchManager.class) + .setCallbacks("setSwitchManager", "unsetSwitchManager") + .setRequired(true)); + c.add(createContainerServiceDependency(containerName) + .setService(IForwardingRulesManagerAware.class) + .setCallbacks("setFrmAware", "unsetFrmAware") + .setRequired(false)); + c.add(createContainerServiceDependency(containerName) + .setService(IfIptoHost.class) + .setCallbacks("setHostFinder", "unsetHostFinder") + .setRequired(true)); + c.add(createContainerServiceDependency(containerName) + .setService(IContainer.class) + .setCallbacks("setIContainer", "unsetIContainer") .setRequired(true)); - - c.add(createContainerServiceDependency(containerName).setService( - IClusterContainerServices.class).setCallbacks( - "setClusterContainerService", - "unsetClusterContainerService").setRequired(true)); - c.add(createContainerServiceDependency(containerName).setService( - ISwitchManager.class).setCallbacks("setSwitchManager", - "unsetSwitchManager").setRequired(true)); - c.add(createContainerServiceDependency(containerName).setService( - IForwardingRulesManagerAware.class).setCallbacks( - "setFrmAware", "unsetFrmAware").setRequired(false)); - c.add(createContainerServiceDependency(containerName).setService( - IfIptoHost.class).setCallbacks("setHostFinder", - "unsetHostFinder").setRequired(true)); - c.add(createContainerServiceDependency(containerName).setService( - IContainer.class).setCallbacks("setIContainer", - "unsetIContainer").setRequired(true)); } } } diff --git a/opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManagerImpl.java b/opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManagerImpl.java similarity index 93% rename from opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManagerImpl.java rename to opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManagerImpl.java index b82ab6f9a8..8e80f83d80 100644 --- a/opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManagerImpl.java +++ b/opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManagerImpl.java @@ -59,10 +59,10 @@ import org.opendaylight.controller.sal.core.NodeConnector; import org.opendaylight.controller.sal.core.Property; import org.opendaylight.controller.sal.core.UpdateType; import org.opendaylight.controller.sal.flowprogrammer.Flow; -import org.opendaylight.controller.sal.flowprogrammer.IFlowProgrammerListener; import org.opendaylight.controller.sal.flowprogrammer.IFlowProgrammerService; import org.opendaylight.controller.sal.match.Match; import org.opendaylight.controller.sal.match.MatchType; +import org.opendaylight.controller.sal.utils.StatusCode; import org.opendaylight.controller.sal.utils.EtherTypes; import org.opendaylight.controller.sal.utils.GlobalConstants; import org.opendaylight.controller.sal.utils.HexEncode; @@ -73,7 +73,6 @@ import org.opendaylight.controller.sal.utils.NodeCreator; import org.opendaylight.controller.sal.utils.ObjectReader; import org.opendaylight.controller.sal.utils.ObjectWriter; import org.opendaylight.controller.sal.utils.Status; -import org.opendaylight.controller.sal.utils.StatusCode; import org.opendaylight.controller.switchmanager.IInventoryListener; import org.opendaylight.controller.switchmanager.ISwitchManager; import org.opendaylight.controller.switchmanager.ISwitchManagerAware; @@ -91,8 +90,7 @@ import org.slf4j.LoggerFactory; public class ForwardingRulesManagerImpl implements IForwardingRulesManager, PortGroupChangeListener, IContainerListener, ISwitchManagerAware, IConfigurationContainerAware, IInventoryListener, IObjectReader, - ICacheUpdateAware, CommandProvider, - IFlowProgrammerListener { + ICacheUpdateAware, CommandProvider { private static final String SAVE = "Save"; private static final String NODEDOWN = "Node is Down"; private static final Logger log = LoggerFactory @@ -144,8 +142,7 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, // Sanity Check if (flowEntry == null || flowEntry.getNode() == null) { String msg = "Invalid FlowEntry"; - String logMsg = msg + ": {}"; - log.warn(logMsg, flowEntry); + log.warn(msg + ": " + flowEntry); return new Status(StatusCode.NOTACCEPTABLE, msg); } @@ -159,8 +156,7 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, // Container Flow conflict Check if (toInstallList.isEmpty()) { String msg = "Flow Entry conflicts with all Container Flows"; - String logMsg = msg + ": {}"; - log.warn(logMsg, flowEntry); + log.warn(msg); return new Status(StatusCode.CONFLICT, msg); } @@ -172,7 +168,7 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, if (findMatch(entry.getInstall(), false) != null) { log.warn("Operation Rejected: A flow with same match " + "and priority exists on the target node"); - log.trace("Aborting to install {}", entry); + log.trace("Aborting to install " + entry); continue; } toInstallSafe.add(entry); @@ -183,8 +179,7 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, if (toInstallSafe.size() == 0) { String msg = "A flow with same match and priority exists " + "on the target node"; - String logMsg = msg + ": {}"; - log.warn(logMsg, flowEntry); + log.warn(msg); return new Status(StatusCode.CONFLICT, msg); } @@ -200,8 +195,7 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, oneSucceded = true; } else { error = ret; - log.warn("Failed to install the entry: {}. The failure is: {}", - installEntry, ret.getDescription()); + log.warn("Failed to install the entry: " + ret.getDescription()); } } @@ -261,24 +255,21 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, if (currentFlowEntry == null || currentFlowEntry.getNode() == null || newFlowEntry == null || newFlowEntry.getNode() == null) { String msg = "Modify: Invalid FlowEntry"; - String logMsg = msg + ": {} or {}"; - log.warn(logMsg, currentFlowEntry, newFlowEntry); + log.warn(msg + ": {} or {} ", currentFlowEntry, newFlowEntry); return new Status(StatusCode.NOTACCEPTABLE, msg); } if (!currentFlowEntry.getNode().equals(newFlowEntry.getNode()) || !currentFlowEntry.getFlowName().equals( newFlowEntry.getFlowName())) { String msg = "Modify: Incompatible Flow Entries"; - String logMsg = msg + ": {} and {}"; - log.warn(logMsg, currentFlowEntry, newFlowEntry); + log.warn(msg + ": {} and {}", currentFlowEntry, newFlowEntry); return new Status(StatusCode.NOTACCEPTABLE, msg); } // Equality Check if (currentFlowEntry.equals(newFlowEntry)) { String msg = "Modify skipped as flows are the same"; - String logMsg = msg + ": {} and {}"; - log.debug(logMsg, currentFlowEntry, newFlowEntry); + log.debug(msg + ": " + currentFlowEntry + " and " + newFlowEntry); return new Status(StatusCode.SUCCESS, msg); } @@ -293,8 +284,7 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, currentFlowEntry)) { String msg = "Operation Rejected: Another flow with same match " + "and priority exists on the target node"; - String logMsg = msg + ": {}"; - log.warn(logMsg, currentFlowEntry); + log.warn(msg); return new Status(StatusCode.CONFLICT, msg); } @@ -307,8 +297,6 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, if (toInstallList.isEmpty()) { String msg = "Modify Operation Rejected: The new entry " + "conflicts with all the container flows"; - String logMsg = msg + ": {}"; - log.warn(logMsg, newFlowEntry); log.warn(msg); return new Status(StatusCode.CONFLICT, msg); } @@ -429,9 +417,8 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, .getFlow()); if (!status.isSuccess()) { - log.warn( - "SDN Plugin failed to program the flow: {}. The failure is: {}", - newEntries.getInstall(), status.getDescription()); + log.warn("SDN Plugin failed to program the flow: " + + status.getDescription()); return status; } @@ -458,8 +445,7 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, // Sanity Check if (flowEntry == null || flowEntry.getNode() == null) { String msg = "Invalid FlowEntry"; - String logMsg = msg + ": {}"; - log.warn(logMsg, flowEntry); + log.warn(msg + ": " + flowEntry); return new Status(StatusCode.NOTACCEPTABLE, msg); } @@ -471,14 +457,14 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, boolean atLeastOneRemoved = false; for (FlowEntryInstall entry : installedList) { if (flowsOnNode == null) { - String msg = "Removal skipped (Node down) for flow entry"; - String logMsg = msg + ": {}"; - log.debug(logMsg, flowEntry); + String msg = "Removal skipped (Node down)"; + log.debug(msg + " for flow entry " + flowEntry); return new Status(StatusCode.SUCCESS, msg); } if (!flowsOnNode.contains(entry)) { - String logMsg = "Removal skipped (not present in software view) for flow entry: {}"; - log.debug(logMsg, flowEntry); + log.debug("Removal skipped (not present in software view) " + + "for flow entry " + flowEntry); + if (installedList.size() == 1) { // If we had only one entry to remove, we are done return new Status(StatusCode.SUCCESS, null); @@ -492,8 +478,7 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, if (!ret.isSuccess()) { error = ret; - log.warn("Failed to remove the entry: {}. The failure is: {}", - entry.getInstall(), ret.getDescription()); + log.warn("Failed to remove the entry: " + ret.getDescription()); if (installedList.size() == 1) { // If we had only one entry to remove, this is fatal failure return error; @@ -530,12 +515,11 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, .getInstall().getFlow()); if (!status.isSuccess()) { - log.warn( - "SDN Plugin failed to program the flow: {}. The failure is: {}", - entry.getInstall(), status.getDescription()); + log.warn("SDN Plugin failed to remove the flow: " + + status.getDescription()); return status; } - log.info("Removed {}", entry.getInstall()); + log.trace("Removed {}", entry.getInstall()); // Update DB updateLocalDatabase(entry, false); @@ -559,13 +543,12 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, .getFlow()); if (!status.isSuccess()) { - log.warn( - "SDN Plugin failed to program the flow: {}. The failure is: {}", - entry.getInstall(), status.getDescription()); + log.warn("SDN Plugin failed to program the flow: " + + status.getDescription()); return status; } - log.info("Added {}", entry.getInstall()); + log.trace("Added {}", entry.getInstall()); // Update DB updateLocalDatabase(entry, true); @@ -721,11 +704,6 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, // Update DB if (status.isSuccess()) { updateLocalDatabase(target, false); - } else { - // log the error - log.warn( - "SDN Plugin failed to remove the flow: {}. The failure is: {}", - target.getInstall(), status.getDescription()); } return status; @@ -736,9 +714,8 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, Status status; if (inContainerMode) { String msg = "Controller in container mode: Install Refused"; - String logMsg = msg + ": {}"; status = new Status(StatusCode.NOTACCEPTABLE, msg); - log.warn(logMsg, flowEntry); + log.warn(msg); } else { status = addEntry(flowEntry); } @@ -750,9 +727,8 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, Status status; if (inContainerMode) { String msg = "Controller in container mode: Uninstall Refused"; - String logMsg = msg + ": {}"; status = new Status(StatusCode.NOTACCEPTABLE, msg); - log.warn(logMsg, entry); + log.warn(msg); } else { status = removeEntry(entry); } @@ -765,9 +741,8 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, Status status = null; if (inContainerMode) { String msg = "Controller in container mode: Modify Refused"; - String logMsg = msg + ": {}"; status = new Status(StatusCode.NOTACCEPTABLE, msg); - log.warn(logMsg, newFlowEntry); + log.warn(msg); } else { status = modifyEntry(currentFlowEntry, newFlowEntry); } @@ -904,7 +879,7 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, try { frma.policyUpdate(policyname, add); } catch (Exception e) { - log.warn("Exception on callback", e); + log.error("Exception on callback", e); } } } @@ -956,10 +931,9 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, log.info("Ports {} added to FlowEntry {}", portList, flowName); } else { - log.warn( - "Failed to add ports {} to Flow entry {}. The failure is: {}", - portList, currentFlowEntry.toString(), - error.getDescription()); + log.warn("Failed to add ports {} to Flow entry {}: " + + error.getDescription(), portList, + currentFlowEntry.toString()); } return; } @@ -987,10 +961,9 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, log.info("Ports {} removed from FlowEntry {}", portList, flowName); } else { - log.warn( - "Failed to remove ports {} from Flow entry {}. The failure is: {}", - portList, currentFlowEntry.toString(), - status.getDescription()); + log.warn("Failed to remove ports {} from Flow entry {}: " + + status.getDescription(), portList, + currentFlowEntry.toString()); } return; } @@ -1040,12 +1013,11 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, Status status = modifyEntry(currentFlowEntry, newFlowEntry); if (status.isSuccess()) { - log.info("Output port replaced with {} for flow {} on node {}", - outPort, flowName, node); + log.info("Output port replaced with " + outPort + + " for flow {} on node {}", flowName, node); } else { - log.warn( - "Failed to replace output port for flow {} on node {}. The failure is: {}", - flowName, node, status.getDescription()); + log.warn("Failed to replace output port for flow {} on node {}: ", + status.getDescription(), flowName, node); } return; } @@ -1107,9 +1079,9 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, EnumSet.of(IClusterServices.cacheMode.NON_TRANSACTIONAL)); } catch (CacheConfigException cce) { - log.error("FRM CacheConfigException", cce); + log.error("FRM CacheConfigException"); } catch (CacheExistException cce) { - log.error("FRM CacheExistException", cce); + log.error("FRM CacheExistException"); } } @@ -1239,17 +1211,13 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, // Presence check if (flowConfigExists(config)) { error = "Entry with this name on specified switch already exists"; - log.warn( - "Entry with this name on specified switch already exists: {}", - config); config.setStatus(error); return new Status(StatusCode.CONFLICT, error); } // Skip validation check if we are trying to restore a saved config if (!restore && !config.isValid(container, resultStr)) { - log.warn("Invalid Configuration for flow {}. The failure is {}", - config, resultStr.toString()); + log.debug(resultStr.toString()); error = "Invalid Configuration (" + resultStr.toString() + ")"; config.setStatus(error); return new Status(StatusCode.BADREQUEST, error); @@ -1263,9 +1231,7 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, } } if (!multipleFlowPush) { - log.warn( - "Invalid Configuration(Invalid PortGroup Name) for flow {}", - config); + log.debug(resultStr.toString()); error = "Invalid Configuration (Invalid PortGroup Name)"; config.setStatus(error); return new Status(StatusCode.BADREQUEST, error); @@ -1336,7 +1302,7 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, } private void updateStaticFlowConfigsOnNodeDown(Node node) { - log.trace("Updating Static Flow configs on node down: {}", node); + log.trace("Updating Static Flow configs on node down: " + node); List toRemove = new ArrayList(); for (Entry entry : staticFlows.entrySet()) { @@ -1363,8 +1329,8 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, } private void updateStaticFlowConfigsOnContainerModeChange(UpdateType update) { - log.trace("Updating Static Flow configs on container mode change: {}", - update); + log.trace("Updating Static Flow configs on container mode change: " + + update); for (FlowConfig config : staticFlows.values()) { if (config.isPortGroupEnabled()) { @@ -1419,8 +1385,7 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, if (entry.isInternalFlow()) { String msg = "Invalid operation: Controller generated " + "flow cannot be deleted"; - String logMsg = msg + ": {}"; - log.warn(logMsg, name); + log.warn(msg); return new Status(StatusCode.NOTACCEPTABLE, msg); } if (!entry.isPortGroupEnabled()) { @@ -1445,8 +1410,7 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, if (newFlowConfig.isInternalFlow()) { String msg = "Invalid operation: Controller generated flow " + "cannot be modified"; - String logMsg = msg + ": {}"; - log.warn(logMsg, newFlowConfig); + log.warn(msg); return new Status(StatusCode.NOTACCEPTABLE, msg); } @@ -1455,8 +1419,7 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, if (!newFlowConfig.isValid(container, resultStr)) { String msg = "Invalid Configuration (" + resultStr.toString() + ")"; newFlowConfig.setStatus(msg); - log.warn("Invalid Configuration for flow {}. The failure is {}", - newFlowConfig, resultStr.toString()); + log.warn(msg); return new Status(StatusCode.BADREQUEST, msg); } @@ -1474,17 +1437,14 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, if (oldFlowConfig == null) { String msg = "Attempt to modify a non existing static flow"; - String logMsg = msg + ": {}"; - log.warn(logMsg, newFlowConfig); + log.warn(msg); return new Status(StatusCode.NOTFOUND, msg); } // Do not attempt to reinstall the flow, warn user if (newFlowConfig.equals(oldFlowConfig)) { String msg = "No modification detected"; - log.info( - "Static flow modification skipped. New flow and old flow are the same: {}", - newFlowConfig); + log.info("Static flow modification skipped: " + msg); return new Status(StatusCode.SUCCESS, msg); } @@ -1520,8 +1480,7 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, if (config.isInternalFlow()) { String msg = "Invalid operation: Controller generated flow " + "cannot be modified"; - String logMsg = msg + ": {}"; - log.warn(logMsg, config); + log.warn(msg); return new Status(StatusCode.NOTACCEPTABLE, msg); } @@ -1571,8 +1530,9 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, for (FlowEntry flowEntry : inactiveFlows) { Status status = this.removeEntry(flowEntry); if (!status.isSuccess()) { - log.warn("Failed to remove entry: {}. The failure is: {}" - + flowEntry, status.getDescription()); + log.warn( + "Failed to remove entry: {}: " + + status.getDescription(), flowEntry); } } } @@ -1588,8 +1548,9 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, for (FlowEntry flowEntry : this.inactiveFlows) { Status status = this.addEntry(flowEntry); if (!status.isSuccess()) { - log.warn("Failed to install entry: {}. The failure is: {}" - + flowEntry, status.getDescription()); + log.warn( + "Failed to install entry: {}: " + + status.getDescription(), flowEntry); } } @@ -1816,7 +1777,7 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, * @param node */ private synchronized void cleanDatabaseForNode(Node node) { - log.info("Cleaning Flow database for Node {}", node.toString()); + log.info("Cleaning Flow database for Node " + node.toString()); // Find out which groups the node's flows are part of Set affectedGroups = new HashSet(); @@ -2281,8 +2242,7 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, try { node = NodeCreator.createOFNode(Long.valueOf(nodeId)); } catch (NumberFormatException e) { - ci.print("Node id not a number"); - return; + e.printStackTrace(); } ci.println(this.programmer.addFlow(node, getSampleFlow(node))); } @@ -2298,8 +2258,7 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, try { node = NodeCreator.createOFNode(Long.valueOf(nodeId)); } catch (NumberFormatException e) { - ci.print("Node id not a number"); - return; + e.printStackTrace(); } ci.println(this.programmer.removeFlow(node, getSampleFlow(node))); } @@ -2398,28 +2357,4 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, } } - @Override - public void flowRemoved(Node node, Flow flow) { - log.trace("Received flow removed notification on {} for {}", node, flow); - // For flow entry identification, only match and priority matter - FlowEntry toFind = new FlowEntry("any", "any", flow, node); - FlowEntryInstall installedEntry = this.findMatch(toFind, false); - if (installedEntry == null) { - log.trace("Entry is not know to us"); - return; - } - - // Update Static flow status - for (Map.Entry entry : staticFlows.entrySet()) { - FlowConfig conf = entry.getValue(); - if (conf.isByNameAndNodeIdEqual(installedEntry.getFlowName(), node)) { - // Update Configuration database - conf.toggleStatus(); - break; - } - } - // Update software views - this.updateLocalDatabase(installedEntry, false); - } - }