2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.protocol.pcep.object;
10 import java.util.Collections;
11 import java.util.List;
13 import org.opendaylight.protocol.pcep.PCEPObject;
14 import org.opendaylight.protocol.pcep.PCEPTlv;
15 import com.google.common.base.Objects.ToStringHelper;
18 * The GLOBAL CONSTRAINTS Object is used in a PCReq message to specify the
19 * necessary global constraints that should be applied to all individual path
20 * computations for a global concurrent path optimization request.
22 * @see <a href="http://tools.ietf.org/html/rfc5557#section-5.5">GLOBAL
23 * CONSTRAINTS (GC) Object</a>
25 public class PCEPGlobalConstraintsObject extends PCEPObject {
27 private final short maxHop;
28 private final short maxUtilization;
29 private final short minUtilization;
30 private final short overBookingFactor;
32 private List<PCEPTlv> tlvs;
35 * Constructs Global Constraints Object with all mandatory fields.
39 * @param maxUtilization
40 * 8-bit integer between 0 and 100
41 * @param minUtilization
42 * 8-bit integer between 0 and 100
43 * @param overBookingFactor
50 public PCEPGlobalConstraintsObject(short maxhop, short maxUtilization, short minUtilization, short overBookingFactor, boolean processed, boolean ignored) {
51 this(maxhop, maxUtilization, minUtilization, overBookingFactor, null, processed, ignored);
55 * Constructs Global Constraints Object with all mandatory fields and
56 * optional list of tlvs.
60 * @param maxUtilization
61 * 8-bit integer between 0 and 100
62 * @param minUtilization
63 * 8-bit integer between 0 and 100
64 * @param overBookingFactor
73 public PCEPGlobalConstraintsObject(short maxhop, short maxUtilization, short minUtilization, short overBookingFactor, List<PCEPTlv> tlvs,
74 boolean processed, boolean ignored) {
75 super(processed, ignored);
78 if (maxUtilization < 0 || maxUtilization > 100)
79 throw new IllegalArgumentException("Maximu utilization can be only between 0 and 100. Passed: " + maxUtilization);
80 this.maxUtilization = maxUtilization;
82 if (minUtilization < 0 || minUtilization > 100)
83 throw new IllegalArgumentException("Minimum utilization can be only between 0 and 100. Passed: " + minUtilization);
84 this.minUtilization = minUtilization;
86 this.overBookingFactor = overBookingFactor;
89 this.tlvs = Collections.emptyList();
95 * Gets the maximum hop count for all the TE LSPs
97 * @return the maximum hop count
99 public short getMaxHop() {
104 * Gets the maximum utilization percentage by which all links should be
107 * @return the maximum utilization percentage
109 public short getMaxUtilization() {
110 return this.maxUtilization;
114 * Gets the minimum utilization percentage by which all links should be
117 * @return the maximum utilization percentage
119 public short getMinUtilization() {
120 return this.minUtilization;
124 * Gets the over booking factor percentage that allows the reserved
125 * bandwidth to be overbooked on each link beyond its physical capacity
128 * @return the over booking factor percentage
130 public short getOverBookingFactor() {
131 return this.overBookingFactor;
135 * Gets the list of optional tlvs
137 * @return List<PCEPTlv>. Can be empty but not null.
139 public List<PCEPTlv> getTlvs() {
144 protected ToStringHelper addToStringAttributes(ToStringHelper toStringHelper) {
145 toStringHelper.add("maxHop", this.maxHop);
146 toStringHelper.add("maxUtilization", this.maxUtilization);
147 toStringHelper.add("minUtilization", this.minUtilization);
148 toStringHelper.add("overBookingFactor", this.overBookingFactor);
149 toStringHelper.add("tlvs", this.tlvs);
150 return super.addToStringAttributes(toStringHelper);
154 public int hashCode() {
155 final int prime = 31;
156 int result = super.hashCode();
157 result = prime * result + this.maxHop;
158 result = prime * result + this.maxUtilization;
159 result = prime * result + this.minUtilization;
160 result = prime * result + this.overBookingFactor;
165 public boolean equals(Object obj) {
168 if (!super.equals(obj))
170 if (this.getClass() != obj.getClass())
172 final PCEPGlobalConstraintsObject other = (PCEPGlobalConstraintsObject) obj;
173 if (this.maxHop != other.maxHop)
175 if (this.maxUtilization != other.maxUtilization)
177 if (this.minUtilization != other.minUtilization)
179 if (this.overBookingFactor != other.overBookingFactor)