protected PathConstraints constraints = null;
/* Priority Queue and HashMap to manage path computation */
- protected PriorityQueue<CspfPath> priorityQueue;
- protected HashMap<Long, CspfPath> processedPath;
+ protected final PriorityQueue<CspfPath> priorityQueue = new PriorityQueue<>();
+ protected final HashMap<Long, CspfPath> processedPath = new HashMap<>();
- protected AbstractPathComputation(ConnectedGraph graph) {
+ protected AbstractPathComputation(final ConnectedGraph graph) {
this.graph = graph;
- priorityQueue = new PriorityQueue<CspfPath>();
- processedPath = new HashMap<Long, CspfPath>();
}
/**
* @return Constrained Path Builder with status set to 'OnGoing' if
* initialization success, 'Failed' otherwise
*/
- protected ConstrainedPathBuilder initializePathComputation(VertexKey src, VertexKey dst) {
+ protected ConstrainedPathBuilder initializePathComputation(final VertexKey src, final VertexKey dst) {
ConstrainedPathBuilder cpathBuilder = new ConstrainedPathBuilder().setStatus(ComputationStatus.InProgress);
/* Check that source and destination vertexKey are not identical */
*
* @return True if Edge must be prune, False if Edge must be keep
*/
- protected boolean pruneEdge(ConnectedEdge edge, CspfPath path) {
+ protected boolean pruneEdge(final ConnectedEdge edge, final CspfPath path) {
/* Check that Constraints are initialized */
if (constraints == null) {
LOG.warn("Constraints not set");
}
/* Edge could point to an unknown Vertex e.g. with inter-domain link */
- if ((edge.getDestination() == null) || (edge.getDestination().getVertex() == null)) {
+ if (edge.getDestination() == null || edge.getDestination().getVertex() == null) {
LOG.debug("No Destination");
return true;
}
/* Check that Edge belongs to the requested address family */
switch (constraints.getAddressFamily()) {
case Ipv4:
- if ((attributes.getRemoteAddress() == null)
- || (attributes.getRemoteAddress().getIpv4Address() == null)) {
+ if (attributes.getRemoteAddress() == null
+ || attributes.getRemoteAddress().getIpv4Address() == null) {
LOG.debug("No Ipv4 address");
return true;
}
break;
case Ipv6:
- if ((attributes.getRemoteAddress() == null)
- || (attributes.getRemoteAddress().getIpv6Address() == null)) {
+ if (attributes.getRemoteAddress() == null
+ || attributes.getRemoteAddress().getIpv6Address() == null) {
LOG.debug("No Ipv6 address");
return true;
}
/* Check that Edge respect Loss constraint */
if (constraints.getLoss() != null) {
- if ((attributes.getLoss() == null)
- || (attributes.getLoss().getValue().intValue() > constraints.getLoss().getValue().intValue())) {
+ if (attributes.getLoss() == null
+ || attributes.getLoss().getValue().intValue() > constraints.getLoss().getValue().intValue()) {
return true;
}
}
/* Check that Edge meet Bandwidth constraint */
if (constraints.getBandwidth() != null) {
- if ((attributes.getMaxLinkBandwidth() == null) || (attributes.getMaxResvLinkBandwidth() == null)
- || (attributes.getUnreservedBandwidth() == null)
- || (attributes.getUnreservedBandwidth().get(constraints.getClassType().intValue()) == null)) {
+ if (attributes.getMaxLinkBandwidth() == null || attributes.getMaxResvLinkBandwidth() == null
+ || attributes.getUnreservedBandwidth() == null
+ || attributes.getUnreservedBandwidth().get(constraints.getClassType().intValue()) == null) {
return true;
} else {
Long bandwidth = constraints.getBandwidth().getValue().longValue();
}
/* Check that Edge belongs to admin group */
- if ((constraints.getAdminGroup() != null)
- && !(constraints.getAdminGroup().equals(attributes.getAdminGroup()))) {
+ if (constraints.getAdminGroup() != null
+ && !constraints.getAdminGroup().equals(attributes.getAdminGroup())) {
LOG.debug("Not in the requested admin-group");
return true;
}
* @return MPLS Label if Connected Vertex is Segment Routing aware, Null
* otherwise
*/
- protected @Nullable MplsLabel getIpv4NodeSid(ConnectedVertex cvertex) {
+ protected @Nullable MplsLabel getIpv4NodeSid(final ConnectedVertex cvertex) {
/*
* Check that Vertex is Segment Routing aware
*/
- if ((cvertex.getVertex() == null) || (cvertex.getVertex().getSrgb() == null)) {
+ if (cvertex.getVertex() == null || cvertex.getVertex().getSrgb() == null) {
return null;
}
/*
return null;
}
for (Prefix prefix : cvertex.getPrefixes()) {
- if ((prefix.getPrefixSid() == null) || (prefix.isNodeSid() == null)) {
+ if (prefix.getPrefixSid() == null || prefix.getNodeSid() == null) {
continue;
}
- if (prefix.isNodeSid() && prefix.getPrefix().getIpv4Prefix() != null) {
+ if (prefix.getNodeSid() && prefix.getPrefix().getIpv4Prefix() != null) {
return new MplsLabel(Uint32.valueOf(prefix.getPrefixSid().intValue()));
}
}
* @return MPLS Label if Connected Vertex is Segment Routing aware, Null
* otherwise
*/
- protected @Nullable MplsLabel getIpv6NodeSid(ConnectedVertex cvertex) {
+ protected @Nullable MplsLabel getIpv6NodeSid(final ConnectedVertex cvertex) {
/*
* Check that Vertex is Segment Routing aware
*/
- if ((cvertex.getVertex() == null) || (cvertex.getVertex().getSrgb() == null)) {
+ if (cvertex.getVertex() == null || cvertex.getVertex().getSrgb() == null) {
return null;
}
/*
return null;
}
for (Prefix prefix : cvertex.getPrefixes()) {
- if ((prefix.getPrefixSid() == null) || (prefix.isNodeSid() == null)) {
+ if (prefix.getPrefixSid() == null || prefix.getNodeSid() == null) {
continue;
}
- if (prefix.isNodeSid() && prefix.getPrefix().getIpv6Prefix() != null) {
+ if (prefix.getNodeSid() && prefix.getPrefix().getIpv6Prefix() != null) {
return new MplsLabel(Uint32.valueOf(prefix.getPrefixSid().intValue()));
}
}
*
* @return Path Description
*/
- protected List<PathDescription> getPathDescription(List<ConnectedEdge> edges) {
- ArrayList<PathDescription> list = new ArrayList<PathDescription>();
+ protected List<PathDescription> getPathDescription(final List<ConnectedEdge> edges) {
+ ArrayList<PathDescription> list = new ArrayList<>();
for (ConnectedEdge edge : edges) {
PathDescription pathDesc = null;