use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64 in project openflowplugin by opendaylight.
the class FlowStatsResponseConvertor method convert.
@Override
public List<FlowAndStatisticsMapList> convert(List<FlowStats> source, FlowStatsResponseConvertorData data) {
final List<FlowAndStatisticsMapList> result = new ArrayList<>();
for (FlowStats flowStats : source) {
// Convert Openflow switch specific flow statistics to the MD-SAL format flow statistics
FlowAndStatisticsMapListBuilder salFlowStatsBuilder = new FlowAndStatisticsMapListBuilder();
salFlowStatsBuilder.setByteCount(new Counter64(flowStats.getByteCount()));
if (flowStats.getCookie() != null) {
salFlowStatsBuilder.setCookie(new FlowCookie(flowStats.getCookie()));
}
DurationBuilder time = new DurationBuilder();
time.setSecond(new Counter32(flowStats.getDurationSec()));
time.setNanosecond(new Counter32(flowStats.getDurationNsec()));
salFlowStatsBuilder.setDuration(time.build());
salFlowStatsBuilder.setHardTimeout(flowStats.getHardTimeout());
salFlowStatsBuilder.setIdleTimeout(flowStats.getIdleTimeout());
salFlowStatsBuilder.setPacketCount(new Counter64(flowStats.getPacketCount()));
salFlowStatsBuilder.setPriority(flowStats.getPriority());
salFlowStatsBuilder.setTableId(flowStats.getTableId());
Short ipProtocol = null;
if (flowStats.getMatchV10() != null) {
final Optional<MatchBuilder> matchBuilderOptional = getConvertorExecutor().convert(flowStats.getMatchV10(), data);
if (matchBuilderOptional.isPresent()) {
if (Objects.nonNull(matchBuilderOptional.get().getIpMatch())) {
ipProtocol = matchBuilderOptional.get().getIpMatch().getIpProtocol();
}
salFlowStatsBuilder.setMatch(matchBuilderOptional.get().build());
}
if (flowStats.getAction() != null && flowStats.getAction().size() != 0) {
salFlowStatsBuilder.setInstructions(wrapOF10ActionsToInstruction(flowStats.getAction(), data.getVersion(), ipProtocol));
}
}
if (flowStats.getMatch() != null) {
final Optional<MatchBuilder> matchBuilderOptional = getConvertorExecutor().convert(flowStats.getMatch(), data);
if (matchBuilderOptional.isPresent()) {
final MatchBuilder matchBuilder = matchBuilderOptional.get();
final AugmentTuple<Match> matchExtensionWrap = MatchExtensionHelper.processAllExtensions(flowStats.getMatch().getMatchEntry(), OpenflowVersion.get(data.getVersion()), data.getMatchPath());
if (matchExtensionWrap != null) {
matchBuilder.addAugmentation(matchExtensionWrap.getAugmentationClass(), matchExtensionWrap.getAugmentationObject());
}
salFlowStatsBuilder.setMatch(matchBuilder.build());
}
salFlowStatsBuilder.setFlags(new FlowModFlags(flowStats.getFlags().isOFPFFCHECKOVERLAP(), flowStats.getFlags().isOFPFFRESETCOUNTS(), flowStats.getFlags().isOFPFFNOPKTCOUNTS(), flowStats.getFlags().isOFPFFNOBYTCOUNTS(), flowStats.getFlags().isOFPFFSENDFLOWREM()));
}
if (flowStats.getInstruction() != null) {
final VersionConvertorData simpleConvertorData = new VersionConvertorData(data.getVersion());
final Optional<Instructions> instructions = getConvertorExecutor().convert(flowStats.getInstruction(), simpleConvertorData);
salFlowStatsBuilder.setInstructions(instructions.orElse(new InstructionsBuilder().setInstruction(Collections.emptyList()).build()));
}
result.add(salFlowStatsBuilder.build());
}
return result;
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64 in project openflowplugin by opendaylight.
the class MultipartReplyMeterStatsDeserializer method deserialize.
@Override
public MultipartReplyBody deserialize(ByteBuf message) {
final MultipartReplyMeterStatsBuilder builder = new MultipartReplyMeterStatsBuilder();
final List<MeterStats> items = new ArrayList<>();
while (message.readableBytes() > 0) {
final MeterStatsBuilder itemBuilder = new MeterStatsBuilder().setMeterId(new MeterId(message.readUnsignedInt()));
final int itemLength = message.readUnsignedShort();
message.skipBytes(PADDING_IN_METER_STATS_HEADER);
itemBuilder.setKey(new MeterStatsKey(itemBuilder.getMeterId())).setFlowCount(new Counter32(message.readUnsignedInt()));
final byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
message.readBytes(packetCount);
final byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
message.readBytes(byteCount);
itemBuilder.setPacketInCount(new Counter64(new BigInteger(1, packetCount))).setByteInCount(new Counter64(new BigInteger(1, byteCount))).setDuration(new DurationBuilder().setSecond(new Counter32(message.readUnsignedInt())).setNanosecond(new Counter32(message.readUnsignedInt())).build());
final List<BandStat> subItems = new ArrayList<>();
int actualLength = METER_BODY_LENGTH;
long bandKey = 0;
while (actualLength < itemLength) {
final byte[] packetCountB = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
message.readBytes(packetCountB);
final byte[] byteCountB = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
message.readBytes(byteCountB);
subItems.add(new BandStatBuilder().setBandId(new BandId(bandKey)).setKey(new BandStatKey(new BandId(bandKey))).setPacketBandCount(new Counter64(new BigInteger(1, packetCountB))).setByteBandCount(new Counter64(new BigInteger(1, byteCountB))).build());
bandKey++;
actualLength += METER_BAND_STATS_LENGTH;
}
items.add(itemBuilder.setMeterBandStats(new MeterBandStatsBuilder().setBandStat(subItems).build()).build());
}
return builder.setMeterStats(items).build();
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64 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.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64 in project openflowplugin by opendaylight.
the class MultipartReplyTranslatorUtil method translateTable.
private static MultipartReplyFlowTableStats translateTable(final MultipartReply msg) {
MultipartReplyFlowTableStatsBuilder message = new MultipartReplyFlowTableStatsBuilder();
MultipartReplyTableCase caseBody = (MultipartReplyTableCase) msg.getMultipartReplyBody();
MultipartReplyTable replyBody = caseBody.getMultipartReplyTable();
List<TableStats> swTablesStats = replyBody.getTableStats();
List<FlowTableAndStatisticsMap> salFlowStats = new ArrayList<>();
// TODO: Duplicate code: look at OpendaylightFlowTableStatisticsServiceImpl method transformToNotification
for (TableStats swTableStats : swTablesStats) {
FlowTableAndStatisticsMapBuilder statisticsBuilder = new FlowTableAndStatisticsMapBuilder();
statisticsBuilder.setActiveFlows(new Counter32(swTableStats.getActiveCount()));
statisticsBuilder.setPacketsLookedUp(new Counter64(swTableStats.getLookupCount()));
statisticsBuilder.setPacketsMatched(new Counter64(swTableStats.getMatchedCount()));
statisticsBuilder.setTableId(new TableId(swTableStats.getTableId()));
salFlowStats.add(statisticsBuilder.build());
}
message.setFlowTableAndStatisticsMap(salFlowStats);
return message.build();
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64 in project openflowplugin by opendaylight.
the class MultipartReplyFlowAggregateStatsDeserializer method deserialize.
@Override
public MultipartReplyBody deserialize(ByteBuf message) {
final byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
message.readBytes(packetCount);
final byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
message.readBytes(byteCount);
final MultipartReplyFlowAggregateStatsBuilder builder = new MultipartReplyFlowAggregateStatsBuilder().setPacketCount(new Counter64(new BigInteger(1, packetCount))).setByteCount(new Counter64(new BigInteger(1, byteCount))).setFlowCount(new Counter32(message.readUnsignedInt()));
message.skipBytes(PADDING_IN_AGGREGATE_HEADER);
return builder.build();
}
Aggregations