blob: e41947d4178c099ab3088696e1e4917f95e75bd7 [file] [log] [blame]
Mahesh Poojary Sba827292016-05-09 11:31:12 +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
Mahesh Poojary Sba827292016-05-09 11:31:12 +053018import com.google.common.base.MoreObjects;
19
20import java.util.Objects;
Mahesh Poojary S33536202016-05-30 07:22:36 +053021import java.util.List;
Mahesh Poojary Sba827292016-05-09 11:31:12 +053022
23import org.onosproject.net.resource.ResourceConsumer;
24import org.onosproject.pce.pcestore.api.LspLocalLabelInfo;
25
26/**
27 * PCECC tunnel information is used to store
28 * list of links label information of a path containing IN, OUT label and destination port of a link
29 * to release label allocation in devices.
30 * Also storing resource consumer id to release bandwdith of a tunnel.
31 * The first entry is created with TunnelId and resource consumer id,
32 * later this entry may be updated to store label information on basic PCECC case.
33 */
34public final class PceccTunnelInfo {
35
36 private List<LspLocalLabelInfo> lspLocalLabelInfoList;
37
38 private ResourceConsumer tunnelConsumerId;
39
40 /**
41 * Initialization of member variables.
42 *
43 * @param lspLocalLabelInfoList list of devices local label info
44 * @param tunnelConsumerId tunnel consumer id
45 */
46 public PceccTunnelInfo(List<LspLocalLabelInfo> lspLocalLabelInfoList,
47 ResourceConsumer tunnelConsumerId) {
48 this.lspLocalLabelInfoList = lspLocalLabelInfoList;
49 this.tunnelConsumerId = tunnelConsumerId;
50 }
51
52 /**
53 * Initialization for serialization.
54 */
55 public PceccTunnelInfo() {
56 this.lspLocalLabelInfoList = null;
57 this.tunnelConsumerId = null;
58 }
59
60 /**
61 * Retrieves list of devices local label info.
62 *
63 * @return list of devices local label info
64 */
65 public List<LspLocalLabelInfo> lspLocalLabelInfoList() {
66 return this.lspLocalLabelInfoList;
67 }
68
69 /**
70 * Retrieves tunnel consumer id.
71 *
72 * @return tunnel consumer id
73 */
74 public ResourceConsumer tunnelConsumerId() {
75 return this.tunnelConsumerId;
76 }
77
78 /**
79 * Sets list of local label info of a path.
80 *
81 * @param lspLocalLabelInfoList list of devices local label info
82 */
83 public void lspLocalLabelInfoList(List<LspLocalLabelInfo> lspLocalLabelInfoList) {
84 this.lspLocalLabelInfoList = lspLocalLabelInfoList;
85 }
86
87 /**
88 * Sets tunnel consumer id.
89 *
90 * @param id tunnel consumer id
91 */
92 public void tunnelConsumerId(ResourceConsumer id) {
93 this.tunnelConsumerId = id;
94 }
95
96 @Override
97 public int hashCode() {
98 return Objects.hash(lspLocalLabelInfoList, tunnelConsumerId);
99 }
100
101 @Override
102 public boolean equals(Object obj) {
103 if (this == obj) {
104 return true;
105 }
106 if (obj instanceof PceccTunnelInfo) {
107 final PceccTunnelInfo other = (PceccTunnelInfo) obj;
108 return Objects.equals(this.lspLocalLabelInfoList, other.lspLocalLabelInfoList) &&
109 Objects.equals(this.tunnelConsumerId, other.tunnelConsumerId);
110 }
111 return false;
112 }
113
114 @Override
115 public String toString() {
116 return MoreObjects.toStringHelper(getClass())
117 .omitNullValues()
Priyanka B4c3b4512016-07-22 11:41:49 +0530118 .add("DeviceLabelInfoList", lspLocalLabelInfoList)
119 .add("TunnelConsumerId", tunnelConsumerId)
Mahesh Poojary Sba827292016-05-09 11:31:12 +0530120 .toString();
121 }
122}