blob: 225e48f30f0b951b6dd2ca4ad715ad6e80bac3ae [file] [log] [blame]
Andrea Campanella0c3309d2020-05-29 01:51:18 -07001/*
2 * Copyright 2020-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.opencord.olt.impl;
17
18import org.onosproject.net.DeviceId;
Andrea Campanella0c3309d2020-05-29 01:51:18 -070019import org.onosproject.net.meter.MeterId;
Tunahan Sezenf0843b92021-04-30 07:13:16 +000020import org.opencord.olt.AccessDevicePort;
Andrea Campanella0c3309d2020-05-29 01:51:18 -070021import org.opencord.sadis.UniTagInformation;
22
23import java.util.Objects;
24
25/**
26 * Contains the mapping of a given port to flow information, including bandwidth profile.
27 */
28class SubscriberFlowInfo {
29 private final DeviceId devId;
Tunahan Sezenf0843b92021-04-30 07:13:16 +000030 private final AccessDevicePort nniPort;
31 private final AccessDevicePort uniPort;
Andrea Campanella0c3309d2020-05-29 01:51:18 -070032 private final UniTagInformation tagInfo;
33 private MeterId downId;
34 private MeterId upId;
yasin saplib4b8ee12021-06-13 18:25:20 +000035 private MeterId downOltId;
36 private MeterId upOltId;
Andrea Campanella0c3309d2020-05-29 01:51:18 -070037 private final String downBpInfo;
38 private final String upBpInfo;
yasin saplib4b8ee12021-06-13 18:25:20 +000039 private final String downOltBpInfo;
40 private final String upOltBpInfo;
Andrea Campanella0c3309d2020-05-29 01:51:18 -070041
42 /**
43 * Builds the mapper of information.
yasin saplib4b8ee12021-06-13 18:25:20 +000044 * @param nniPort the nni port
45 * @param uniPort the uni port
46 * @param tagInfo the tag info
47 * @param downId the downstream meter id
48 * @param upId the upstream meter id
49 * @param downOltId the downstream meter id of OLT device
50 * @param upOltId the upstream meter id of OLT device
51 * @param downBpInfo the downstream bandwidth profile
52 * @param upBpInfo the upstream bandwidth profile
53 * @param downOltBpInfo the downstream bandwidth profile of OLT device
54 * @param upOltBpInfo the upstream bandwidth profile of OLT device
Andrea Campanella0c3309d2020-05-29 01:51:18 -070055 */
Tunahan Sezenf0843b92021-04-30 07:13:16 +000056 SubscriberFlowInfo(AccessDevicePort nniPort, AccessDevicePort uniPort,
Andrea Campanella0c3309d2020-05-29 01:51:18 -070057 UniTagInformation tagInfo, MeterId downId, MeterId upId,
yasin saplib4b8ee12021-06-13 18:25:20 +000058 MeterId downOltId, MeterId upOltId,
59 String downBpInfo, String upBpInfo,
60 String downOltBpInfo, String upOltBpInfo) {
Tunahan Sezenf0843b92021-04-30 07:13:16 +000061 this.devId = uniPort.deviceId();
Andrea Campanella0c3309d2020-05-29 01:51:18 -070062 this.nniPort = nniPort;
63 this.uniPort = uniPort;
64 this.tagInfo = tagInfo;
65 this.downId = downId;
66 this.upId = upId;
yasin saplib4b8ee12021-06-13 18:25:20 +000067 this.downOltId = downOltId;
68 this.upOltId = upOltId;
Andrea Campanella0c3309d2020-05-29 01:51:18 -070069 this.downBpInfo = downBpInfo;
70 this.upBpInfo = upBpInfo;
yasin saplib4b8ee12021-06-13 18:25:20 +000071 this.downOltBpInfo = downOltBpInfo;
72 this.upOltBpInfo = upOltBpInfo;
Andrea Campanella0c3309d2020-05-29 01:51:18 -070073 }
74
75 /**
76 * Gets the device id of this subscriber and flow information.
77 *
78 * @return device id
79 */
80 DeviceId getDevId() {
81 return devId;
82 }
83
84 /**
85 * Gets the nni of this subscriber and flow information.
86 *
87 * @return nni port
88 */
Tunahan Sezenf0843b92021-04-30 07:13:16 +000089 AccessDevicePort getNniPort() {
Andrea Campanella0c3309d2020-05-29 01:51:18 -070090 return nniPort;
91 }
92
93 /**
94 * Gets the uni port of this subscriber and flow information.
95 *
96 * @return uni port
97 */
Tunahan Sezenf0843b92021-04-30 07:13:16 +000098 AccessDevicePort getUniPort() {
Andrea Campanella0c3309d2020-05-29 01:51:18 -070099 return uniPort;
100 }
101
102 /**
103 * Gets the tag of this subscriber and flow information.
104 *
105 * @return tag of the subscriber
106 */
107 UniTagInformation getTagInfo() {
108 return tagInfo;
109 }
110
111 /**
112 * Gets the downstream meter id of this subscriber and flow information.
113 *
114 * @return downstream meter id
115 */
116 MeterId getDownId() {
117 return downId;
118 }
119
120 /**
121 * Gets the upstream meter id of this subscriber and flow information.
122 *
123 * @return upstream meter id
124 */
125 MeterId getUpId() {
126 return upId;
127 }
128
129 /**
yasin saplib4b8ee12021-06-13 18:25:20 +0000130 * Gets the downstream meter id of this subscriber and flow information of OLT device.
131 *
132 * @return downstream olt meter id
133 */
134 MeterId getDownOltId() {
135 return downOltId;
136 }
137
138 /**
139 * Gets the upstream meter id of this subscriber and flow information of OLT device.
140 *
141 * @return upstream olt meter id
142 */
143 MeterId getUpOltId() {
144 return upOltId;
145 }
146
147 /**
Andrea Campanella0c3309d2020-05-29 01:51:18 -0700148 * Gets the downstream bandwidth profile of this subscriber and flow information.
149 *
150 * @return downstream bandwidth profile
151 */
152 String getDownBpInfo() {
153 return downBpInfo;
154 }
155
156 /**
157 * Gets the upstream bandwidth profile of this subscriber and flow information.
158 *
159 * @return upstream bandwidth profile.
160 */
161 String getUpBpInfo() {
162 return upBpInfo;
163 }
164
165 /**
yasin saplib4b8ee12021-06-13 18:25:20 +0000166 * Gets the downstream bandwidth profile of this subscriber and flow information of OLT device.
167 *
168 * @return downstream OLT bandwidth profile
169 */
170 String getDownOltBpInfo() {
171 return downOltBpInfo;
172 }
173
174 /**
175 * Gets the upstream bandwidth profile of this subscriber and flow information of OLT device.
176 *
177 * @return upstream OLT bandwidth profile.
178 */
179 String getUpOltBpInfo() {
180 return upOltBpInfo;
181 }
182
183 /**
Andrea Campanella0c3309d2020-05-29 01:51:18 -0700184 * Sets the upstream meter id.
yasin saplib4b8ee12021-06-13 18:25:20 +0000185 *
Andrea Campanella0c3309d2020-05-29 01:51:18 -0700186 * @param upMeterId the upstream meter id
187 */
188 void setUpMeterId(MeterId upMeterId) {
189 this.upId = upMeterId;
190 }
191
192 /**
193 * Sets the downstream meter id.
yasin saplib4b8ee12021-06-13 18:25:20 +0000194 *
Andrea Campanella0c3309d2020-05-29 01:51:18 -0700195 * @param downMeterId the downstream meter id
196 */
197 void setDownMeterId(MeterId downMeterId) {
198 this.downId = downMeterId;
199 }
200
yasin saplib4b8ee12021-06-13 18:25:20 +0000201 /**
202 * Sets the upstream meter id of OLT.
203 *
204 * @param upOltMeterId the upstream meter id of OLT
205 */
206 void setUpOltMeterId(MeterId upOltMeterId) {
207 this.upOltId = upOltMeterId;
208 }
209
210 /**
211 * Sets the downstream meter id of OLT.
212 *
213 * @param downOltMeterId the downstream meter id of OLT
214 */
215 void setDownOltMeterId(MeterId downOltMeterId) {
216 this.downOltId = downOltMeterId;
217 }
218
Andrea Campanella0c3309d2020-05-29 01:51:18 -0700219 @Override
220 public boolean equals(Object o) {
221 if (this == o) {
222 return true;
223 }
224 if (o == null || getClass() != o.getClass()) {
225 return false;
226 }
227 SubscriberFlowInfo flowInfo = (SubscriberFlowInfo) o;
228 return devId.equals(flowInfo.devId) &&
229 nniPort.equals(flowInfo.nniPort) &&
230 uniPort.equals(flowInfo.uniPort) &&
231 tagInfo.equals(flowInfo.tagInfo) &&
Andrea Campanella0c3309d2020-05-29 01:51:18 -0700232 downBpInfo.equals(flowInfo.downBpInfo) &&
yasin saplib4b8ee12021-06-13 18:25:20 +0000233 upBpInfo.equals(flowInfo.upBpInfo) &&
234 Objects.equals(downOltBpInfo, flowInfo.downOltBpInfo) &&
235 Objects.equals(upOltBpInfo, flowInfo.upOltBpInfo);
Andrea Campanella0c3309d2020-05-29 01:51:18 -0700236 }
237
238 @Override
239 public int hashCode() {
yasin saplib4b8ee12021-06-13 18:25:20 +0000240 return Objects.hash(devId, nniPort, uniPort, tagInfo, downBpInfo, upBpInfo, downOltBpInfo, upOltBpInfo);
Andrea Campanella0c3309d2020-05-29 01:51:18 -0700241 }
242
243 @Override
244 public String toString() {
245 return com.google.common.base.MoreObjects.toStringHelper(this)
246 .add("devId", devId)
247 .add("nniPort", nniPort)
248 .add("uniPort", uniPort)
249 .add("tagInfo", tagInfo)
250 .add("downId", downId)
251 .add("upId", upId)
yasin saplib4b8ee12021-06-13 18:25:20 +0000252 .add("downOltId", downOltId)
253 .add("upOltId", upOltId)
Andrea Campanella0c3309d2020-05-29 01:51:18 -0700254 .add("downBpInfo", downBpInfo)
255 .add("upBpInfo", upBpInfo)
yasin saplib4b8ee12021-06-13 18:25:20 +0000256 .add("downOltBpInfo", downOltBpInfo)
257 .add("upOltBpInfo", upOltBpInfo)
Andrea Campanella0c3309d2020-05-29 01:51:18 -0700258 .toString();
259 }
260}