本文整理汇总了Java中org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector.getAugmentation方法的典型用法代码示例。如果您正苦于以下问题:Java NodeConnector.getAugmentation方法的具体用法?Java NodeConnector.getAugmentation怎么用?Java NodeConnector.getAugmentation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector
的用法示例。
在下文中一共展示了NodeConnector.getAugmentation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: measureNodeStatistics
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector; //导入方法依赖的package包/类
public void measureNodeStatistics(String nodeId, String nodeConnectorId) {
LOG.info("Checking src node {} and interface {} statistics. ", nodeId,
nodeConnectorId);
float packetLoss = 0.0f;
float bw = 0.0f;
NodeConnector nc = null;
try {
InstanceIdentifier<NodeConnector> nodeConnectorIid = InstanceIdentifier
.builder(Nodes.class)
.child(Node.class, new NodeKey(new NodeId(nodeId)))
.child(NodeConnector.class,
new NodeConnectorKey(new NodeConnectorId(
nodeConnectorId))).build();
ReadOnlyTransaction nodesTransaction = db.newReadOnlyTransaction();
CheckedFuture<Optional<NodeConnector>, ReadFailedException> nodeConnectorFuture = nodesTransaction
.read(LogicalDatastoreType.OPERATIONAL, nodeConnectorIid);
Optional<NodeConnector> nodeConnectorOptional = Optional.absent();
nodeConnectorOptional = nodeConnectorFuture.checkedGet();
if (nodeConnectorOptional != null
&& nodeConnectorOptional.isPresent()) {
nc = nodeConnectorOptional.get();
}
if (nc != null) {
FlowCapableNodeConnectorStatisticsData statData = nc
.getAugmentation(FlowCapableNodeConnectorStatisticsData.class);
FlowCapableNodeConnectorStatistics statistics = statData
.getFlowCapableNodeConnectorStatistics();
BigInteger packetsTransmitted = statistics.getPackets()
.getTransmitted();
BigInteger packetErrorsTransmitted = statistics
.getTransmitErrors();
packetLoss = (packetsTransmitted.floatValue() == 0) ? 0
: packetErrorsTransmitted.floatValue()
/ packetsTransmitted.floatValue();
FlowCapableNodeConnector fnc = nc
.getAugmentation(FlowCapableNodeConnector.class);
bw = fnc.getCurrentSpeed();
}
} catch (Exception e) {
LOG.error("Source node statistics reading failed:", e);
}
LOG.info("Packet loss {} ", packetLoss);
LOG.info("Bw {} ", bw);
}
示例2: getNodeFromIpAddress
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector; //导入方法依赖的package包/类
/**
* Returns the node from a given ip address
*/
public Node getNodeFromIpAddress(String ipAddress) {
LOG.info("Finding node with IP address {}. ", ipAddress);
try {
List<Node> nodeList = new ArrayList<>();
InstanceIdentifier<Nodes> nodesIid = InstanceIdentifier.builder(
Nodes.class).build();
ReadOnlyTransaction nodesTransaction = db.newReadOnlyTransaction();
CheckedFuture<Optional<Nodes>, ReadFailedException> nodesFuture = nodesTransaction
.read(LogicalDatastoreType.OPERATIONAL, nodesIid);
Optional<Nodes> nodesOptional = Optional.absent();
nodesOptional = nodesFuture.checkedGet();
if (nodesOptional != null && nodesOptional.isPresent()) {
nodeList = nodesOptional.get().getNode();
}
if (nodeList != null) {
for (Node n : nodeList) {
List<NodeConnector> nodeConnectors = n.getNodeConnector();
for (NodeConnector nc : nodeConnectors) {
AddressCapableNodeConnector acnc = nc
.getAugmentation(AddressCapableNodeConnector.class);
if (acnc != null && acnc.getAddresses() != null) {
// get address list from augmentation.
List<Addresses> addresses = acnc.getAddresses();
for (Addresses address : addresses) {
LOG.info(
"Checking address {} for connector {}",
address.getIp().getIpv4Address()
.getValue(), nc.getId()
.getValue());
if (address.getIp().getIpv4Address().getValue()
.equals(ipAddress))
return n;
}
}
}
}
}
} catch (Exception e) {
LOG.info("IP address reading failed");
}
return null;
}