本文整理汇总了Java中org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails类的典型用法代码示例。如果您正苦于以下问题:Java PathAttrNlriDetails类的具体用法?Java PathAttrNlriDetails怎么用?Java PathAttrNlriDetails使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PathAttrNlriDetails类属于org.onosproject.bgpio.protocol.linkstate包,在下文中一共展示了PathAttrNlriDetails类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: add
import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails; //导入依赖的package包/类
/**
* Update vpn nlri identifier into the tree if nlri identifier exists in tree otherwise add this to the tree.
*
* @param nlri NLRI info
* @param details has pathattribute , protocolID and identifier
*/
public void add(BgpLSNlri nlri, PathAttrNlriDetails details) {
if (nlri instanceof BgpNodeLSNlriVer4) {
BgpNodeLSIdentifier nodeLSIdentifier = ((BgpNodeLSNlriVer4) nlri).getLocalNodeDescriptors();
if (nodeTree.containsKey(nodeLSIdentifier)) {
nodeTree.replace(nodeLSIdentifier, details);
} else {
nodeTree.put(nodeLSIdentifier, details);
}
} else if (nlri instanceof BgpLinkLsNlriVer4) {
BgpLinkLSIdentifier linkLSIdentifier = ((BgpLinkLsNlriVer4) nlri).getLinkIdentifier();
if (linkTree.containsKey(linkLSIdentifier)) {
linkTree.replace(linkLSIdentifier, details);
} else {
linkTree.put(linkLSIdentifier, details);
}
} else if (nlri instanceof BgpPrefixIPv4LSNlriVer4) {
BgpPrefixLSIdentifier prefixIdentifier = ((BgpPrefixIPv4LSNlriVer4) nlri).getPrefixIdentifier();
if (prefixTree.containsKey(prefixIdentifier)) {
prefixTree.replace(prefixIdentifier, details);
} else {
prefixTree.put(prefixIdentifier, details);
}
}
}
示例2: addVpn
import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails; //导入依赖的package包/类
/**
* Update nlri identifier mapped with route distinguisher if it exists in tree otherwise add nlri infomation mapped
* to respective route distinguisher in tree.
*
* @param nlri NLRI info
* @param details has pathattribute , protocolID and identifier
* @param routeDistinguisher unique for for each vpn
*/
public void addVpn(BgpLSNlri nlri, PathAttrNlriDetails details, RouteDistinguisher routeDistinguisher) {
add(nlri, details);
if (nlri instanceof BgpNodeLSNlriVer4) {
if (!vpnNodeTree.containsKey(routeDistinguisher)) {
vpnNodeTree.put(routeDistinguisher, nodeTree);
}
} else if (nlri instanceof BgpLinkLsNlriVer4) {
if (!vpnLinkTree.containsKey(routeDistinguisher)) {
vpnLinkTree.put(routeDistinguisher, linkTree);
}
} else if (nlri instanceof BgpPrefixIPv4LSNlriVer4) {
if (!vpnPrefixTree.containsKey(routeDistinguisher)) {
vpnPrefixTree.put(routeDistinguisher, prefixTree);
}
}
}
示例3: add
import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails; //导入依赖的package包/类
/**
* Update nlri identifier into the tree if nlri identifier exists in tree otherwise add this to the tree.
*
* @param nlri NLRI Info
* @param details has pathattribute , protocolID and identifier
*/
public void add(BgpLSNlri nlri, PathAttrNlriDetails details) {
if (nlri instanceof BgpNodeLSNlriVer4) {
BgpNodeLSIdentifier nodeLSIdentifier = ((BgpNodeLSNlriVer4) nlri).getLocalNodeDescriptors();
if (nodeTree.containsKey(nodeLSIdentifier)) {
nodeTree.replace(nodeLSIdentifier, details);
} else {
nodeTree.put(nodeLSIdentifier, details);
}
} else if (nlri instanceof BgpLinkLsNlriVer4) {
BgpLinkLSIdentifier linkLSIdentifier = ((BgpLinkLsNlriVer4) nlri).getLinkIdentifier();
if (linkTree.containsKey(linkLSIdentifier)) {
linkTree.replace(linkLSIdentifier, details);
} else {
linkTree.put(linkLSIdentifier, details);
}
} else if (nlri instanceof BgpPrefixIPv4LSNlriVer4) {
BgpPrefixLSIdentifier prefixIdentifier = ((BgpPrefixIPv4LSNlriVer4) nlri).getPrefixIdentifier();
if (prefixTree.containsKey(prefixIdentifier)) {
prefixTree.replace(prefixIdentifier, details);
} else {
prefixTree.put(prefixIdentifier, details);
}
}
}
示例4: add
import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails; //导入依赖的package包/类
@Override
public void add(BgpSessionInfo sessionInfo, BgpLSNlri nlri, PathAttrNlriDetails details,
RouteDistinguisher routeDistinguisher) throws BgpParseException {
add(sessionInfo, nlri, details);
if (nlri instanceof BgpNodeLSNlriVer4) {
if (!vpnNodeTree.containsKey(routeDistinguisher)) {
vpnNodeTree.put(routeDistinguisher, nodeTree);
}
} else if (nlri instanceof BgpLinkLsNlriVer4) {
if (!vpnLinkTree.containsKey(routeDistinguisher)) {
vpnLinkTree.put(routeDistinguisher, linkTree);
}
} else if (nlri instanceof BgpPrefixIPv4LSNlriVer4) {
if (!vpnPrefixTree.containsKey(routeDistinguisher)) {
vpnPrefixTree.put(routeDistinguisher, prefixTree);
}
}
}
示例5: addVpn
import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails; //导入依赖的package包/类
/**
* Update nlri identifier mapped with route distinguisher if it exists in tree otherwise add nlri information mapped
* to respective route distinguisher in tree.
*
* @param nlri NLRI info
* @param details has pathattribute , protocolID and identifier
* @param routeDistinguisher unique for for each vpn
*/
public void addVpn(BgpLSNlri nlri, PathAttrNlriDetails details, RouteDistinguisher routeDistinguisher) {
add(nlri, details);
if (nlri instanceof BgpNodeLSNlriVer4) {
if (!vpnNodeTree.containsKey(routeDistinguisher)) {
vpnNodeTree.put(routeDistinguisher, nodeTree);
}
} else if (nlri instanceof BgpLinkLsNlriVer4) {
if (!vpnLinkTree.containsKey(routeDistinguisher)) {
vpnLinkTree.put(routeDistinguisher, linkTree);
}
} else if (nlri instanceof BgpPrefixIPv4LSNlriVer4) {
if (!vpnPrefixTree.containsKey(routeDistinguisher)) {
vpnPrefixTree.put(routeDistinguisher, prefixTree);
}
}
}
示例6: addLink
import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails; //导入依赖的package包/类
@Override
public void addLink(BgpLinkLsNlriVer4 linkNlri, PathAttrNlriDetails details) throws BgpParseException {
log.debug("Addlink {}", linkNlri.toString());
LinkDescription linkDes = buildLinkDes(linkNlri, details, true);
/*
* Update link ports and configure bandwidth on source and destination port using networkConfig service
* Only master of source link registers for bandwidth
*/
if (mastershipService.isLocalMaster(linkDes.src().deviceId())) {
registerBandwidthAndTeMetric(linkDes, details);
}
//Updating ports of the link
deviceProviderService.updatePorts(linkDes.src().deviceId(), buildPortDescriptions(linkDes.src().deviceId(),
linkDes.src().port()));
deviceProviderService.updatePorts(linkDes.dst().deviceId(), buildPortDescriptions(linkDes.dst().deviceId(),
linkDes.dst().port()));
linkProviderService.linkDetected(linkDes);
}
示例7: setPathAttrDetails
import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails; //导入依赖的package包/类
/**
* Sets BGP path attribute and NLRI details.
*
* @param nlriInfo MpReachNlri path attribute
* @param pathAttr list of BGP path attributes
* @return details object of PathAttrNlriDetails
* @throws BgpParseException throw exception
*/
public PathAttrNlriDetails setPathAttrDetails(BgpLSNlri nlriInfo, List<BgpValueType> pathAttr)
throws BgpParseException {
PathAttrNlriDetails details = new PathAttrNlriDetails();
details.setProtocolID(nlriInfo.getProtocolId());
details.setIdentifier(nlriInfo.getIdentifier());
details.setPathAttribute(pathAttr);
return details;
}
示例8: addLink
import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails; //导入依赖的package包/类
@Override
public void addLink(BgpLinkLsNlriVer4 linkNlri, PathAttrNlriDetails details) throws BgpParseException {
log.debug("Addlink {}", linkNlri.toString());
LinkDescription linkDes = buildLinkDes(linkNlri, details, true);
//If already link exists, return
if (linkService.getLink(linkDes.src(), linkDes.dst()) != null || linkProviderService == null) {
return;
}
/*
* Update link ports and configure bandwidth on source and destination port using networkConfig service
* Only master of source link registers for bandwidth
*/
if (mastershipService.isLocalMaster(linkDes.src().deviceId())) {
registerBandwidth(linkDes, details);
}
//Updating ports of the link
deviceProviderService.updatePorts(linkDes.src().deviceId(), buildPortDescriptions(linkDes.src().deviceId(),
linkDes.src().port()));
deviceProviderService.updatePorts(linkDes.dst().deviceId(), buildPortDescriptions(linkDes.dst().deviceId(),
linkDes.dst().port()));
linkProviderService.linkDetected(linkDes);
}
示例9: registerBandwidth
import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails; //导入依赖的package包/类
private void registerBandwidth(LinkDescription linkDes, PathAttrNlriDetails details) {
if (details == null) {
log.error("Couldnot able to register bandwidth ");
return;
}
List<BgpValueType> attribute = details.pathAttributes().stream()
.filter(attr -> attr instanceof LinkStateAttributes).collect(toList());
if (attribute.isEmpty()) {
return;
}
List<BgpValueType> tlvs = ((LinkStateAttributes) attribute.iterator().next()).linkStateAttributes();
float maxReservableBw = 0;
for (BgpValueType tlv : tlvs) {
switch (tlv.getType()) {
case LinkStateAttributes.ATTR_LINK_MAX_RES_BANDWIDTH:
maxReservableBw = ((BgpLinkAttrMaxLinkBandwidth) tlv).linkAttrMaxLinkBandwidth();
//will get in bits/second , convert to MBPS to store in network config service
maxReservableBw = maxReservableBw / 1000000;
break;
default: // do nothing
}
}
if (maxReservableBw == 0.0) {
return;
}
//Configure bandwidth for src and dst port
BandwidthCapacity config = networkConfigService.addConfig(linkDes.src(), BandwidthCapacity.class);
config.capacity(Bandwidth.bps(maxReservableBw)).apply();
config = networkConfigService.addConfig(linkDes.dst(), BandwidthCapacity.class);
config.capacity(Bandwidth.bps(maxReservableBw)).apply();
}
示例10: bgpTopologyProviderTestAddDevice1
import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails; //导入依赖的package包/类
/**
* Validate node is added to the device validating URI, RIB should get updated properly.
*/
@Test
public void bgpTopologyProviderTestAddDevice1() {
LinkedList<BgpValueType> subTlvs = new LinkedList<>();
BgpValueType tlv = new AutonomousSystemTlv(100);
short deslength = AutonomousSystemTlv.LENGTH;
short desType = AutonomousSystemTlv.TYPE;
subTlvs.add(tlv);
BgpNodeLSIdentifier localNodeDescriptors = new BgpNodeLSIdentifier(new NodeDescriptors(subTlvs, deslength,
desType));
BgpNodeLSNlriVer4 nodeNlri = new BgpNodeLSNlriVer4(0, (byte) Constants.DIRECT, localNodeDescriptors, false,
new RouteDistinguisher());
PathAttrNlriDetails details = new PathAttrNlriDetails();
details.setIdentifier(0);
details.setProtocolID(ProtocolType.DIRECT);
List<BgpValueType> pathAttributes = new LinkedList<>();
details.setPathAttribute(pathAttributes);
for (BgpNodeListener l : controller.nodeListener) {
l.addNode(nodeNlri, details);
assertThat(nodeRegistry.connected.size(), is(1));
l.deleteNode(nodeNlri);
assertThat(nodeRegistry.connected.size(), is(0));
}
}
示例11: bgpTopologyProviderTestAddDevice2
import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails; //导入依赖的package包/类
/**
* Validate node is not added to the device for invalid URI, RIB count should be zero.
*/
@Test
public void bgpTopologyProviderTestAddDevice2() {
LinkedList<BgpValueType> subTlvs;
BgpValueType tlv = new AutonomousSystemTlv(10);
short deslength = AutonomousSystemTlv.LENGTH;
short desType = AutonomousSystemTlv.TYPE;
PathAttrNlriDetails details = new PathAttrNlriDetails();
details.setIdentifier(0);
details.setProtocolID(ProtocolType.DIRECT);
List<BgpValueType> pathAttributes = new LinkedList<>();
details.setPathAttribute(pathAttributes);
subTlvs = new LinkedList<>();
subTlvs.add(tlv);
BgpNodeLSIdentifier localNodeDescriptors = new BgpNodeLSIdentifier(new NodeDescriptors(subTlvs, deslength,
desType));
BgpNodeLSNlriVer4 nodeNlri = new BgpNodeLSNlriVer4(0, (byte) Constants.DIRECT, localNodeDescriptors, false,
new RouteDistinguisher());
for (BgpNodeListener l : controller.nodeListener) {
l.addNode(nodeNlri, details);
assertThat(nodeRegistry.connected.size(), is(0));
}
}
示例12: bgpTopologyProviderDeviceTestLabel1
import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails; //导入依赖的package包/类
/**
* Add device check label registration is done.
*
* @throws BgpParseException while adding a device
*/
@Test
public void bgpTopologyProviderDeviceTestLabel1() throws BgpParseException {
LinkedList<BgpValueType> subTlvs = new LinkedList<>();
BgpValueType tlv = new AutonomousSystemTlv(100);
short deslength = AutonomousSystemTlv.LENGTH;
short desType = AutonomousSystemTlv.TYPE;
subTlvs.add(tlv);
BgpNodeLSIdentifier localNodeDescriptors = new BgpNodeLSIdentifier(new NodeDescriptors(subTlvs, deslength,
desType));
BgpNodeLSNlriVer4 nodeNlri = new BgpNodeLSNlriVer4(0, (byte) Constants.DIRECT, localNodeDescriptors, false,
new RouteDistinguisher());
PathAttrNlriDetails details = new PathAttrNlriDetails();
details.setIdentifier(0);
details.setProtocolID(ProtocolType.DIRECT);
List<BgpValueType> pathAttributes = new LinkedList<>();
List<BgpValueType> linkStateAttributes = new LinkedList<>();
tlv = BgpAttrRouterIdV4.of(Ip4Address.valueOf("1.1.1.1"), LinkStateAttributes.ATTR_NODE_IPV4_LOCAL_ROUTER_ID);
linkStateAttributes.add(tlv);
pathAttributes.add(new LinkStateAttributes(linkStateAttributes));
details.setPathAttribute(pathAttributes);
for (BgpNodeListener l : controller.nodeListener) {
l.addNode(nodeNlri, details);
assertThat(nodeRegistry.connected.size(), is(1));
}
MastershipEvent event = new MastershipEvent(Type.MASTER_CHANGED, nodeRegistry.connected.iterator().next(),
new RoleInfo(NodeId.nodeId("Node1"), new LinkedList<>()));
listener.event(event);
assertThat(labelResourceAdminService.resourcePool.keySet().size(), is(1));
}
示例13: bgpTopologyProviderDeviceTestLabel2
import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails; //导入依赖的package包/类
/**
* Add device check label registration is done and delete node destroy label pool.
*
* @throws BgpParseException while adding a device
*/
@Test
public void bgpTopologyProviderDeviceTestLabel2() throws BgpParseException {
LinkedList<BgpValueType> subTlvs = new LinkedList<>();
BgpValueType tlv = new AutonomousSystemTlv(100);
short deslength = AutonomousSystemTlv.LENGTH;
short desType = AutonomousSystemTlv.TYPE;
subTlvs.add(tlv);
BgpNodeLSIdentifier localNodeDescriptors = new BgpNodeLSIdentifier(new NodeDescriptors(subTlvs, deslength,
desType));
BgpNodeLSNlriVer4 nodeNlri = new BgpNodeLSNlriVer4(0, (byte) Constants.DIRECT, localNodeDescriptors, false,
new RouteDistinguisher());
PathAttrNlriDetails details = new PathAttrNlriDetails();
details.setIdentifier(0);
details.setProtocolID(ProtocolType.DIRECT);
List<BgpValueType> pathAttributes = new LinkedList<>();
List<BgpValueType> linkStateAttributes = new LinkedList<>();
tlv = BgpAttrRouterIdV4.of(Ip4Address.valueOf("1.1.1.1"), LinkStateAttributes.ATTR_NODE_IPV4_LOCAL_ROUTER_ID);
linkStateAttributes.add(tlv);
pathAttributes.add(new LinkStateAttributes(linkStateAttributes));
details.setPathAttribute(pathAttributes);
for (BgpNodeListener l : controller.nodeListener) {
l.addNode(nodeNlri, details);
assertThat(nodeRegistry.connected.size(), is(1));
// Check label resource reserved for that device
MastershipEvent event = new MastershipEvent(Type.MASTER_CHANGED, nodeRegistry.connected.iterator().next(),
new RoleInfo(NodeId.nodeId("Node1"), new LinkedList<>()));
listener.event(event);
assertThat(labelResourceAdminService.resourcePool.keySet().size(), is(1));
l.deleteNode(nodeNlri);
assertThat(nodeRegistry.connected.size(), is(0));
assertThat(labelResourceAdminService.resourcePool.keySet().size(), is(0));
}
}
示例14: bgpTopologyProviderDeviceTestLabel1
import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails; //导入依赖的package包/类
/**
* Add device check label registration is done.
*
* @throws BgpParseException while adding a device
*/
@Test
public void bgpTopologyProviderDeviceTestLabel1() throws BgpParseException {
LinkedList<BgpValueType> subTlvs = new LinkedList<>();
BgpValueType tlv = new AutonomousSystemTlv(100);
short deslength = AutonomousSystemTlv.LENGTH;
short desType = AutonomousSystemTlv.TYPE;
subTlvs.add(tlv);
BgpNodeLSIdentifier localNodeDescriptors = new BgpNodeLSIdentifier(new NodeDescriptors(subTlvs, deslength,
desType));
BgpNodeLSNlriVer4 nodeNlri = new BgpNodeLSNlriVer4(0, (byte) Constants.DIRECT, localNodeDescriptors, false,
new RouteDistinguisher());
PathAttrNlriDetails details = new PathAttrNlriDetails();
details.setIdentifier(0);
details.setProtocolID(ProtocolType.DIRECT);
List<BgpValueType> pathAttributes = new LinkedList<>();
List<BgpValueType> linkStateAttributes = new LinkedList<>();
tlv = BgpAttrRouterIdV4.of(Ip4Address.valueOf("1.1.1.1"), LinkStateAttributes.ATTR_NODE_IPV4_LOCAL_ROUTER_ID);
linkStateAttributes.add(tlv);
pathAttributes.add(new LinkStateAttributes(linkStateAttributes));
details.setPathAttribute(pathAttributes);
for (BgpNodeListener l : controller.nodeListener) {
l.addNode(nodeNlri, details);
assertThat(nodeRegistry.connected.size(), is(1));
}
DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder();
newBuilder.set("lsrId", "1.1.1.1");
Device device = new DefaultDevice(BgpTopologyProviderTest.providerId, nodeRegistry.connected.iterator().next(),
Device.Type.ROUTER, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, new ChassisId(), newBuilder.build());
DeviceEvent event = new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, device);
listener.event(event);
assertThat(labelResourceAdminService.resourcePool.keySet().size(), is(1));
}
示例15: selectionAlgoTest1
import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails; //导入依赖的package包/类
/**
* firstPathAttribute and secondPathAttribute has same AS count and firstPathAttribute
* has shortest Origin value than secondPathAttribute.
*/
@Test
public void selectionAlgoTest1() throws BgpParseException {
byte[] peerIp = new byte[] {0x0a, 0x0a, 0x0a, 0x0a };
LinkedList<BgpValueType> pathAttributes1 = new LinkedList<>();
BgpValueType pathAttribute1;
//origin with IGP
byte[] origin = new byte[] {0x40, 0x01, 0x01, 0x00 };
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(origin);
pathAttribute1 = Origin.read(buffer);
pathAttributes1.add(pathAttribute1);
//AsPath with AS_SEQ with one AS
byte[] asPath = new byte[] {0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd,
(byte) 0xea };
buffer.writeBytes(asPath);
pathAttribute1 = AsPath.read(buffer);
pathAttributes1.add(pathAttribute1);
IpAddress ipAddress = IpAddress.valueOf(Version.INET, peerIp);
int bgpId = 168427777;
short locRibAsNum = 100;
boolean isIbgp = false;
PathAttrNlriDetails attrList1 = new PathAttrNlriDetails();
attrList1.setIdentifier(0);
attrList1.setPathAttribute(pathAttributes1);
attrList1.setProtocolID(ProtocolType.ISIS_LEVEL_ONE);
PathAttrNlriDetailsLocalRib list1 = new PathAttrNlriDetailsLocalRib(
ipAddress, bgpId, locRibAsNum, isIbgp, attrList1);
peerIp = new byte[] {0x0b, 0x0b, 0x0b, 0x0b };
LinkedList<BgpValueType> pathAttributes2 = new LinkedList<>();
BgpValueType pathAttribute2;
//origin with INCOMPLETE
origin = new byte[] {0x40, 0x01, 0x01, 0x02 };
buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(origin);
pathAttribute2 = Origin.read(buffer);
pathAttributes2.add(pathAttribute2);
//AsPath with AS_SEQ with one AS
asPath = new byte[] {0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd,
(byte) 0xe9 };
buffer.writeBytes(asPath);
pathAttribute2 = AsPath.read(buffer);
pathAttributes2.add(pathAttribute2);
ipAddress = IpAddress.valueOf(Version.INET, peerIp);
bgpId = 536936448;
locRibAsNum = 200;
isIbgp = true;
PathAttrNlriDetails attrList2 = new PathAttrNlriDetails();
attrList2.setIdentifier(0);
attrList2.setPathAttribute(pathAttributes2);
attrList2.setProtocolID(ProtocolType.OSPF_V2);
PathAttrNlriDetailsLocalRib list2 = new PathAttrNlriDetailsLocalRib(
ipAddress, bgpId, locRibAsNum, isIbgp, attrList2);
BgpSelectionAlgo algo = new BgpSelectionAlgo();
int result = algo.compare(list1, list2);
assertThat(result, is(1));
}