blob: 6497e36a535d35e4df3d8bf6a3fb1af115528446 [file] [log] [blame]
Mahesh Poojary Sf920ec02016-05-17 23:16:09 +05301/*
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 */
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
Mahesh Poojary Sf920ec02016-05-17 23:16:09 +053046 /**
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 Bbae0eeb12016-11-30 11:59:48 +053054 * @param explicitPathInfo explicit path info
Mahesh Poojary Sf920ec02016-05-17 23:16:09 +053055 */
56 public PcePathInfo(DeviceId src,
57 DeviceId dst,
58 String name,
59 List<Constraint> constraints,
Priyanka Bbae0eeb12016-11-30 11:59:48 +053060 LspType lspType,
61 List<ExplicitPathInfo> explicitPathInfo) {
Mahesh Poojary Sf920ec02016-05-17 23:16:09 +053062 this.src = src;
63 this.dst = dst;
64 this.name = name;
65 this.constraints = constraints;
66 this.lspType = lspType;
Priyanka Bbae0eeb12016-11-30 11:59:48 +053067 this.explicitPathInfo = explicitPathInfo;
Mahesh Poojary Sf920ec02016-05-17 23:16:09 +053068 }
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 Bbae0eeb12016-11-30 11:59:48 +053079 this.explicitPathInfo = null;
Mahesh Poojary Sf920ec02016-05-17 23:16:09 +053080 }
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 Bbae0eeb12016-11-30 11:59:48 +0530172 /**
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 Sf920ec02016-05-17 23:16:09 +0530190 @Override
191 public int hashCode() {
Priyanka Bbae0eeb12016-11-30 11:59:48 +0530192 return Objects.hash(src, dst, name, constraints, lspType, explicitPathInfo);
Mahesh Poojary Sf920ec02016-05-17 23:16:09 +0530193 }
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 Bbae0eeb12016-11-30 11:59:48 +0530206 Objects.equals(this.lspType, other.lspType) &&
207 Objects.equals(this.explicitPathInfo, other.explicitPathInfo);
Mahesh Poojary Sf920ec02016-05-17 23:16:09 +0530208 }
209 return false;
210 }
211
212 @Override
213 public String toString() {
214 return MoreObjects.toStringHelper(getClass())
215 .omitNullValues()
Priyanka Bbae0eeb12016-11-30 11:59:48 +0530216 .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 Sf920ec02016-05-17 23:16:09 +0530222 .toString();
223 }
224}