use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTable 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.MultipartReplyTable 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.MultipartReplyTable in project openflowplugin by opendaylight.
the class OF10StatsReplyMessageFactoryTest method testTable.
/**
* Testing OF10StatsReplyMessageFactory (Table) for correct deserialization.
*/
@Test
public void testTable() {
ByteBuf bb = BufferHelper.buildBuffer("00 03 00 01 " + "08 00 00 00 4A 41 4D 45 53 20 42 4F 4E 44 00 00 00 00 00 00 00 00 00 " + "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 " + "00 00 00 30 00 00 00 10 FF 01 01 01 01 01 01 01 FF 01 01 01 01 01 01 00");
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb);
BufferHelper.checkHeaderV10(builtByFactory);
Assert.assertEquals("Wrong type", 0x03, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyTableCase messageCase = (MultipartReplyTableCase) builtByFactory.getMultipartReplyBody();
MultipartReplyTable message = messageCase.getMultipartReplyTable();
Assert.assertEquals("Wrong tableId", 8, message.getTableStats().get(0).getTableId().intValue());
Assert.assertEquals("Wrong name", "JAMES BOND", message.getTableStats().get(0).getName());
Assert.assertEquals("Wrong wildcards", new FlowWildcardsV10(false, false, false, false, false, false, false, false, false, false), message.getTableStats().get(0).getWildcards());
Assert.assertEquals("Wrong src-mask", 32, message.getTableStats().get(0).getNwSrcMask().intValue());
Assert.assertEquals("Wrong dst-mask", 32, message.getTableStats().get(0).getNwDstMask().intValue());
Assert.assertEquals("Wrong max-entries", 48, message.getTableStats().get(0).getMaxEntries().longValue());
Assert.assertEquals("Wrong activeCount", 16, message.getTableStats().get(0).getActiveCount().longValue());
Assert.assertEquals("Wrong lookupCount", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getTableStats().get(0).getLookupCount());
Assert.assertEquals("Wrong matchedCount", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00 }), message.getTableStats().get(0).getMatchedCount());
Assert.assertTrue("Unread data", bb.readableBytes() == 0);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTable in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactoryTest method testTableSerialize.
@Test
public void testTableSerialize() throws Exception {
MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setFlags(new MultipartRequestFlags(true));
builder.setType(MultipartType.forValue(3));
MultipartReplyTableCaseBuilder tableCase = new MultipartReplyTableCaseBuilder();
MultipartReplyTableBuilder table = new MultipartReplyTableBuilder();
table.setTableStats(createTableStats());
tableCase.setMultipartReplyTable(table.build());
builder.setMultipartReplyBody(tableCase.build());
MultipartReplyMessage message = builder.build();
ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
factory.serialize(message, serializedBuffer);
BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 40);
Assert.assertEquals("Wrong type", MultipartType.OFPMPTABLE.getIntValue(), serializedBuffer.readShort());
Assert.assertEquals("Wrong flags", message.getFlags(), createMultipartRequestFlags(serializedBuffer.readShort()));
serializedBuffer.skipBytes(PADDING);
MultipartReplyTableCase body = (MultipartReplyTableCase) message.getMultipartReplyBody();
MultipartReplyTable messageOutput = body.getMultipartReplyTable();
TableStats tableStats = messageOutput.getTableStats().get(0);
Assert.assertEquals("Wrong tableId", tableStats.getTableId().shortValue(), serializedBuffer.readUnsignedByte());
serializedBuffer.skipBytes(3);
Assert.assertEquals("Wrong active count", tableStats.getActiveCount().longValue(), serializedBuffer.readInt());
Assert.assertEquals("Wrong lookup count", tableStats.getLookupCount().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong matched count", tableStats.getMatchedCount().longValue(), serializedBuffer.readLong());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTable in project openflowplugin by opendaylight.
the class OF10StatsReplyMessageFactory method serializeTableBody.
private void serializeTableBody(MultipartReplyBody body, ByteBuf outBuffer) {
MultipartReplyTableCase tableCase = (MultipartReplyTableCase) body;
MultipartReplyTable table = tableCase.getMultipartReplyTable();
for (TableStats tableStats : table.getTableStats()) {
outBuffer.writeByte(tableStats.getTableId());
outBuffer.writeZero(TABLE_PADDING);
write16String(tableStats.getName(), outBuffer);
writeFlowWildcardsV10(tableStats.getWildcards(), outBuffer);
outBuffer.writeInt(tableStats.getMaxEntries().intValue());
outBuffer.writeInt(tableStats.getActiveCount().intValue());
outBuffer.writeLong(tableStats.getLookupCount().longValue());
outBuffer.writeLong(tableStats.getMatchedCount().longValue());
}
}
Aggregations