From: Giovanni Meo Date: Wed, 31 Jul 2013 08:02:48 +0000 (+0000) Subject: Merge "Fixed a bug and added a function for operating on MAC addresses." X-Git-Tag: releasepom-0.1.0~247 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=ebd2fbb7486febe6d330995238ce98bdb34fc77e;hp=7b8542bde88493834288782e7280c0fe72f3763b Merge "Fixed a bug and added a function for operating on MAC addresses." --- diff --git a/opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/HostTracker.java b/opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/HostTracker.java index f600e6b2ac..af983b3c8b 100644 --- a/opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/HostTracker.java +++ b/opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/HostTracker.java @@ -95,7 +95,7 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw private IClusterContainerServices clusterContainerService = null; private ISwitchManager switchManager = null; private Timer timer; - private Timer arp_refresh_timer; + private Timer arpRefreshTimer; private String containerName = null; private ExecutorService executor; private static class ARPPending { @@ -160,8 +160,8 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw timer.schedule(new OutStandingARPHandler(), 4000, 4000); executor = Executors.newFixedThreadPool(2); /* ARP Refresh Timer to go off every 5 seconds to implement ARP aging */ - arp_refresh_timer = new Timer(); - arp_refresh_timer.schedule(new ARPRefreshHandler(), 5000, 5000); + arpRefreshTimer = new Timer(); + arpRefreshTimer.schedule(new ARPRefreshHandler(), 5000, 5000); logger.debug("startUp: Caches created, timers started"); } @@ -911,7 +911,6 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw public void run() { ARPPending arphost; /* This routine runs every 4 seconds */ - // logger.info ("ARP Handler called"); for (int i = 0; i < ARPPendingList.size(); i++) { arphost = ARPPendingList.get(i); if (arphost.getSent_count() < switchManager.getHostRetryCount()) { @@ -943,7 +942,7 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw failedARPReqList.add(arphost); } else { - logger.error("Inavlid arp_sent count for entery at index: {}", i); + logger.error("Inavlid arp_sent count for entry at index: {}", i); } } } @@ -1386,7 +1385,12 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw * calls * */ - void stop() { + void stop(){ + } + + void stopping() { + arpRefreshTimer.cancel(); + timer.cancel(); executor.shutdown(); } diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/reader/FlowOnNode.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/reader/FlowOnNode.java index 163d04b3ff..994ee4533e 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/reader/FlowOnNode.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/reader/FlowOnNode.java @@ -114,6 +114,56 @@ public class FlowOnNode implements Serializable{ this.durationNanoseconds = durationNanoseconds; } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (int) (byteCount ^ (byteCount >>> 32)); + result = prime * result + durationNanoseconds; + result = prime * result + durationSeconds; + result = prime * result + ((flow == null) ? 0 : flow.hashCode()); + result = prime * result + (int) (packetCount ^ (packetCount >>> 32)); + result = prime * result + tableId; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (!(obj instanceof FlowOnNode)) { + return false; + } + FlowOnNode other = (FlowOnNode) obj; + if (byteCount != other.byteCount) { + return false; + } + if (durationNanoseconds != other.durationNanoseconds) { + return false; + } + if (durationSeconds != other.durationSeconds) { + return false; + } + if (flow == null) { + if (other.flow != null) { + return false; + } + } else if (!flow.equals(other.flow)) { + return false; + } + if (packetCount != other.packetCount) { + return false; + } + if (tableId != other.tableId) { + return false; + } + return true; + } + @Override public String toString() { return "FlowOnNode[flow =" + flow + ", tableId = " + tableId diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/reader/NodeConnectorStatistics.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/reader/NodeConnectorStatistics.java index 848b19ee0f..fc6a6d87f1 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/reader/NodeConnectorStatistics.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/reader/NodeConnectorStatistics.java @@ -18,7 +18,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.opendaylight.controller.sal.core.NodeConnector; /** - * Represents the statistics for the node conenctor + * Represents the statistics for a node connector */ @XmlRootElement @XmlAccessorType(XmlAccessType.NONE) @@ -52,6 +52,84 @@ public class NodeConnectorStatistics implements Serializable { @XmlElement private long collisionCount; + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (int) (collisionCount ^ (collisionCount >>> 32)); + result = prime * result + ((nodeConnector == null) ? 0 : nodeConnector.hashCode()); + result = prime * result + (int) (receiveBytes ^ (receiveBytes >>> 32)); + result = prime * result + (int) (receiveCrcError ^ (receiveCrcError >>> 32)); + result = prime * result + (int) (receiveDrops ^ (receiveDrops >>> 32)); + result = prime * result + (int) (receiveErrors ^ (receiveErrors >>> 32)); + result = prime * result + (int) (receiveFrameError ^ (receiveFrameError >>> 32)); + result = prime * result + (int) (receiveOverRunError ^ (receiveOverRunError >>> 32)); + result = prime * result + (int) (receivePackets ^ (receivePackets >>> 32)); + result = prime * result + (int) (transmitBytes ^ (transmitBytes >>> 32)); + result = prime * result + (int) (transmitDrops ^ (transmitDrops >>> 32)); + result = prime * result + (int) (transmitErrors ^ (transmitErrors >>> 32)); + result = prime * result + (int) (transmitPackets ^ (transmitPackets >>> 32)); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (!(obj instanceof NodeConnectorStatistics)) { + return false; + } + NodeConnectorStatistics other = (NodeConnectorStatistics) obj; + if (collisionCount != other.collisionCount) { + return false; + } + if (nodeConnector == null) { + if (other.nodeConnector != null) { + return false; + } + } else if (!nodeConnector.equals(other.nodeConnector)) { + return false; + } + if (receiveBytes != other.receiveBytes) { + return false; + } + if (receiveCrcError != other.receiveCrcError) { + return false; + } + if (receiveDrops != other.receiveDrops) { + return false; + } + if (receiveErrors != other.receiveErrors) { + return false; + } + if (receiveFrameError != other.receiveFrameError) { + return false; + } + if (receiveOverRunError != other.receiveOverRunError) { + return false; + } + if (receivePackets != other.receivePackets) { + return false; + } + if (transmitBytes != other.transmitBytes) { + return false; + } + if (transmitDrops != other.transmitDrops) { + return false; + } + if (transmitErrors != other.transmitErrors) { + return false; + } + if (transmitPackets != other.transmitPackets) { + return false; + } + return true; + } + // To Satisfy JAXB public NodeConnectorStatistics() { diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/reader/NodeDescription.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/reader/NodeDescription.java index 8f99b05a09..12ce4d6948 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/reader/NodeDescription.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/reader/NodeDescription.java @@ -68,6 +68,68 @@ public class NodeDescription implements Serializable, Cloneable{ this.description = description; } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((description == null) ? 0 : description.hashCode()); + result = prime * result + ((hardware == null) ? 0 : hardware.hashCode()); + result = prime * result + ((manufacturer == null) ? 0 : manufacturer.hashCode()); + result = prime * result + ((serialNumber == null) ? 0 : serialNumber.hashCode()); + result = prime * result + ((software == null) ? 0 : software.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (!(obj instanceof NodeDescription)) { + return false; + } + NodeDescription other = (NodeDescription) obj; + if (description == null) { + if (other.description != null) { + return false; + } + } else if (!description.equals(other.description)) { + return false; + } + if (hardware == null) { + if (other.hardware != null) { + return false; + } + } else if (!hardware.equals(other.hardware)) { + return false; + } + if (manufacturer == null) { + if (other.manufacturer != null) { + return false; + } + } else if (!manufacturer.equals(other.manufacturer)) { + return false; + } + if (serialNumber == null) { + if (other.serialNumber != null) { + return false; + } + } else if (!serialNumber.equals(other.serialNumber)) { + return false; + } + if (software == null) { + if (other.software != null) { + return false; + } + } else if (!software.equals(other.software)) { + return false; + } + return true; + } + @Override public String toString() { return "HwDescription[manufacturer=" + manufacturer + ", hardware=" diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/reader/NodeTableStatistics.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/reader/NodeTableStatistics.java index 3b359cb812..7c404178cf 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/reader/NodeTableStatistics.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/reader/NodeTableStatistics.java @@ -39,6 +39,56 @@ public class NodeTableStatistics implements Serializable { private long matchedCount; + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + activeCount; + result = prime * result + (int) (lookupCount ^ (lookupCount >>> 32)); + result = prime * result + (int) (matchedCount ^ (matchedCount >>> 32)); + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((nodeTable == null) ? 0 : nodeTable.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (!(obj instanceof NodeTableStatistics)) { + return false; + } + NodeTableStatistics other = (NodeTableStatistics) obj; + if (activeCount != other.activeCount) { + return false; + } + if (lookupCount != other.lookupCount) { + return false; + } + if (matchedCount != other.matchedCount) { + return false; + } + if (name == null) { + if (other.name != null) { + return false; + } + } else if (!name.equals(other.name)) { + return false; + } + if (nodeTable == null) { + if (other.nodeTable != null) { + return false; + } + } else if (!nodeTable.equals(other.nodeTable)) { + return false; + } + return true; + } + //To Satisfy JAXB public NodeTableStatistics() { diff --git a/opendaylight/statisticsmanager/implementation/src/main/java/org/opendaylight/controller/statisticsmanager/internal/StatisticsManager.java b/opendaylight/statisticsmanager/implementation/src/main/java/org/opendaylight/controller/statisticsmanager/internal/StatisticsManager.java index f5c13b6105..eec183d595 100644 --- a/opendaylight/statisticsmanager/implementation/src/main/java/org/opendaylight/controller/statisticsmanager/internal/StatisticsManager.java +++ b/opendaylight/statisticsmanager/implementation/src/main/java/org/opendaylight/controller/statisticsmanager/internal/StatisticsManager.java @@ -167,7 +167,7 @@ public class StatisticsManager implements IStatisticsManager, IReadServiceListen * Function called after registering the service in OSGi service registry. */ void started(){ - //retrieve current statistics so we don't have to wait for next refresh + // Retrieve current statistics so we don't have to wait for next refresh ISwitchManager switchManager = (ISwitchManager) ServiceHelper.getInstance( ISwitchManager.class, container.getName(), this); if (reader != null && switchManager != null) { @@ -180,7 +180,7 @@ public class StatisticsManager implements IStatisticsManager, IReadServiceListen } } else { - log.warn("Failed to retrieve current statistics. Statistics will not be immidiately available!"); + log.trace("Failed to retrieve current statistics. Statistics will not be immediately available!"); } } @@ -247,7 +247,7 @@ public class StatisticsManager implements IStatisticsManager, IReadServiceListen } Node node; - //index FlowEntries' flows by node so we don't traverse entire flow list for each flowEntry + // Index FlowEntries' flows by node so we don't traverse entire flow list for each flowEntry Map> index = new HashMap>(); for (FlowEntry flowEntry : flowList) { node = flowEntry.getNode(); @@ -256,7 +256,7 @@ public class StatisticsManager implements IStatisticsManager, IReadServiceListen index.put(node, set); } - //iterate over flows per indexed node and add to output + // Iterate over flows per indexed node and add to output for (Entry> indexEntry : index.entrySet()) { node = indexEntry.getKey(); List flowsPerNode = flowStatistics.get(node); @@ -356,27 +356,40 @@ public class StatisticsManager implements IStatisticsManager, IReadServiceListen @Override public void nodeFlowStatisticsUpdated(Node node, List flowStatsList) { - this.flowStatistics.put(node, flowStatsList); + List currentStat = this.flowStatistics.get(node); + // Update cache only if changed to avoid unnecessary cache sync operations + if (! flowStatsList.equals(currentStat)){ + this.flowStatistics.put(node, flowStatsList); + } } @Override public void nodeConnectorStatisticsUpdated(Node node, List ncStatsList) { - this.nodeConnectorStatistics.put(node, ncStatsList); + List currentStat = this.nodeConnectorStatistics.get(node); + if (! ncStatsList.equals(currentStat)){ + this.nodeConnectorStatistics.put(node, ncStatsList); + } } @Override public void nodeTableStatisticsUpdated(Node node, List tableStatsList) { - this.tableStatistics.put(node, tableStatsList); + List currentStat = this.tableStatistics.get(node); + if (! tableStatsList.equals(currentStat)) { + this.tableStatistics.put(node, tableStatsList); + } } @Override public void descriptionStatisticsUpdated(Node node, NodeDescription nodeDescription) { - this.descriptionStatistics.put(node, nodeDescription); + NodeDescription currentDesc = this.descriptionStatistics.get(node); + if (! nodeDescription.equals(currentDesc)){ + this.descriptionStatistics.put(node, nodeDescription); + } } @Override public void updateNode(Node node, UpdateType type, Set props) { - //if node is removed, remove stats mappings + // If node is removed, clean up stats mappings if (type == UpdateType.REMOVED) { flowStatistics.remove(node); nodeConnectorStatistics.remove(node); @@ -387,6 +400,6 @@ public class StatisticsManager implements IStatisticsManager, IReadServiceListen @Override public void updateNodeConnector(NodeConnector nodeConnector, UpdateType type, Set props) { - // not interested in this update + // Not interested in this update } }