X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fforwardingrulesmanager%2Fapi%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fforwardingrulesmanager%2FFlowEntry.java;h=83106a391cb7bdc00ff0911fa703e7dee1c1c2f4;hb=144cfa4b4a926b7d0c3d5f60ada050c609762699;hp=2e174d25e29930e43431d72052c8060ddc5b9939;hpb=fc7a2ae9b5c6b82d463fe612509a157e3f261653;p=controller.git diff --git a/opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowEntry.java b/opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowEntry.java index 2e174d25e2..83106a391c 100644 --- a/opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowEntry.java +++ b/opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowEntry.java @@ -11,8 +11,6 @@ package org.opendaylight.controller.forwardingrulesmanager; import java.io.Serializable; import java.util.Date; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; import org.opendaylight.controller.sal.core.ContainerFlow; import org.opendaylight.controller.sal.core.Node; import org.opendaylight.controller.sal.flowprogrammer.Flow; @@ -27,8 +25,7 @@ import org.slf4j.LoggerFactory; * instance the flows constituting a policy all share the same group name. */ public class FlowEntry implements Cloneable, Serializable { - protected static final Logger logger = LoggerFactory - .getLogger(FlowEntry.class); + protected static final Logger logger = LoggerFactory.getLogger(FlowEntry.class); private static final long serialVersionUID = 1L; private static final Logger log = LoggerFactory.getLogger(FlowEntry.class); private String groupName; // group name @@ -53,7 +50,7 @@ public class FlowEntry implements Cloneable, Serializable { /** * Return the actual Flow contained in this entry - * + * * @return the flow */ public Flow getFlow() { @@ -88,20 +85,65 @@ public class FlowEntry implements Cloneable, Serializable { return cloned; } + /* + * Only accounts fields which uniquely identify a flow for collision + * purposes: node, match and priority + */ @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = 1; + result = prime * result + ((node == null) ? 0 : node.hashCode()); + result = prime * result + ((flow == null) ? 0 : (int) flow.getPriority()); + result = prime * result + ((flow == null || flow.getMatch() == null) ? 0 : flow.getMatch().hashCode()); + + return result; } @Override public boolean equals(Object obj) { - return EqualsBuilder.reflectionEquals(this, obj); + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + FlowEntry other = (FlowEntry) obj; + + if (node == null) { + if (other.node != null) { + return false; + } + } else if (!node.equals(other.node)) { + return false; + } + + if (flow == null) { + return (other.flow == null) ? true : false; + } else if (other.flow == null) { + return false; + } + if (flow.getPriority() != other.flow.getPriority()) { + return false; + } + if (flow.getMatch() == null) { + if (other.flow.getMatch() != null) { + return false; + } + } else if (!flow.getMatch().equals(other.flow.getMatch())) { + return false; + } + + return true; } @Override public String toString() { - return "FlowEntry[flowName = " + flowName + ", groupName = " - + groupName + ",node = " + node + ", flow = " + flow + "]"; + return "FlowEntry[flowName = " + flowName + ", groupName = " + groupName + ", node = " + node + ", flow = " + + flow + "]"; } private String constructFlowName() { @@ -114,27 +156,37 @@ 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 - * - * + * + * * @param containerFlow * @return this merged FlowEntry */ public FlowEntry mergeWith(ContainerFlow containerFlow) { Match myMatch = flow.getMatch(); - // Based on this flow direction, rearrange the match - Match match = containerFlow.getMatch(); + Match filter = containerFlow.getMatch(); // Merge - myMatch.mergeWithFilter(match); + Match merge = myMatch.mergeWithFilter(filter); // Replace this Flow's match with merged version - flow.setMatch(myMatch); + flow.setMatch(merge); return this; } + + /** + * Returns whether this entry is the result of an internal generated static + * flow + * + * @return true if internal generated static flow, false otherwise + */ + public boolean isInternal() { + return flowName.startsWith(FlowConfig.INTERNALSTATICFLOWBEGIN) + && flowName.endsWith(FlowConfig.INTERNALSTATICFLOWEND); + } }