blob: 444f45ffd60c17275ee53ea645cdf18d3ea84b6d [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;
35 private final String downBpInfo;
36 private final String upBpInfo;
37
38 /**
39 * Builds the mapper of information.
Andrea Campanella0c3309d2020-05-29 01:51:18 -070040 * @param nniPort the nni port
41 * @param uniPort the uni port
42 * @param tagInfo the tag info
43 * @param downId the downstream meter id
44 * @param upId the upstream meter id
45 * @param downBpInfo the downstream bandwidth profile
46 * @param upBpInfo the upstream bandwidth profile
47 */
Tunahan Sezenf0843b92021-04-30 07:13:16 +000048 SubscriberFlowInfo(AccessDevicePort nniPort, AccessDevicePort uniPort,
Andrea Campanella0c3309d2020-05-29 01:51:18 -070049 UniTagInformation tagInfo, MeterId downId, MeterId upId,
50 String downBpInfo, String upBpInfo) {
Tunahan Sezenf0843b92021-04-30 07:13:16 +000051 this.devId = uniPort.deviceId();
Andrea Campanella0c3309d2020-05-29 01:51:18 -070052 this.nniPort = nniPort;
53 this.uniPort = uniPort;
54 this.tagInfo = tagInfo;
55 this.downId = downId;
56 this.upId = upId;
57 this.downBpInfo = downBpInfo;
58 this.upBpInfo = upBpInfo;
59 }
60
61 /**
62 * Gets the device id of this subscriber and flow information.
63 *
64 * @return device id
65 */
66 DeviceId getDevId() {
67 return devId;
68 }
69
70 /**
71 * Gets the nni of this subscriber and flow information.
72 *
73 * @return nni port
74 */
Tunahan Sezenf0843b92021-04-30 07:13:16 +000075 AccessDevicePort getNniPort() {
Andrea Campanella0c3309d2020-05-29 01:51:18 -070076 return nniPort;
77 }
78
79 /**
80 * Gets the uni port of this subscriber and flow information.
81 *
82 * @return uni port
83 */
Tunahan Sezenf0843b92021-04-30 07:13:16 +000084 AccessDevicePort getUniPort() {
Andrea Campanella0c3309d2020-05-29 01:51:18 -070085 return uniPort;
86 }
87
88 /**
89 * Gets the tag of this subscriber and flow information.
90 *
91 * @return tag of the subscriber
92 */
93 UniTagInformation getTagInfo() {
94 return tagInfo;
95 }
96
97 /**
98 * Gets the downstream meter id of this subscriber and flow information.
99 *
100 * @return downstream meter id
101 */
102 MeterId getDownId() {
103 return downId;
104 }
105
106 /**
107 * Gets the upstream meter id of this subscriber and flow information.
108 *
109 * @return upstream meter id
110 */
111 MeterId getUpId() {
112 return upId;
113 }
114
115 /**
116 * Gets the downstream bandwidth profile of this subscriber and flow information.
117 *
118 * @return downstream bandwidth profile
119 */
120 String getDownBpInfo() {
121 return downBpInfo;
122 }
123
124 /**
125 * Gets the upstream bandwidth profile of this subscriber and flow information.
126 *
127 * @return upstream bandwidth profile.
128 */
129 String getUpBpInfo() {
130 return upBpInfo;
131 }
132
133 /**
134 * Sets the upstream meter id.
135 * @param upMeterId the upstream meter id
136 */
137 void setUpMeterId(MeterId upMeterId) {
138 this.upId = upMeterId;
139 }
140
141 /**
142 * Sets the downstream meter id.
143 * @param downMeterId the downstream meter id
144 */
145 void setDownMeterId(MeterId downMeterId) {
146 this.downId = downMeterId;
147 }
148
149 @Override
150 public boolean equals(Object o) {
151 if (this == o) {
152 return true;
153 }
154 if (o == null || getClass() != o.getClass()) {
155 return false;
156 }
157 SubscriberFlowInfo flowInfo = (SubscriberFlowInfo) o;
158 return devId.equals(flowInfo.devId) &&
159 nniPort.equals(flowInfo.nniPort) &&
160 uniPort.equals(flowInfo.uniPort) &&
161 tagInfo.equals(flowInfo.tagInfo) &&
Andrea Campanella0c3309d2020-05-29 01:51:18 -0700162 downBpInfo.equals(flowInfo.downBpInfo) &&
163 upBpInfo.equals(flowInfo.upBpInfo);
164 }
165
166 @Override
167 public int hashCode() {
Andrea Campanellac727a372020-06-09 17:34:38 +0200168 return Objects.hash(devId, nniPort, uniPort, tagInfo, downBpInfo, upBpInfo);
Andrea Campanella0c3309d2020-05-29 01:51:18 -0700169 }
170
171 @Override
172 public String toString() {
173 return com.google.common.base.MoreObjects.toStringHelper(this)
174 .add("devId", devId)
175 .add("nniPort", nniPort)
176 .add("uniPort", uniPort)
177 .add("tagInfo", tagInfo)
178 .add("downId", downId)
179 .add("upId", upId)
180 .add("downBpInfo", downBpInfo)
181 .add("upBpInfo", upBpInfo)
182 .toString();
183 }
184}