Search in sources :

Example 1 with FlowTableAndStatisticsMap

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMap 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();
}
Also used : MultipartReplyFlowTableStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.multipart.reply.multipart.reply.body.MultipartReplyFlowTableStatsBuilder) FlowTableAndStatisticsMap(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMap) Counter32(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32) TableId(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId) Counter64(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64) MultipartReplyTableCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCase) ArrayList(java.util.ArrayList) MultipartReplyTable(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTable) FlowTableAndStatisticsMapBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMapBuilder) MultipartReplyFlowTableStats(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.multipart.reply.multipart.reply.body.MultipartReplyFlowTableStats) TableStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStats)

Example 2 with FlowTableAndStatisticsMap

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMap 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();
}
Also used : TableId(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId) MultipartReplyTableCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCase) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) FlowTableStatisticsUpdateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsUpdateBuilder) ArrayList(java.util.ArrayList) FlowTableAndStatisticsMapBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMapBuilder) TableStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStats) FlowTableAndStatisticsMap(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMap) Counter32(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32) Counter64(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64) MultipartReplyTable(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTable)

Example 3 with FlowTableAndStatisticsMap

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMap in project openflowplugin by opendaylight.

the class MultipartReplyFlowTableStatsDeserializer method deserialize.

@Override
public MultipartReplyBody deserialize(ByteBuf message) {
    final MultipartReplyFlowTableStatsBuilder builder = new MultipartReplyFlowTableStatsBuilder();
    final List<FlowTableAndStatisticsMap> items = new ArrayList<>();
    while (message.readableBytes() > 0) {
        final FlowTableAndStatisticsMapBuilder itemBuilder = new FlowTableAndStatisticsMapBuilder().setTableId(new TableId(message.readUnsignedByte()));
        message.skipBytes(PADDING_IN_TABLE_HEADER);
        itemBuilder.setKey(new FlowTableAndStatisticsMapKey(itemBuilder.getTableId())).setActiveFlows(new Counter32(message.readUnsignedInt()));
        final byte[] packetsLooked = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        message.readBytes(packetsLooked);
        final byte[] packetsMatched = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        message.readBytes(packetsMatched);
        items.add(itemBuilder.setPacketsLookedUp(new Counter64(new BigInteger(1, packetsLooked))).setPacketsMatched(new Counter64(new BigInteger(1, packetsMatched))).build());
    }
    return builder.setFlowTableAndStatisticsMap(items).build();
}
Also used : MultipartReplyFlowTableStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.multipart.reply.multipart.reply.body.MultipartReplyFlowTableStatsBuilder) FlowTableAndStatisticsMap(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMap) TableId(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId) Counter32(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32) Counter64(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64) FlowTableAndStatisticsMapKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMapKey) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) FlowTableAndStatisticsMapBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMapBuilder)

Aggregations

ArrayList (java.util.ArrayList)3 Counter32 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32)3 Counter64 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64)3 FlowTableAndStatisticsMap (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMap)3 FlowTableAndStatisticsMapBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMapBuilder)3 TableId (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId)3 MultipartReplyFlowTableStatsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.multipart.reply.multipart.reply.body.MultipartReplyFlowTableStatsBuilder)2 MultipartReplyTableCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCase)2 MultipartReplyTable (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTable)2 TableStats (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStats)2 BigInteger (java.math.BigInteger)1 FlowTableStatisticsUpdateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsUpdateBuilder)1 FlowTableAndStatisticsMapKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMapKey)1 MultipartReplyFlowTableStats (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.multipart.reply.multipart.reply.body.MultipartReplyFlowTableStats)1 MultipartReply (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply)1