use of org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMapBuilder in project openflowplugin by opendaylight.
the class QueueStatNotificationSupplierImpl method createNotification.
@Override
public QueueStatisticsUpdate createNotification(final FlowCapableNodeConnectorQueueStatisticsData statisticsDataTreeItem, final InstanceIdentifier<FlowCapableNodeConnectorQueueStatisticsData> path) {
Preconditions.checkArgument(statisticsDataTreeItem != null);
Preconditions.checkArgument(path != null);
final NodeConnectorBuilder connBuilder = new NodeConnectorBuilder();
final NodeConnectorKey key = path.firstKeyOf(NodeConnector.class, NodeConnectorKey.class);
connBuilder.setId(key.getId());
connBuilder.setKey(key);
final QueueIdAndStatisticsMapBuilder queueStatMapBuilder = new QueueIdAndStatisticsMapBuilder(statisticsDataTreeItem.getFlowCapableNodeConnectorQueueStatistics());
final QueueStatisticsUpdateBuilder builder = new QueueStatisticsUpdateBuilder();
builder.setId(getNodeId(path));
builder.setMoreReplies(Boolean.FALSE);
builder.setQueueIdAndStatisticsMap(Collections.singletonList(queueStatMapBuilder.build()));
builder.setNodeConnector(Collections.singletonList(connBuilder.build()));
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMapBuilder in project openflowplugin by opendaylight.
the class QueueStatisticsToNotificationTransformer method transformToNotification.
/**
* Transform statistics to notification.
*
* @param mpReplyList raw multipart response from device
* @param deviceInfo device state
* @param ofVersion device version
* @param emulatedTxId emulated transaction Id
* @return notification containing flow stats
*/
public static QueueStatisticsUpdate transformToNotification(final List<MultipartReply> mpReplyList, final DeviceInfo deviceInfo, final OpenflowVersion ofVersion, final TransactionId emulatedTxId) {
QueueStatisticsUpdateBuilder notification = new QueueStatisticsUpdateBuilder();
notification.setId(deviceInfo.getNodeId());
notification.setMoreReplies(Boolean.FALSE);
notification.setTransactionId(emulatedTxId);
notification.setQueueIdAndStatisticsMap(new ArrayList<>());
for (MultipartReply mpReply : mpReplyList) {
MultipartReplyQueueCase caseBody = (MultipartReplyQueueCase) mpReply.getMultipartReplyBody();
MultipartReplyQueue replyBody = caseBody.getMultipartReplyQueue();
for (QueueStats queueStats : replyBody.getQueueStats()) {
QueueIdAndStatisticsMapBuilder statsBuilder = new QueueIdAndStatisticsMapBuilder();
statsBuilder.setNodeConnectorId(InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(deviceInfo.getDatapathId(), queueStats.getPortNo(), ofVersion));
statsBuilder.setTransmissionErrors(new Counter64(queueStats.getTxErrors()));
statsBuilder.setTransmittedBytes(new Counter64(queueStats.getTxBytes()));
statsBuilder.setTransmittedPackets(new Counter64(queueStats.getTxPackets()));
DurationBuilder durationBuilder = new DurationBuilder();
durationBuilder.setSecond(new Counter32(queueStats.getDurationSec()));
durationBuilder.setNanosecond(new Counter32(queueStats.getDurationNsec()));
statsBuilder.setDuration(durationBuilder.build());
statsBuilder.setQueueId(new QueueId(queueStats.getQueueId()));
notification.getQueueIdAndStatisticsMap().add(statsBuilder.build());
}
}
return notification.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMapBuilder in project openflowplugin by opendaylight.
the class QueueDirectStatisticsServiceTest method testBuildReply.
@Override
public void testBuildReply() throws Exception {
final QueueIdAndStatisticsMap queueStats = new QueueIdAndStatisticsMapBuilder().setQueueId(new QueueId(QUEUE_NO)).setNodeConnectorId(new NodeConnectorId(PORT_NO.toString())).setTransmittedBytes(new Counter64(BigInteger.ONE)).setTransmissionErrors(new Counter64(BigInteger.ONE)).setTransmittedBytes(new Counter64(BigInteger.ONE)).build();
final MultipartReply reply = new MultipartReplyBuilder().setMultipartReplyBody(new MultipartReplyQueueStatsBuilder().setQueueIdAndStatisticsMap(Collections.singletonList(queueStats)).build()).build();
final List<MultipartReply> input = Collections.singletonList(reply);
final GetQueueStatisticsOutput output = service.buildReply(input, true);
assertTrue(output.getQueueIdAndStatisticsMap().size() > 0);
final QueueIdAndStatisticsMap map = output.getQueueIdAndStatisticsMap().get(0);
assertEquals(map.getQueueId().getValue(), QUEUE_NO);
assertEquals(map.getNodeConnectorId().getValue(), PORT_NO.toString());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMapBuilder in project openflowplugin by opendaylight.
the class MultipartReplyTranslatorUtil method translateQueue.
private static MultipartReplyQueueStats translateQueue(final MultipartReply msg, final OpenflowVersion ofVersion, final BigInteger datapathId) {
MultipartReplyQueueStatsBuilder message = new MultipartReplyQueueStatsBuilder();
MultipartReplyQueueCase caseBody = (MultipartReplyQueueCase) msg.getMultipartReplyBody();
MultipartReplyQueue replyBody = caseBody.getMultipartReplyQueue();
List<QueueIdAndStatisticsMap> statsMap = new ArrayList<>();
for (QueueStats queueStats : replyBody.getQueueStats()) {
QueueIdAndStatisticsMapBuilder statsBuilder = new QueueIdAndStatisticsMapBuilder();
statsBuilder.setNodeConnectorId(InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(datapathId, queueStats.getPortNo(), ofVersion));
statsBuilder.setTransmissionErrors(new Counter64(queueStats.getTxErrors()));
statsBuilder.setTransmittedBytes(new Counter64(queueStats.getTxBytes()));
statsBuilder.setTransmittedPackets(new Counter64(queueStats.getTxPackets()));
DurationBuilder durationBuilder = new DurationBuilder();
durationBuilder.setSecond(new Counter32(queueStats.getDurationSec()));
durationBuilder.setNanosecond(new Counter32(queueStats.getDurationNsec()));
statsBuilder.setDuration(durationBuilder.build());
statsBuilder.setQueueId(new QueueId(queueStats.getQueueId()));
statsBuilder.setNodeConnectorId(InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(datapathId, queueStats.getPortNo(), ofVersion));
statsMap.add(statsBuilder.build());
}
message.setQueueIdAndStatisticsMap(statsMap);
return message.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMapBuilder in project openflowplugin by opendaylight.
the class MultipartReplyQueueStatsDeserializer method deserialize.
@Override
public MultipartReplyBody deserialize(ByteBuf message) {
final MultipartReplyQueueStatsBuilder builder = new MultipartReplyQueueStatsBuilder();
final List<QueueIdAndStatisticsMap> items = new ArrayList<>();
while (message.readableBytes() > 0) {
final long port = message.readUnsignedInt();
final NodeConnectorId nodeConnectorId = new NodeConnectorId(OpenflowPortsUtil.getProtocolAgnosticPortUri(EncodeConstants.OF13_VERSION_ID, port));
final QueueId queueId = new QueueId(message.readUnsignedInt());
final byte[] txBytes = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
message.readBytes(txBytes);
final byte[] txPackets = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
message.readBytes(txPackets);
final byte[] txErrors = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
message.readBytes(txErrors);
items.add(new QueueIdAndStatisticsMapBuilder().setKey(new QueueIdAndStatisticsMapKey(nodeConnectorId, queueId)).setNodeConnectorId(nodeConnectorId).setQueueId(queueId).setTransmittedBytes(new Counter64(new BigInteger(1, txBytes))).setTransmittedPackets(new Counter64(new BigInteger(1, txPackets))).setTransmissionErrors(new Counter64(new BigInteger(1, txErrors))).setDuration(new DurationBuilder().setSecond(new Counter32(message.readUnsignedInt())).setNanosecond(new Counter32(message.readUnsignedInt())).build()).build());
}
return builder.setQueueIdAndStatisticsMap(items).build();
}
Aggregations