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 {
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");
}
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()) {
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);
}
}
}
* calls
*
*/
- void stop() {
+ void stop(){
+ }
+
+ void stopping() {
+ arpRefreshTimer.cancel();
+ timer.cancel();
executor.shutdown();
}
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
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)
@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() {
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="
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() {
* 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) {
}
} 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!");
}
}
}
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<Node, Set<Flow>> index = new HashMap<Node, Set<Flow>>();
for (FlowEntry flowEntry : flowList) {
node = flowEntry.getNode();
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<Node, Set<Flow>> indexEntry : index.entrySet()) {
node = indexEntry.getKey();
List<FlowOnNode> flowsPerNode = flowStatistics.get(node);
@Override
public void nodeFlowStatisticsUpdated(Node node, List<FlowOnNode> flowStatsList) {
- this.flowStatistics.put(node, flowStatsList);
+ List<FlowOnNode> 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<NodeConnectorStatistics> ncStatsList) {
- this.nodeConnectorStatistics.put(node, ncStatsList);
+ List<NodeConnectorStatistics> currentStat = this.nodeConnectorStatistics.get(node);
+ if (! ncStatsList.equals(currentStat)){
+ this.nodeConnectorStatistics.put(node, ncStatsList);
+ }
}
@Override
public void nodeTableStatisticsUpdated(Node node, List<NodeTableStatistics> tableStatsList) {
- this.tableStatistics.put(node, tableStatsList);
+ List<NodeTableStatistics> 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<Property> 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);
@Override
public void updateNodeConnector(NodeConnector nodeConnector, UpdateType type, Set<Property> props) {
- // not interested in this update
+ // Not interested in this update
}
}