当前位置: 首页>>代码示例>>Java>>正文


Java NodeConnector.getAugmentation方法代码示例

本文整理汇总了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);

	}
 
开发者ID:geopet85,项目名称:virtuwind-example,代码行数:55,代码来源:NodeMonitor.java

示例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;
}
 
开发者ID:geopet85,项目名称:virtuwind-example,代码行数:50,代码来源:AddressMonitor.java


注:本文中的org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector.getAugmentation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。