import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.VertexKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.vertex.SrgbBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp.topology.types.rev160524.TopologyTypes1;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp.topology.types.rev160524.TopologyTypes1Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp.topology.types.rev160524.bgp.linkstate.topology.type.BgpLinkstateTopologyBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.SrlgId;
public class LinkstateGraphBuilder extends AbstractTopologyBuilder<LinkstateRoute> {
private static final TopologyTypes LINKSTATE_TOPOLOGY_TYPE = new TopologyTypesBuilder().addAugmentation(
- TopologyTypes1.class,
new TopologyTypes1Builder().setBgpLinkstateTopology(new BgpLinkstateTopologyBuilder().build()).build())
.build();
private static final Logger LOG = LoggerFactory.getLogger(LinkstateGraphBuilder.class);
- private ConnectedGraphProvider graphProvider;
- private ConnectedGraph cgraph;
+ private final ConnectedGraphProvider graphProvider;
+ private final ConnectedGraph cgraph;
public LinkstateGraphBuilder(final DataBroker dataProvider, final RibReference locRibReference,
- final TopologyId topologyId, ConnectedGraphProvider provider) {
+ final TopologyId topologyId, final ConnectedGraphProvider provider) {
super(dataProvider, locRibReference, topologyId, LINKSTATE_TOPOLOGY_TYPE, LinkstateAddressFamily.class,
LinkstateSubsequentAddressFamily.class);
this.graphProvider = requireNonNull(provider);
@VisibleForTesting
LinkstateGraphBuilder(final DataBroker dataProvider, final RibReference locRibReference,
- final TopologyId topologyId, ConnectedGraphProvider provider, final long listenerResetLimitInMillsec,
+ final TopologyId topologyId, final ConnectedGraphProvider provider, final long listenerResetLimitInMillsec,
final int listenerResetEnforceCounter) {
super(dataProvider, locRibReference, topologyId, LINKSTATE_TOPOLOGY_TYPE, LinkstateAddressFamily.class,
LinkstateSubsequentAddressFamily.class, listenerResetLimitInMillsec, listenerResetEnforceCounter);
*
* @return True if all information are present, false otherwise
*/
- private boolean checkLinkState(final LinkCase linkCase) {
+ private static boolean checkLinkState(final LinkCase linkCase) {
if (linkCase.getLocalNodeDescriptors() == null || linkCase.getRemoteNodeDescriptors() == null) {
LOG.warn("Missing Local or Remote Node descriptor in link {}, skipping it", linkCase);
return false;
*
* @return Link Attributes
*/
- private LinkAttributes getLinkAttributes(final Attributes attributes) {
+ private static LinkAttributes getLinkAttributes(final Attributes attributes) {
final LinkAttributes la;
final Attributes1 attr = attributes.augmentation(Attributes1.class);
if (attr != null) {
*
* @return Unique key
*/
- private Uint64 getEdgeId(LinkCase linkCase) {
+ private static Uint64 getEdgeId(final LinkCase linkCase) {
long key = 0;
if (linkCase.getLinkDescriptors().getIpv4InterfaceAddress() != null) {
key = ipv4ToKey(linkCase.getLinkDescriptors().getIpv4InterfaceAddress().getValue());
cgraph.addPrefix(prefix);
}
+ private static final int MAX_PRIORITY = 8;
+
/**
* Create Edge Attributes from Link attributes.
*
*
* @return EdgeAttributes
*/
- private static final int MAX_PRIORITY = 8;
-
- private EdgeAttributes createEdgeAttributes(LinkAttributes la, final LinkDescriptors linkDesc) {
+ private static EdgeAttributes createEdgeAttributes(final LinkAttributes la, final LinkDescriptors linkDesc) {
EdgeAttributesBuilder builder = new EdgeAttributesBuilder();
if (linkDesc.getIpv4InterfaceAddress() != null) {
final List<UnreservedBandwidth> unRsvBw = new ArrayList<>(upperBound);
for (final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120
- .UnreservedBandwidth bandwidth : la.getUnreservedBandwidth()) {
+ .UnreservedBandwidth bandwidth : la.nonnullUnreservedBandwidth().values()) {
unRsvBw.add(new UnreservedBandwidthBuilder()
.setBandwidth(bandwithToDecimalBandwidth(bandwidth.getBandwidth()))
.withKey(new UnreservedBandwidthKey(bandwidth.getPriority())).build());
builder.setUtilizedBandwidth(bandwithToDecimalBandwidth(la.getUtilizedBandwidth()));
}
if (la.getSharedRiskLinkGroups() != null) {
- List<Uint32> srlgs = new ArrayList<Uint32>();
+ List<Uint32> srlgs = new ArrayList<>();
for (SrlgId srlg : la.getSharedRiskLinkGroups()) {
srlgs.add(srlg.getValue());
}
*
* @return Node Attributes
*/
- private NodeAttributes getNodeAttributes(final Attributes attributes) {
+ private static NodeAttributes getNodeAttributes(final Attributes attributes) {
final NodeAttributes na;
final Attributes1 attr = attributes.augmentation(Attributes1.class);
if (attr != null) {
*
* @return New Vertex
*/
- private Vertex getVertex(NodeAttributes na, Uint64 id, int as) {
+ private static Vertex getVertex(final NodeAttributes na, final Uint64 id, final int as) {
VertexBuilder builder = new VertexBuilder().setVertexId(id).setAsn(Uint32.valueOf(as));
if (na.getIpv4RouterId() != null) {
builder.setRouterId(new IpAddress(new Ipv4Address(na.getIpv4RouterId().getValue())));
} else {
int key = id.intValue();
builder.setName(
- ((key << 24) & 0xFF) + "." + ((key << 16) & 0xFF) + "." + ((key << 8) & 0xFF) + "." + (key & 0xFF));
+ (key << 24 & 0xFF) + "." + (key << 16 & 0xFF) + "." + (key << 8 & 0xFF) + "." + (key & 0xFF));
}
if (na.getSrCapabilities() != null) {
builder.setSrgb(new SrgbBuilder()
}
}
- private void removeEdge(LinkCase linkCase) {
+ private void removeEdge(final LinkCase linkCase) {
/* Get Source and Destination Connected Vertex */
if (linkCase.getLinkDescriptors() == null) {
LOG.warn("Missing Link descriptor in link {}, skipping it", linkCase);
return;
}
EdgeKey edgeKey = new EdgeKey(getEdgeId(linkCase));
- if ((edgeKey == null) || (edgeKey.getEdgeId() == Uint64.ZERO)) {
+ if (edgeKey == null || edgeKey.getEdgeId() == Uint64.ZERO) {
LOG.warn("Unable to get the Edge Key from link {}, skipping it", linkCase);
return;
}
cgraph.deleteEdge(edgeKey);
}
- private void removeVertex(NodeCase nodeCase) {
+ private void removeVertex(final NodeCase nodeCase) {
VertexKey vertexKey = new VertexKey(getVertexId(nodeCase.getNodeDescriptors().getCRouterIdentifier()));
- if ((vertexKey == null) || (vertexKey.getVertexId() == Uint64.ZERO)) {
+ if (vertexKey == null || vertexKey.getVertexId() == Uint64.ZERO) {
LOG.warn("Unable to get Vertex Key from descriptor {}, skipping it", nodeCase.getNodeDescriptors());
return;
}
cgraph.deleteVertex(vertexKey);
}
- private void removePrefix(PrefixCase prefixCase) {
+ private void removePrefix(final PrefixCase prefixCase) {
final IpPrefix ippfx = prefixCase.getPrefixDescriptors().getIpReachabilityInformation();
if (ippfx == null) {
LOG.warn("IP reachability not present in prefix {}, skipping it", prefixCase);
*
* @return Vertex in the Connected Graph that corresponds to this Router ID. Vertex is created if not found.
*/
- private Uint64 getVertexId(CRouterIdentifier routerID) {
+ private static Uint64 getVertexId(final CRouterIdentifier routerID) {
Long rid = 0L;
if (routerID instanceof IsisNodeCase) {
return Uint64.valueOf(rid);
}
- private DecimalBandwidth bandwithToDecimalBandwidth(Bandwidth bw) {
+ private static DecimalBandwidth bandwithToDecimalBandwidth(final Bandwidth bw) {
return new DecimalBandwidth(BigDecimal.valueOf(ByteBuffer.wrap(bw.getValue()).getFloat()));
}
- private long ipv4ToKey(String str) {
+ private static long ipv4ToKey(final String str) {
byte[] ip;
try {
ip = ((Inet4Address) Inet4Address.getByName(str)).getAddress();
} catch (UnknownHostException e) {
return 0;
}
- return (((0xFF & ip[0]) << 24) | ((0xFF & ip[1]) << 16) | ((0xFF & ip[2]) << 8) | (0xFF & ip[3]));
+ return (0xFF & ip[0]) << 24 | (0xFF & ip[1]) << 16 | (0xFF & ip[2]) << 8 | 0xFF & ip[3];
}
- private Long ipv6ToKey(String str) {
+ private static Long ipv6ToKey(final String str) {
byte[] ip;
try {
ip = ((Inet6Address) Inet6Address.getByName(str)).getAddress();
protected void clearTopology() {
cgraph.clear();
}
-
}