use of org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsOutput 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.direct.statistics.rev160511.GetNodeConnectorStatisticsOutput 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.direct.statistics.rev160511.GetNodeConnectorStatisticsOutput in project netvirt by opendaylight.
the class CounterRetriever method getNodeConnectorCountersDirect.
public CounterResultDataStructure getNodeConnectorCountersDirect(NodeId nodeId, NodeConnectorId nodeConnectorId) {
GetNodeConnectorStatisticsInput gncsi = getNodeConnectorStatisticsInputBuilder(nodeId, nodeConnectorId);
Future<RpcResult<GetNodeConnectorStatisticsOutput>> rpcResultFuture = odlDirectStatsService.getNodeConnectorStatistics(gncsi);
RpcResult<GetNodeConnectorStatisticsOutput> rpcResult = null;
try {
rpcResult = rpcResultFuture.get();
} catch (InterruptedException | ExecutionException e) {
counters.failedGettingNodeConnectorCounters.inc();
LOG.warn("Unable to retrieve node connector counters for port {}", nodeConnectorId);
return null;
}
if (rpcResult != null && rpcResult.isSuccessful() && rpcResult.getResult() != null) {
GetNodeConnectorStatisticsOutput nodeConnectorStatsOutput = rpcResult.getResult();
return createNodeConnectorResultMapDirect(nodeConnectorStatsOutput, nodeConnectorId);
} else {
counters.failedGettingRpcResultForNodeConnectorCounters.inc();
LOG.warn("Unable to retrieve node connector counters for port {}", nodeConnectorId);
return null;
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsOutput 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.direct.statistics.rev160511.GetNodeConnectorStatisticsOutput in project openflowplugin by opendaylight.
the class OpendaylightDirectStatisticsServiceImplTest method testGetNodeConnectorStatisticsFail.
@Test
public void testGetNodeConnectorStatisticsFail() throws Exception {
RpcResult<GetNodeConnectorStatisticsOutput> result = emptyService.getNodeConnectorStatistics(getNodeConnectorStatisticsInput).get();
assertFalse(result.isSuccessful());
for (RpcError error : result.getErrors()) {
assertTrue(error.getMessage().contains(AbstractPortDirectStatisticsService.class.getSimpleName()));
}
verify(nodeConnectorDirectStatisticsService, times(0)).handleAndReply(getNodeConnectorStatisticsInput);
}
Aggregations