use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStats 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.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStats in project openflowplugin by opendaylight.
the class OpendaylightFlowTableStatisticsServiceImpl method transformToNotification.
@Override
public FlowTableStatisticsUpdate transformToNotification(List<MultipartReply> mpReplyList, TransactionId emulatedTxId) {
FlowTableStatisticsUpdateBuilder notification = new FlowTableStatisticsUpdateBuilder();
notification.setId(getDeviceInfo().getNodeId());
notification.setMoreReplies(Boolean.FALSE);
notification.setTransactionId(emulatedTxId);
final List<FlowTableAndStatisticsMap> salFlowStats = new ArrayList<>();
notification.setFlowTableAndStatisticsMap(salFlowStats);
for (MultipartReply mpReply : mpReplyList) {
MultipartReplyTableCase caseBody = (MultipartReplyTableCase) mpReply.getMultipartReplyBody();
MultipartReplyTable replyBody = caseBody.getMultipartReplyTable();
List<TableStats> swTablesStats = replyBody.getTableStats();
// TODO: Duplicate code: look at MultiReplyTranslatorUtil method translateTable
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());
}
}
return notification.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStats in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactoryTest method createTableStats.
private static List<TableStats> createTableStats() {
TableStatsBuilder builder = new TableStatsBuilder();
builder.setTableId((short) 1);
builder.setActiveCount(1L);
builder.setLookupCount(BigInteger.valueOf(1L));
builder.setMatchedCount(BigInteger.valueOf(1L));
List<TableStats> list = new ArrayList<>();
list.add(builder.build());
return list;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStats in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactory method setTable.
private static MultipartReplyTableCase setTable(final ByteBuf input) {
MultipartReplyTableCaseBuilder caseBuilder = new MultipartReplyTableCaseBuilder();
MultipartReplyTableBuilder builder = new MultipartReplyTableBuilder();
List<TableStats> tableStatsList = new ArrayList<>();
while (input.readableBytes() > 0) {
TableStatsBuilder tableStatsBuilder = new TableStatsBuilder();
tableStatsBuilder.setTableId(input.readUnsignedByte());
input.skipBytes(PADDING_IN_TABLE_HEADER);
tableStatsBuilder.setActiveCount(input.readUnsignedInt());
byte[] lookupCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
input.readBytes(lookupCount);
tableStatsBuilder.setLookupCount(new BigInteger(1, lookupCount));
byte[] matchedCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
input.readBytes(matchedCount);
tableStatsBuilder.setMatchedCount(new BigInteger(1, matchedCount));
tableStatsList.add(tableStatsBuilder.build());
}
builder.setTableStats(tableStatsList);
caseBuilder.setMultipartReplyTable(builder.build());
return caseBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStats in project openflowplugin by opendaylight.
the class OF10StatsReplyMessageFactory method setTable.
private static MultipartReplyTableCase setTable(ByteBuf input) {
final MultipartReplyTableCaseBuilder caseBuilder = new MultipartReplyTableCaseBuilder();
MultipartReplyTableBuilder builder = new MultipartReplyTableBuilder();
List<TableStats> tableStatsList = new ArrayList<>();
// TODO - replace ">= TABLE_STATS_LENGTH" with "> 0" after fix in OVS switch
while (input.readableBytes() >= TABLE_STATS_LENGTH) {
TableStatsBuilder tableStatsBuilder = new TableStatsBuilder();
tableStatsBuilder.setTableId(input.readUnsignedByte());
input.skipBytes(PADDING_IN_TABLE_HEADER);
tableStatsBuilder.setName(ByteBufUtils.decodeNullTerminatedString(input, MAX_TABLE_NAME_LENGTH));
long wildcards = input.readUnsignedInt();
tableStatsBuilder.setWildcards(OF10MatchDeserializer.createWildcards(wildcards));
tableStatsBuilder.setNwSrcMask(OF10MatchDeserializer.decodeNwSrcMask(wildcards));
tableStatsBuilder.setNwDstMask(OF10MatchDeserializer.decodeNwDstMask(wildcards));
tableStatsBuilder.setMaxEntries(input.readUnsignedInt());
tableStatsBuilder.setActiveCount(input.readUnsignedInt());
byte[] lookupCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
input.readBytes(lookupCount);
tableStatsBuilder.setLookupCount(new BigInteger(1, lookupCount));
byte[] matchedCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
input.readBytes(matchedCount);
tableStatsBuilder.setMatchedCount(new BigInteger(1, matchedCount));
tableStatsList.add(tableStatsBuilder.build());
}
input.skipBytes(input.readableBytes());
builder.setTableStats(tableStatsList);
caseBuilder.setMultipartReplyTable(builder.build());
return caseBuilder.build();
}
Aggregations