BUG-2218: Keep existing link augmentations during discovery process
[controller.git] / opendaylight / sal / api / src / main / java / org / opendaylight / controller / sal / reader / FlowOnNode.java
1
2 /*
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
4  *
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
8  */
9
10 package org.opendaylight.controller.sal.reader;
11
12 import java.io.Serializable;
13
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;
18
19 import org.opendaylight.controller.sal.flowprogrammer.Flow;
20
21 /**
22  * Represents the flow that is installed on the network node
23  * along with the table location, hit counters and timers
24  */
25
26 @XmlRootElement (name="FlowStat")
27 @XmlAccessorType(XmlAccessType.NONE)
28 public class FlowOnNode implements Serializable{
29     private static final long serialVersionUID = 1L;
30
31     @XmlElement
32     private Flow flow; // Flow descriptor
33     @XmlElement
34     private byte tableId;
35     @XmlElement
36     private int durationSeconds;
37     @XmlElement
38     private int durationNanoseconds;
39     @XmlElement
40     private long packetCount;
41     @XmlElement
42     private long byteCount;
43
44     /* Dummy constructor for JAXB */
45     @SuppressWarnings("unused")
46     private FlowOnNode () {
47     }
48
49     public FlowOnNode(Flow flow) {
50         this.flow = flow;
51     }
52
53     /**
54      * Returns the description of the flow which statistics are about
55      * @return
56      */
57     public Flow getFlow() {
58         return flow;
59     }
60
61     /**
62      * Set the packet count's value
63      * @param count
64      */
65     public void setPacketCount(long count) {
66         packetCount = count;
67     }
68
69     /**
70      * Set the byte count's value
71      * @param count
72      */
73     public void setByteCount(long count) {
74         byteCount = count;
75     }
76
77     /**
78      * Returns the packet count for the flow
79      * @return
80      */
81     public long getPacketCount() {
82         return packetCount;
83     }
84
85     /**
86      * Return the byte count for the flow
87      * @return
88      */
89     public long getByteCount() {
90         return byteCount;
91     }
92
93     public byte getTableId() {
94         return tableId;
95     }
96
97     public void setTableId(byte tableId) {
98         this.tableId = tableId;
99     }
100
101     public int getDurationSeconds() {
102         return durationSeconds;
103     }
104
105     public void setDurationSeconds(int durationSeconds) {
106         this.durationSeconds = durationSeconds;
107     }
108
109     public int getDurationNanoseconds() {
110         return durationNanoseconds;
111     }
112
113     public void setDurationNanoseconds(int durationNanoseconds) {
114         this.durationNanoseconds = durationNanoseconds;
115     }
116
117     @Override
118     public int hashCode() {
119         final int prime = 31;
120         int result = 1;
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;
127         return result;
128     }
129
130     @Override
131     public boolean equals(Object obj) {
132         if (this == obj) {
133             return true;
134         }
135         if (obj == null) {
136             return false;
137         }
138         if (!(obj instanceof FlowOnNode)) {
139             return false;
140         }
141         FlowOnNode other = (FlowOnNode) obj;
142         if (byteCount != other.byteCount) {
143             return false;
144         }
145         if (durationNanoseconds != other.durationNanoseconds) {
146             return false;
147         }
148         if (durationSeconds != other.durationSeconds) {
149             return false;
150         }
151         if (flow == null) {
152             if (other.flow != null) {
153                 return false;
154             }
155         } else if (!flow.equals(other.flow)) {
156             return false;
157         }
158         if (packetCount != other.packetCount) {
159             return false;
160         }
161         if (tableId != other.tableId) {
162             return false;
163         }
164         return true;
165     }
166
167     @Override
168     public String toString() {
169         return "FlowOnNode[flow =" + flow + ", tableId = " + tableId
170                 + ", sec = " + durationSeconds + ", nsec = "
171                 + durationNanoseconds + ", pkt = " + packetCount + ", byte = "
172                 + byteCount + "]";
173     }
174 }