blob: 577296916e6d854d31786a191279d914b06e2d71 [file] [log] [blame]
Mahesh Poojary Sf920ec02016-05-17 23:16:09 +05301/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Mahesh Poojary Sf920ec02016-05-17 23:16:09 +05303 *
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.onosproject.pce.pcestore;
17
18import com.google.common.base.MoreObjects;
19
20import java.util.List;
21import java.util.Objects;
22
23import org.onosproject.net.DeviceId;
24import org.onosproject.net.intent.Constraint;
Priyanka Bbae0eeb12016-11-30 11:59:48 +053025import org.onosproject.pce.pceservice.ExplicitPathInfo;
Mahesh Poojary Sf920ec02016-05-17 23:16:09 +053026import 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 */
32public 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 Bbae0eeb12016-11-30 11:59:48 +053044 private List<ExplicitPathInfo> explicitPathInfo; //Explicit path info to compute explicit path
45
Satish Kba1c9122017-04-05 15:27:23 +053046 private boolean loadBalancing; //load balancing option
47
Mahesh Poojary Sf920ec02016-05-17 23:16:09 +053048 /**
49 * Initialization of member variables.
50 *
51 * @param src source device id
52 * @param dst destination device id
53 * @param name tunnel name
54 * @param constraints list of constraints
55 * @param lspType lsp type
Priyanka Bbae0eeb12016-11-30 11:59:48 +053056 * @param explicitPathInfo explicit path info
Satish Kba1c9122017-04-05 15:27:23 +053057 * @param loadBalancing load balancing option
Mahesh Poojary Sf920ec02016-05-17 23:16:09 +053058 */
59 public PcePathInfo(DeviceId src,
60 DeviceId dst,
61 String name,
62 List<Constraint> constraints,
Priyanka Bbae0eeb12016-11-30 11:59:48 +053063 LspType lspType,
Satish Kba1c9122017-04-05 15:27:23 +053064 List<ExplicitPathInfo> explicitPathInfo,
65 boolean loadBalancing) {
Mahesh Poojary Sf920ec02016-05-17 23:16:09 +053066 this.src = src;
67 this.dst = dst;
68 this.name = name;
69 this.constraints = constraints;
70 this.lspType = lspType;
Priyanka Bbae0eeb12016-11-30 11:59:48 +053071 this.explicitPathInfo = explicitPathInfo;
Satish Kba1c9122017-04-05 15:27:23 +053072 this.loadBalancing = loadBalancing;
Mahesh Poojary Sf920ec02016-05-17 23:16:09 +053073 }
74
75 /**
76 * Initialization for serialization.
77 */
78 public PcePathInfo() {
79 this.src = null;
80 this.dst = null;
81 this.name = null;
82 this.constraints = null;
83 this.lspType = null;
Priyanka Bbae0eeb12016-11-30 11:59:48 +053084 this.explicitPathInfo = null;
Satish Kba1c9122017-04-05 15:27:23 +053085 this.loadBalancing = false;
Mahesh Poojary Sf920ec02016-05-17 23:16:09 +053086 }
87
88 /**
89 * Returns source device id.
90 *
91 * @return source device id
92 */
93 public DeviceId src() {
94 return src;
95 }
96
97 /**
98 * Sets source device id.
99 *
100 * @param id source device id
101 */
102 public void src(DeviceId id) {
103 this.src = id;
104 }
105
106 /**
107 * Returns destination device id.
108 *
109 * @return destination device id
110 */
111 public DeviceId dst() {
112 return dst;
113 }
114
115 /**
116 * Sets destination device id.
117 *
118 * @param id destination device id
119 */
120 public void dst(DeviceId id) {
121 this.dst = id;
122 }
123
124
125 /**
126 * Returns tunnel name.
127 *
128 * @return name
129 */
130 public String name() {
131 return name;
132 }
133
134 /**
135 * Sets tunnel name.
136 *
137 * @param name tunnel name
138 */
139 public void name(String name) {
140 this.name = name;
141 }
142
143 /**
144 * Returns list of constraints including cost, bandwidth, etc.
145 *
146 * @return list of constraints
147 */
148 public List<Constraint> constraints() {
149 return constraints;
150 }
151
152 /**
153 * Sets list of constraints.
154 * @param constraints list of constraints
155 */
156 public void constraints(List<Constraint> constraints) {
157 this.constraints = constraints;
158 }
159
160 /**
161 * Returns lsp type.
162 *
163 * @return lsp type
164 */
165 public LspType lspType() {
166 return lspType;
167 }
168
169 /**
170 * Sets lsp type.
171 *
172 * @param lspType lsp type
173 */
174 public void lspType(LspType lspType) {
175 this.lspType = lspType;
176 }
177
Priyanka Bbae0eeb12016-11-30 11:59:48 +0530178 /**
179 * Returns list of explicit path info.
180 *
181 * @return list of explicit path info
182 */
183 public List<ExplicitPathInfo> explicitPathInfo() {
184 return explicitPathInfo;
185 }
186
187 /**
188 * Sets list of explicit path info.
189 *
190 * @param explicitPathInfo list of explicit path info
191 */
192 public void explicitPathInfo(List<ExplicitPathInfo> explicitPathInfo) {
193 this.explicitPathInfo = explicitPathInfo;
194 }
195
Satish Kba1c9122017-04-05 15:27:23 +0530196 /**
197 * Returns whether stored path has enabled load balancing.
198 *
199 * @return load balancing option is enable
200 */
201 public boolean isLoadBalancing() {
202 return loadBalancing;
203 }
204
205 /**
206 * Sets load balancing option is enable.
207 *
208 * @param loadBalancing load balancing option is enable
209 */
210 public void loadBalancing(boolean loadBalancing) {
211 this.loadBalancing = loadBalancing;
212 }
213
Mahesh Poojary Sf920ec02016-05-17 23:16:09 +0530214 @Override
215 public int hashCode() {
Satish Kba1c9122017-04-05 15:27:23 +0530216 return Objects.hash(src, dst, name, constraints, lspType, explicitPathInfo, loadBalancing);
Mahesh Poojary Sf920ec02016-05-17 23:16:09 +0530217 }
218
219 @Override
220 public boolean equals(Object obj) {
221 if (this == obj) {
222 return true;
223 }
224 if (obj instanceof PcePathInfo) {
225 final PcePathInfo other = (PcePathInfo) obj;
226 return Objects.equals(this.src, other.src) &&
227 Objects.equals(this.dst, other.dst) &&
228 Objects.equals(this.name, other.name) &&
229 Objects.equals(this.constraints, other.constraints) &&
Priyanka Bbae0eeb12016-11-30 11:59:48 +0530230 Objects.equals(this.lspType, other.lspType) &&
Satish Kba1c9122017-04-05 15:27:23 +0530231 Objects.equals(this.explicitPathInfo, other.explicitPathInfo) &&
232 Objects.equals(this.loadBalancing, other.loadBalancing);
Mahesh Poojary Sf920ec02016-05-17 23:16:09 +0530233 }
234 return false;
235 }
236
237 @Override
238 public String toString() {
239 return MoreObjects.toStringHelper(getClass())
240 .omitNullValues()
Priyanka Bbae0eeb12016-11-30 11:59:48 +0530241 .add("Source", src)
242 .add("Destination", dst)
243 .add("Name", name)
244 .add("Constraints", constraints)
245 .add("explicitPathInfo", explicitPathInfo)
246 .add("LspType", lspType)
Satish Kba1c9122017-04-05 15:27:23 +0530247 .add("loadBalancing", loadBalancing)
Mahesh Poojary Sf920ec02016-05-17 23:16:09 +0530248 .toString();
249 }
250}