use of org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap in project openflowplugin by opendaylight.
the class PortDirectStatisticsService method buildReply.
@Override
protected GetNodeConnectorStatisticsOutput buildReply(List<MultipartReply> input, boolean success) {
final List<NodeConnectorStatisticsAndPortNumberMap> nodeConnectorStatisticsAndPortNumberMap = new ArrayList<>();
if (success) {
for (final MultipartReply mpReply : input) {
final MultipartReplyPortStatsCase caseBody = (MultipartReplyPortStatsCase) mpReply.getMultipartReplyBody();
final MultipartReplyPortStats replyBody = caseBody.getMultipartReplyPortStats();
for (final PortStats portStats : replyBody.getPortStats()) {
final NodeConnectorId nodeConnectorId = InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(getDatapathId(), portStats.getPortNo(), getOfVersion());
final BytesBuilder bytesBuilder = new BytesBuilder().setReceived(portStats.getRxBytes()).setTransmitted(portStats.getTxBytes());
final PacketsBuilder packetsBuilder = new PacketsBuilder().setReceived(portStats.getRxPackets()).setTransmitted(portStats.getTxPackets());
final DurationBuilder durationBuilder = new DurationBuilder();
if (portStats.getDurationSec() != null) {
durationBuilder.setSecond(new Counter32(portStats.getDurationSec()));
}
if (portStats.getDurationNsec() != null) {
durationBuilder.setNanosecond(new Counter32(portStats.getDurationNsec()));
}
final NodeConnectorStatisticsAndPortNumberMap stats = new NodeConnectorStatisticsAndPortNumberMapBuilder().setBytes(bytesBuilder.build()).setPackets(packetsBuilder.build()).setNodeConnectorId(nodeConnectorId).setDuration(durationBuilder.build()).setCollisionCount(portStats.getCollisions()).setKey(new NodeConnectorStatisticsAndPortNumberMapKey(nodeConnectorId)).setReceiveCrcError(portStats.getRxCrcErr()).setReceiveDrops(portStats.getRxDropped()).setReceiveErrors(portStats.getRxErrors()).setReceiveFrameError(portStats.getRxFrameErr()).setReceiveOverRunError(portStats.getRxOverErr()).setTransmitDrops(portStats.getTxDropped()).setTransmitErrors(portStats.getTxErrors()).build();
nodeConnectorStatisticsAndPortNumberMap.add(stats);
}
}
}
return new GetNodeConnectorStatisticsOutputBuilder().setNodeConnectorStatisticsAndPortNumberMap(nodeConnectorStatisticsAndPortNumberMap).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap in project netvirt by opendaylight.
the class CounterRetriever method createNodeConnectorResultMapDirect.
private CounterResultDataStructure createNodeConnectorResultMapDirect(GetNodeConnectorStatisticsOutput nodeConnectorStatsOutput, NodeConnectorId nodeConnectorId) {
List<NodeConnectorStatisticsAndPortNumberMap> nodeConnectorUpdates = nodeConnectorStatsOutput.getNodeConnectorStatisticsAndPortNumberMap();
if (nodeConnectorUpdates == null || nodeConnectorUpdates.isEmpty()) {
counters.failedGettingResultMapForNodeConnectorCounters.inc();
LOG.warn("Unable to retrieve statistics info for node connector");
return null;
}
CounterResultDataStructure crds = new CounterResultDataStructure();
for (NodeConnectorStatisticsAndPortNumberMap nodeConnectorUpdate : nodeConnectorUpdates) {
if (nodeConnectorUpdate.getNodeConnectorId() == null) {
continue;
}
String resultId = nodeConnectorId.getValue();
crds.addCounterResult(resultId);
if (nodeConnectorUpdate.getBytes() != null) {
crds.addCounterToGroup(resultId, CountersUtils.BYTES_GROUP_NAME, CountersUtils.BYTES_RECEIVED_COUNTER_NAME, nodeConnectorUpdate.getBytes().getReceived());
crds.addCounterToGroup(resultId, CountersUtils.BYTES_GROUP_NAME, CountersUtils.BYTES_TRANSMITTED_COUNTER_NAME, nodeConnectorUpdate.getBytes().getTransmitted());
}
if (nodeConnectorUpdate.getPackets() != null) {
crds.addCounterToGroup(resultId, CountersUtils.PACKETS_GROUP_NAME, CountersUtils.PACKETS_RECEIVED_COUNTER_NAME, nodeConnectorUpdate.getPackets().getReceived());
crds.addCounterToGroup(resultId, CountersUtils.PACKETS_GROUP_NAME, CountersUtils.PACKETS_TRANSMITTED_COUNTER_NAME, nodeConnectorUpdate.getPackets().getTransmitted());
}
if (nodeConnectorUpdate.getDuration() != null) {
crds.addCounterToGroup(resultId, CountersUtils.DURATION_GROUP_NAME, CountersUtils.DURATION_SECOND_COUNTER_NAME, big(nodeConnectorUpdate.getDuration().getSecond().getValue()));
crds.addCounterToGroup(resultId, CountersUtils.DURATION_GROUP_NAME, CountersUtils.DURATION_NANO_SECOND_COUNTER_NAME, big(nodeConnectorUpdate.getDuration().getNanosecond().getValue()));
}
}
return crds;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap in project netvirt by opendaylight.
the class QosAlertManager method pollDirectStatisticsForAllNodes.
private void pollDirectStatisticsForAllNodes() {
LOG.trace("Polling direct statistics from nodes");
for (Entry<BigInteger, ConcurrentMap<String, QosAlertPortData>> entry : qosAlertDpnPortNumberMap.entrySet()) {
BigInteger dpn = entry.getKey();
LOG.trace("Polling DPN ID {}", dpn);
GetNodeConnectorStatisticsInputBuilder input = new GetNodeConnectorStatisticsInputBuilder().setNode(new NodeRef(InstanceIdentifier.builder(Nodes.class).child(Node.class, new NodeKey(new NodeId(IfmConstants.OF_URI_PREFIX + dpn))).build())).setStoreStats(false);
Future<RpcResult<GetNodeConnectorStatisticsOutput>> rpcResultFuture = odlDirectStatisticsService.getNodeConnectorStatistics(input.build());
RpcResult<GetNodeConnectorStatisticsOutput> rpcResult = null;
try {
rpcResult = rpcResultFuture.get();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Exception {} occurred with node {} Direct-Statistics get", e, dpn);
}
if (rpcResult != null && rpcResult.isSuccessful() && rpcResult.getResult() != null) {
GetNodeConnectorStatisticsOutput nodeConnectorStatisticsOutput = rpcResult.getResult();
List<NodeConnectorStatisticsAndPortNumberMap> nodeConnectorStatisticsAndPortNumberMapList = nodeConnectorStatisticsOutput.getNodeConnectorStatisticsAndPortNumberMap();
ConcurrentMap<String, QosAlertPortData> portDataMap = entry.getValue();
for (NodeConnectorStatisticsAndPortNumberMap stats : nodeConnectorStatisticsAndPortNumberMapList) {
QosAlertPortData portData = portDataMap.get(stats.getNodeConnectorId().getValue());
if (portData != null) {
portData.updatePortStatistics(stats);
}
}
} else {
LOG.error("Direct-Statistics not available for node {}", dpn);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap in project netvirt by opendaylight.
the class QosAlertPortData method calculateAlertCondition.
private void calculateAlertCondition(NodeConnectorStatisticsAndPortNumberMap statsData) {
BigInteger rxDiff = statsData.getPackets().getReceived().subtract(rxPackets);
BigInteger rxDroppedDiff = statsData.getReceiveDrops().subtract(rxDroppedPackets);
BigInteger rxTotalDiff = rxDiff.add(rxDroppedDiff);
LOG.trace("Port {} rxDiff:{} rxDropped diff:{} total diff:{}", port.getUuid(), rxDiff, rxDroppedDiff, rxTotalDiff);
QosPolicy qosPolicy = qosNeutronUtils.getQosPolicy(port);
if (qosPolicy == null) {
return;
}
if (rxDroppedDiff.multiply(BIG_HUNDRED).compareTo(rxTotalDiff.multiply(alertThreshold.get())) > 0) {
LOG.trace(QosConstants.ALERT_MSG_FORMAT, qosPolicy.getName(), qosPolicy.getUuid().getValue(), port.getUuid().getValue(), port.getNetworkId().getValue(), statsData.getPackets().getReceived(), statsData.getReceiveDrops());
QosAlertGenerator.raiseAlert(qosPolicy.getName(), qosPolicy.getUuid().getValue(), port.getUuid().getValue(), port.getNetworkId().getValue(), statsData.getPackets().getReceived(), statsData.getReceiveDrops());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap in project openflowplugin by opendaylight.
the class PortStatsMultipartWriter method storeStatistics.
@Override
public void storeStatistics(final NodeConnectorStatisticsAndPortNumberMap statistics, final boolean withParents) {
statistics.getNodeConnectorStatisticsAndPortNumberMap().forEach(stat -> {
final OpenflowVersion openflowVersion = OpenflowVersion.get(features.getVersion());
final Long port = InventoryDataServiceUtil.portNumberfromNodeConnectorId(openflowVersion, stat.getNodeConnectorId());
final NodeConnectorId id = InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(features.getDatapathId(), port, OpenflowVersion.get(features.getVersion()));
writeToTransaction(getInstanceIdentifier().child(NodeConnector.class, new NodeConnectorKey(id)).augmentation(FlowCapableNodeConnectorStatisticsData.class).child(FlowCapableNodeConnectorStatistics.class), new FlowCapableNodeConnectorStatisticsBuilder(stat).build(), OFConstants.OFP_VERSION_1_0 == features.getVersion() || withParents);
});
}
Aggregations