3 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
5 * This program and the accompanying materials are made available under the
6 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 * and is available at http://www.eclipse.org/legal/epl-v10.html
10 package org.opendaylight.controller.sal.reader;
12 import java.io.Serializable;
14 import javax.xml.bind.annotation.XmlAccessType;
15 import javax.xml.bind.annotation.XmlAccessorType;
16 import javax.xml.bind.annotation.XmlElement;
17 import javax.xml.bind.annotation.XmlRootElement;
19 import org.opendaylight.controller.sal.flowprogrammer.Flow;
22 * Represents the flow that is installed on the network node
23 * along with the table location, hit counters and timers
26 @XmlRootElement (name="FlowStat")
27 @XmlAccessorType(XmlAccessType.NONE)
28 public class FlowOnNode implements Serializable{
29 private static final long serialVersionUID = 1L;
32 private Flow flow; // Flow descriptor
36 private int durationSeconds;
38 private int durationNanoseconds;
40 private long packetCount;
42 private long byteCount;
44 /* Dummy constructor for JAXB */
45 @SuppressWarnings("unused")
46 private FlowOnNode () {
49 public FlowOnNode(Flow flow) {
54 * Returns the description of the flow which statistics are about
57 public Flow getFlow() {
62 * Set the packet count's value
65 public void setPacketCount(long count) {
70 * Set the byte count's value
73 public void setByteCount(long count) {
78 * Returns the packet count for the flow
81 public long getPacketCount() {
86 * Return the byte count for the flow
89 public long getByteCount() {
93 public byte getTableId() {
97 public void setTableId(byte tableId) {
98 this.tableId = tableId;
101 public int getDurationSeconds() {
102 return durationSeconds;
105 public void setDurationSeconds(int durationSeconds) {
106 this.durationSeconds = durationSeconds;
109 public int getDurationNanoseconds() {
110 return durationNanoseconds;
113 public void setDurationNanoseconds(int durationNanoseconds) {
114 this.durationNanoseconds = durationNanoseconds;
118 public int hashCode() {
119 final int prime = 31;
121 result = prime * result + (int) (byteCount ^ (byteCount >>> 32));
122 result = prime * result + durationNanoseconds;
123 result = prime * result + durationSeconds;
124 result = prime * result + ((flow == null) ? 0 : flow.hashCode());
125 result = prime * result + (int) (packetCount ^ (packetCount >>> 32));
126 result = prime * result + tableId;
131 public boolean equals(Object obj) {
138 if (!(obj instanceof FlowOnNode)) {
141 FlowOnNode other = (FlowOnNode) obj;
142 if (byteCount != other.byteCount) {
145 if (durationNanoseconds != other.durationNanoseconds) {
148 if (durationSeconds != other.durationSeconds) {
152 if (other.flow != null) {
155 } else if (!flow.equals(other.flow)) {
158 if (packetCount != other.packetCount) {
161 if (tableId != other.tableId) {
168 public String toString() {
169 return "FlowOnNode[flow =" + flow + ", tableId = " + tableId
170 + ", sec = " + durationSeconds + ", nsec = "
171 + durationNanoseconds + ", pkt = " + packetCount + ", byte = "