Mahesh Poojary S | f920ec0 | 2016-05-17 23:16:09 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-present Open Networking Laboratory |
| 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.onosproject.pce.pcestore; |
| 17 | |
| 18 | import com.google.common.base.MoreObjects; |
| 19 | |
| 20 | import java.util.List; |
| 21 | import java.util.Objects; |
| 22 | |
| 23 | import org.onosproject.net.DeviceId; |
| 24 | import org.onosproject.net.intent.Constraint; |
Priyanka B | bae0eeb1 | 2016-11-30 11:59:48 +0530 | [diff] [blame^] | 25 | import org.onosproject.pce.pceservice.ExplicitPathInfo; |
Mahesh Poojary S | f920ec0 | 2016-05-17 23:16:09 +0530 | [diff] [blame] | 26 | import org.onosproject.pce.pceservice.LspType; |
| 27 | |
| 28 | /** |
| 29 | * Input path information to compute CSPF path. |
| 30 | * This path information will be stored in pce store and will be used later to recalculate the path. |
| 31 | */ |
| 32 | public final class PcePathInfo { |
| 33 | |
| 34 | private DeviceId src; // source path |
| 35 | |
| 36 | private DeviceId dst; // destination path |
| 37 | |
| 38 | private String name; // tunnel name |
| 39 | |
| 40 | private List<Constraint> constraints; // list of constraints (cost, bandwidth, etc.) |
| 41 | |
| 42 | private LspType lspType; // lsp type |
| 43 | |
Priyanka B | bae0eeb1 | 2016-11-30 11:59:48 +0530 | [diff] [blame^] | 44 | private List<ExplicitPathInfo> explicitPathInfo; //Explicit path info to compute explicit path |
| 45 | |
Mahesh Poojary S | f920ec0 | 2016-05-17 23:16:09 +0530 | [diff] [blame] | 46 | /** |
| 47 | * Initialization of member variables. |
| 48 | * |
| 49 | * @param src source device id |
| 50 | * @param dst destination device id |
| 51 | * @param name tunnel name |
| 52 | * @param constraints list of constraints |
| 53 | * @param lspType lsp type |
Priyanka B | bae0eeb1 | 2016-11-30 11:59:48 +0530 | [diff] [blame^] | 54 | * @param explicitPathInfo explicit path info |
Mahesh Poojary S | f920ec0 | 2016-05-17 23:16:09 +0530 | [diff] [blame] | 55 | */ |
| 56 | public PcePathInfo(DeviceId src, |
| 57 | DeviceId dst, |
| 58 | String name, |
| 59 | List<Constraint> constraints, |
Priyanka B | bae0eeb1 | 2016-11-30 11:59:48 +0530 | [diff] [blame^] | 60 | LspType lspType, |
| 61 | List<ExplicitPathInfo> explicitPathInfo) { |
Mahesh Poojary S | f920ec0 | 2016-05-17 23:16:09 +0530 | [diff] [blame] | 62 | this.src = src; |
| 63 | this.dst = dst; |
| 64 | this.name = name; |
| 65 | this.constraints = constraints; |
| 66 | this.lspType = lspType; |
Priyanka B | bae0eeb1 | 2016-11-30 11:59:48 +0530 | [diff] [blame^] | 67 | this.explicitPathInfo = explicitPathInfo; |
Mahesh Poojary S | f920ec0 | 2016-05-17 23:16:09 +0530 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Initialization for serialization. |
| 72 | */ |
| 73 | public PcePathInfo() { |
| 74 | this.src = null; |
| 75 | this.dst = null; |
| 76 | this.name = null; |
| 77 | this.constraints = null; |
| 78 | this.lspType = null; |
Priyanka B | bae0eeb1 | 2016-11-30 11:59:48 +0530 | [diff] [blame^] | 79 | this.explicitPathInfo = null; |
Mahesh Poojary S | f920ec0 | 2016-05-17 23:16:09 +0530 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Returns source device id. |
| 84 | * |
| 85 | * @return source device id |
| 86 | */ |
| 87 | public DeviceId src() { |
| 88 | return src; |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * Sets source device id. |
| 93 | * |
| 94 | * @param id source device id |
| 95 | */ |
| 96 | public void src(DeviceId id) { |
| 97 | this.src = id; |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * Returns destination device id. |
| 102 | * |
| 103 | * @return destination device id |
| 104 | */ |
| 105 | public DeviceId dst() { |
| 106 | return dst; |
| 107 | } |
| 108 | |
| 109 | /** |
| 110 | * Sets destination device id. |
| 111 | * |
| 112 | * @param id destination device id |
| 113 | */ |
| 114 | public void dst(DeviceId id) { |
| 115 | this.dst = id; |
| 116 | } |
| 117 | |
| 118 | |
| 119 | /** |
| 120 | * Returns tunnel name. |
| 121 | * |
| 122 | * @return name |
| 123 | */ |
| 124 | public String name() { |
| 125 | return name; |
| 126 | } |
| 127 | |
| 128 | /** |
| 129 | * Sets tunnel name. |
| 130 | * |
| 131 | * @param name tunnel name |
| 132 | */ |
| 133 | public void name(String name) { |
| 134 | this.name = name; |
| 135 | } |
| 136 | |
| 137 | /** |
| 138 | * Returns list of constraints including cost, bandwidth, etc. |
| 139 | * |
| 140 | * @return list of constraints |
| 141 | */ |
| 142 | public List<Constraint> constraints() { |
| 143 | return constraints; |
| 144 | } |
| 145 | |
| 146 | /** |
| 147 | * Sets list of constraints. |
| 148 | * @param constraints list of constraints |
| 149 | */ |
| 150 | public void constraints(List<Constraint> constraints) { |
| 151 | this.constraints = constraints; |
| 152 | } |
| 153 | |
| 154 | /** |
| 155 | * Returns lsp type. |
| 156 | * |
| 157 | * @return lsp type |
| 158 | */ |
| 159 | public LspType lspType() { |
| 160 | return lspType; |
| 161 | } |
| 162 | |
| 163 | /** |
| 164 | * Sets lsp type. |
| 165 | * |
| 166 | * @param lspType lsp type |
| 167 | */ |
| 168 | public void lspType(LspType lspType) { |
| 169 | this.lspType = lspType; |
| 170 | } |
| 171 | |
Priyanka B | bae0eeb1 | 2016-11-30 11:59:48 +0530 | [diff] [blame^] | 172 | /** |
| 173 | * Returns list of explicit path info. |
| 174 | * |
| 175 | * @return list of explicit path info |
| 176 | */ |
| 177 | public List<ExplicitPathInfo> explicitPathInfo() { |
| 178 | return explicitPathInfo; |
| 179 | } |
| 180 | |
| 181 | /** |
| 182 | * Sets list of explicit path info. |
| 183 | * |
| 184 | * @param explicitPathInfo list of explicit path info |
| 185 | */ |
| 186 | public void explicitPathInfo(List<ExplicitPathInfo> explicitPathInfo) { |
| 187 | this.explicitPathInfo = explicitPathInfo; |
| 188 | } |
| 189 | |
Mahesh Poojary S | f920ec0 | 2016-05-17 23:16:09 +0530 | [diff] [blame] | 190 | @Override |
| 191 | public int hashCode() { |
Priyanka B | bae0eeb1 | 2016-11-30 11:59:48 +0530 | [diff] [blame^] | 192 | return Objects.hash(src, dst, name, constraints, lspType, explicitPathInfo); |
Mahesh Poojary S | f920ec0 | 2016-05-17 23:16:09 +0530 | [diff] [blame] | 193 | } |
| 194 | |
| 195 | @Override |
| 196 | public boolean equals(Object obj) { |
| 197 | if (this == obj) { |
| 198 | return true; |
| 199 | } |
| 200 | if (obj instanceof PcePathInfo) { |
| 201 | final PcePathInfo other = (PcePathInfo) obj; |
| 202 | return Objects.equals(this.src, other.src) && |
| 203 | Objects.equals(this.dst, other.dst) && |
| 204 | Objects.equals(this.name, other.name) && |
| 205 | Objects.equals(this.constraints, other.constraints) && |
Priyanka B | bae0eeb1 | 2016-11-30 11:59:48 +0530 | [diff] [blame^] | 206 | Objects.equals(this.lspType, other.lspType) && |
| 207 | Objects.equals(this.explicitPathInfo, other.explicitPathInfo); |
Mahesh Poojary S | f920ec0 | 2016-05-17 23:16:09 +0530 | [diff] [blame] | 208 | } |
| 209 | return false; |
| 210 | } |
| 211 | |
| 212 | @Override |
| 213 | public String toString() { |
| 214 | return MoreObjects.toStringHelper(getClass()) |
| 215 | .omitNullValues() |
Priyanka B | bae0eeb1 | 2016-11-30 11:59:48 +0530 | [diff] [blame^] | 216 | .add("Source", src) |
| 217 | .add("Destination", dst) |
| 218 | .add("Name", name) |
| 219 | .add("Constraints", constraints) |
| 220 | .add("explicitPathInfo", explicitPathInfo) |
| 221 | .add("LspType", lspType) |
Mahesh Poojary S | f920ec0 | 2016-05-17 23:16:09 +0530 | [diff] [blame] | 222 | .toString(); |
| 223 | } |
| 224 | } |