本文整理汇总了Java中org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes.getNode方法的典型用法代码示例。如果您正苦于以下问题:Java Nodes.getNode方法的具体用法?Java Nodes.getNode怎么用?Java Nodes.getNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes
的用法示例。
在下文中一共展示了Nodes.getNode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getListOfDpns
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; //导入方法依赖的package包/类
public static List<BigInteger> getListOfDpns(DataBroker broker) {
List<BigInteger> dpnsList = new LinkedList<>();
InstanceIdentifier<Nodes> nodesInstanceIdentifier = InstanceIdentifier.builder(Nodes.class).build();
Optional<Nodes> nodesOptional =
MDSALUtil.read(broker, LogicalDatastoreType.OPERATIONAL, nodesInstanceIdentifier);
if (!nodesOptional.isPresent()) {
return dpnsList;
}
Nodes nodes = nodesOptional.get();
List<Node> nodeList = nodes.getNode();
for (Node node : nodeList) {
NodeId nodeId = node.getId();
if (nodeId == null) {
continue;
}
BigInteger dpnId = MDSALUtil.getDpnIdFromNodeName(nodeId);
dpnsList.add(dpnId);
}
return dpnsList;
}
示例2: getNodes
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; //导入方法依赖的package包/类
/**
* Retrieve all the {@link Node} along with a list of their
* associated {@link NodeConnector}.
* @return nodes A map with {@link Node} as the key and a {@link List} of {@link NodeConnector}.
*/
public static Map<Node, List<NodeConnector>> getNodes(final DataBroker dataBroker) {
Map<Node, List<NodeConnector>> nodeMap = new HashMap<Node, List<NodeConnector>>();
Nodes nodeList = new NodesBuilder().build();
ReadTransaction tx = dataBroker.newReadOnlyTransaction();
try {
final InstanceIdentifier<Nodes> nodesIdentifier = InstanceIdentifier.create(Nodes.class);
final CheckedFuture<Optional<Nodes>, ReadFailedException> txCheckedFuture = tx.read(LogicalDatastoreType
.OPERATIONAL, nodesIdentifier);
nodeList = txCheckedFuture.checkedGet().get();
for (Node node : nodeList.getNode()) {
LOG.info("Node ID : {}", node.getId());
List<NodeConnector> nodeConnector = node.getNodeConnector();
nodeMap.put(node, nodeConnector);
}
} catch (ReadFailedException e) {
//TODO: Perform fail over
LOG.error("Error reading Nodes from MD-SAL", e);
}
return nodeMap;
}