Andrea Campanella | 0c3309d | 2020-05-29 01:51:18 -0700 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package org.opencord.olt.impl; |
| 17 | |
| 18 | import org.onosproject.net.DeviceId; |
| 19 | import org.onosproject.net.PortNumber; |
| 20 | import org.onosproject.net.meter.MeterId; |
| 21 | import org.opencord.sadis.UniTagInformation; |
| 22 | |
| 23 | import java.util.Objects; |
| 24 | |
| 25 | /** |
| 26 | * Contains the mapping of a given port to flow information, including bandwidth profile. |
| 27 | */ |
| 28 | class SubscriberFlowInfo { |
| 29 | private final DeviceId devId; |
| 30 | private final PortNumber nniPort; |
| 31 | private final PortNumber uniPort; |
| 32 | 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. |
| 40 | * @param devId the device id |
| 41 | * @param nniPort the nni port |
| 42 | * @param uniPort the uni port |
| 43 | * @param tagInfo the tag info |
| 44 | * @param downId the downstream meter id |
| 45 | * @param upId the upstream meter id |
| 46 | * @param downBpInfo the downstream bandwidth profile |
| 47 | * @param upBpInfo the upstream bandwidth profile |
| 48 | */ |
| 49 | SubscriberFlowInfo(DeviceId devId, PortNumber nniPort, PortNumber uniPort, |
| 50 | UniTagInformation tagInfo, MeterId downId, MeterId upId, |
| 51 | String downBpInfo, String upBpInfo) { |
| 52 | this.devId = devId; |
| 53 | this.nniPort = nniPort; |
| 54 | this.uniPort = uniPort; |
| 55 | this.tagInfo = tagInfo; |
| 56 | this.downId = downId; |
| 57 | this.upId = upId; |
| 58 | this.downBpInfo = downBpInfo; |
| 59 | this.upBpInfo = upBpInfo; |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Gets the device id of this subscriber and flow information. |
| 64 | * |
| 65 | * @return device id |
| 66 | */ |
| 67 | DeviceId getDevId() { |
| 68 | return devId; |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Gets the nni of this subscriber and flow information. |
| 73 | * |
| 74 | * @return nni port |
| 75 | */ |
| 76 | PortNumber getNniPort() { |
| 77 | return nniPort; |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Gets the uni port of this subscriber and flow information. |
| 82 | * |
| 83 | * @return uni port |
| 84 | */ |
| 85 | PortNumber getUniPort() { |
| 86 | return uniPort; |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * Gets the tag of this subscriber and flow information. |
| 91 | * |
| 92 | * @return tag of the subscriber |
| 93 | */ |
| 94 | UniTagInformation getTagInfo() { |
| 95 | return tagInfo; |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * Gets the downstream meter id of this subscriber and flow information. |
| 100 | * |
| 101 | * @return downstream meter id |
| 102 | */ |
| 103 | MeterId getDownId() { |
| 104 | return downId; |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * Gets the upstream meter id of this subscriber and flow information. |
| 109 | * |
| 110 | * @return upstream meter id |
| 111 | */ |
| 112 | MeterId getUpId() { |
| 113 | return upId; |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * Gets the downstream bandwidth profile of this subscriber and flow information. |
| 118 | * |
| 119 | * @return downstream bandwidth profile |
| 120 | */ |
| 121 | String getDownBpInfo() { |
| 122 | return downBpInfo; |
| 123 | } |
| 124 | |
| 125 | /** |
| 126 | * Gets the upstream bandwidth profile of this subscriber and flow information. |
| 127 | * |
| 128 | * @return upstream bandwidth profile. |
| 129 | */ |
| 130 | String getUpBpInfo() { |
| 131 | return upBpInfo; |
| 132 | } |
| 133 | |
| 134 | /** |
| 135 | * Sets the upstream meter id. |
| 136 | * @param upMeterId the upstream meter id |
| 137 | */ |
| 138 | void setUpMeterId(MeterId upMeterId) { |
| 139 | this.upId = upMeterId; |
| 140 | } |
| 141 | |
| 142 | /** |
| 143 | * Sets the downstream meter id. |
| 144 | * @param downMeterId the downstream meter id |
| 145 | */ |
| 146 | void setDownMeterId(MeterId downMeterId) { |
| 147 | this.downId = downMeterId; |
| 148 | } |
| 149 | |
| 150 | @Override |
| 151 | public boolean equals(Object o) { |
| 152 | if (this == o) { |
| 153 | return true; |
| 154 | } |
| 155 | if (o == null || getClass() != o.getClass()) { |
| 156 | return false; |
| 157 | } |
| 158 | SubscriberFlowInfo flowInfo = (SubscriberFlowInfo) o; |
| 159 | return devId.equals(flowInfo.devId) && |
| 160 | nniPort.equals(flowInfo.nniPort) && |
| 161 | uniPort.equals(flowInfo.uniPort) && |
| 162 | tagInfo.equals(flowInfo.tagInfo) && |
Andrea Campanella | 0c3309d | 2020-05-29 01:51:18 -0700 | [diff] [blame] | 163 | downBpInfo.equals(flowInfo.downBpInfo) && |
| 164 | upBpInfo.equals(flowInfo.upBpInfo); |
| 165 | } |
| 166 | |
| 167 | @Override |
| 168 | public int hashCode() { |
Andrea Campanella | c727a37 | 2020-06-09 17:34:38 +0200 | [diff] [blame] | 169 | return Objects.hash(devId, nniPort, uniPort, tagInfo, downBpInfo, upBpInfo); |
Andrea Campanella | 0c3309d | 2020-05-29 01:51:18 -0700 | [diff] [blame] | 170 | } |
| 171 | |
| 172 | @Override |
| 173 | public String toString() { |
| 174 | return com.google.common.base.MoreObjects.toStringHelper(this) |
| 175 | .add("devId", devId) |
| 176 | .add("nniPort", nniPort) |
| 177 | .add("uniPort", uniPort) |
| 178 | .add("tagInfo", tagInfo) |
| 179 | .add("downId", downId) |
| 180 | .add("upId", upId) |
| 181 | .add("downBpInfo", downBpInfo) |
| 182 | .add("upBpInfo", upBpInfo) |
| 183 | .toString(); |
| 184 | } |
| 185 | } |