本文整理汇总了Java中org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodesBuilder类的典型用法代码示例。如果您正苦于以下问题:Java NodesBuilder类的具体用法?Java NodesBuilder怎么用?Java NodesBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NodesBuilder类属于org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819包,在下文中一共展示了NodesBuilder类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNodes
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodesBuilder; //导入依赖的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;
}