use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.multipart.reply.multipart.reply.body.MultipartReplyFlowTableStats 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.opendaylight.flow.table.statistics.rev131215.multipart.reply.multipart.reply.body.MultipartReplyFlowTableStats in project openflowplugin by opendaylight.
the class MultipartReplyFlowTableStatsDeserializerTest method testDeserialize.
@Test
public void testDeserialize() throws Exception {
ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer();
buffer.writeByte(TABLE_ID);
buffer.writeZero(PADDING_IN_TABLE_HEADER);
buffer.writeInt(ACTIVE_FLOWS);
buffer.writeLong(PACKETS_LOOKEDUP);
buffer.writeLong(PACKETS_MATCHED);
final MultipartReplyFlowTableStats reply = (MultipartReplyFlowTableStats) deserializeMultipart(buffer);
assertEquals(TABLE_ID, reply.getFlowTableAndStatisticsMap().get(0).getTableId().getValue().byteValue());
assertEquals(ACTIVE_FLOWS, reply.getFlowTableAndStatisticsMap().get(0).getActiveFlows().getValue().intValue());
assertEquals(PACKETS_LOOKEDUP, reply.getFlowTableAndStatisticsMap().get(0).getPacketsLookedUp().getValue().longValue());
assertEquals(PACKETS_MATCHED, reply.getFlowTableAndStatisticsMap().get(0).getPacketsMatched().getValue().longValue());
assertEquals(0, buffer.readableBytes());
}
Aggregations