Search in sources :

Example 21 with Counter64

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 MultipartReplyFlowStatsDeserializer method deserialize.

@Override
public MultipartReplyBody deserialize(ByteBuf message) {
    final MultipartReplyFlowStatsBuilder builder = new MultipartReplyFlowStatsBuilder();
    final List<FlowAndStatisticsMapList> items = new ArrayList<>();
    while (message.readableBytes() > 0) {
        final FlowAndStatisticsMapListBuilder itemBuilder = new FlowAndStatisticsMapListBuilder();
        final int itemLength = message.readUnsignedShort();
        final ByteBuf itemMessage = message.readSlice(itemLength - EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
        itemBuilder.setTableId(itemMessage.readUnsignedByte());
        itemMessage.skipBytes(PADDING_IN_FLOW_STATS_HEADER_01);
        itemBuilder.setDuration(new DurationBuilder().setSecond(new Counter32(itemMessage.readUnsignedInt())).setNanosecond(new Counter32(itemMessage.readUnsignedInt())).build()).setPriority(itemMessage.readUnsignedShort()).setIdleTimeout(itemMessage.readUnsignedShort()).setHardTimeout(itemMessage.readUnsignedShort()).setFlags(createFlowModFlagsFromBitmap(itemMessage.readUnsignedShort()));
        itemMessage.skipBytes(PADDING_IN_FLOW_STATS_HEADER_02);
        final byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        itemMessage.readBytes(cookie);
        final byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        itemMessage.readBytes(packetCount);
        final byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        itemMessage.readBytes(byteCount);
        itemBuilder.setCookie(new FlowCookie(new BigInteger(1, cookie))).setCookieMask(new FlowCookie(OFConstants.DEFAULT_COOKIE_MASK)).setPacketCount(new Counter64(new BigInteger(1, packetCount))).setByteCount(new Counter64(new BigInteger(1, byteCount)));
        final OFDeserializer<Match> matchDeserializer = Preconditions.checkNotNull(registry).getDeserializer(MATCH_KEY);
        itemBuilder.setMatch(MatchUtil.transformMatch(matchDeserializer.deserialize(itemMessage), org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match.class));
        final int length = itemMessage.readableBytes();
        if (length > 0) {
            final List<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction> instructions = new ArrayList<>();
            final int startIndex = itemMessage.readerIndex();
            int offset = 0;
            while (itemMessage.readerIndex() - startIndex < length) {
                instructions.add(new InstructionBuilder().setKey(new InstructionKey(offset)).setOrder(offset).setInstruction(InstructionUtil.readInstruction(EncodeConstants.OF13_VERSION_ID, itemMessage, registry)).build());
                offset++;
            }
            itemBuilder.setInstructions(new InstructionsBuilder().setInstruction(instructions).build());
        }
        items.add(itemBuilder.build());
    }
    return builder.setFlowAndStatisticsMapList(items).build();
}
Also used : InstructionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder) ArrayList(java.util.ArrayList) InstructionKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey) FlowAndStatisticsMapList(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList) ByteBuf(io.netty.buffer.ByteBuf) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match) InstructionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder) Counter64(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64) FlowCookie(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie) FlowAndStatisticsMapListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListBuilder) Counter32(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32) MultipartReplyFlowStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.multipart.reply.multipart.reply.body.MultipartReplyFlowStatsBuilder) BigInteger(java.math.BigInteger) DurationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.duration.DurationBuilder)

Example 22 with Counter64

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 MultipartReplyGroupStatsDeserializer method deserialize.

@Override
public MultipartReplyBody deserialize(ByteBuf message) {
    final MultipartReplyGroupStatsBuilder builder = new MultipartReplyGroupStatsBuilder();
    final List<GroupStats> items = new ArrayList<>();
    while (message.readableBytes() > 0) {
        final int itemLength = message.readUnsignedShort();
        message.skipBytes(PADDING_IN_GROUP_HEADER_01);
        final GroupStatsBuilder itemBuilder = new GroupStatsBuilder().setGroupId(new GroupId(message.readUnsignedInt())).setRefCount(new Counter32(message.readUnsignedInt()));
        message.skipBytes(PADDING_IN_GROUP_HEADER_02);
        final byte[] packetCountg = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        message.readBytes(packetCountg);
        final byte[] byteCountg = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        message.readBytes(byteCountg);
        itemBuilder.setKey(new GroupStatsKey(itemBuilder.getGroupId())).setPacketCount(new Counter64(new BigInteger(1, packetCountg))).setByteCount(new Counter64(new BigInteger(1, byteCountg))).setDuration(new DurationBuilder().setSecond(new Counter32(message.readUnsignedInt())).setNanosecond(new Counter32(message.readUnsignedInt())).build());
        final List<BucketCounter> subItems = new ArrayList<>();
        int actualLength = GROUP_BODY_LENGTH;
        long bucketKey = 0;
        while (actualLength < itemLength) {
            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);
            subItems.add(new BucketCounterBuilder().setBucketId(new BucketId(bucketKey)).setKey(new BucketCounterKey(new BucketId(bucketKey))).setPacketCount(new Counter64(new BigInteger(1, packetCount))).setByteCount(new Counter64(new BigInteger(1, byteCount))).build());
            bucketKey++;
            actualLength += BUCKET_COUNTER_LENGTH;
        }
        items.add(itemBuilder.setBuckets(new BucketsBuilder().setBucketCounter(subItems).build()).build());
    }
    return builder.setGroupStats(items).build();
}
Also used : BucketCounter(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.buckets.BucketCounter) ArrayList(java.util.ArrayList) BucketsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.BucketsBuilder) MultipartReplyGroupStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyGroupStatsBuilder) GroupStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStatsBuilder) BucketId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.BucketId) MultipartReplyGroupStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyGroupStatsBuilder) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId) Counter32(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32) GroupStatsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStatsKey) Counter64(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64) GroupStats(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats) BigInteger(java.math.BigInteger) BucketCounterKey(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.buckets.BucketCounterKey) BucketCounterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.buckets.BucketCounterBuilder) DurationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.DurationBuilder)

Example 23 with Counter64

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 GroupStatsResponseConvertor method convert.

@Override
public List<GroupStats> convert(List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStats> source, VersionConvertorData data) {
    List<GroupStats> convertedSALGroups = new ArrayList<>();
    for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStats groupStats : source) {
        GroupStatsBuilder salGroupStats = new GroupStatsBuilder();
        salGroupStats.setBuckets(toSALBuckets(groupStats.getBucketStats()));
        salGroupStats.setByteCount(new Counter64(groupStats.getByteCount()));
        DurationBuilder time = new DurationBuilder();
        time.setSecond(new Counter32(groupStats.getDurationSec()));
        time.setNanosecond(new Counter32(groupStats.getDurationNsec()));
        salGroupStats.setDuration(time.build());
        salGroupStats.setGroupId(new GroupId(groupStats.getGroupId().getValue()));
        salGroupStats.setPacketCount(new Counter64(groupStats.getPacketCount()));
        salGroupStats.setRefCount(new Counter32(groupStats.getRefCount()));
        salGroupStats.setKey(new GroupStatsKey(salGroupStats.getGroupId()));
        convertedSALGroups.add(salGroupStats.build());
    }
    return convertedSALGroups;
}
Also used : ArrayList(java.util.ArrayList) GroupStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStatsBuilder) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId) Counter32(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32) GroupStatsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStatsKey) Counter64(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64) GroupStats(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats) DurationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.DurationBuilder)

Aggregations

Counter64 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64)23 Counter32 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32)20 ArrayList (java.util.ArrayList)13 DurationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.duration.DurationBuilder)7 BigInteger (java.math.BigInteger)6 QueueId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId)5 MultipartReply (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply)5 QueueIdAndStatisticsMapBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMapBuilder)5 TableId (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId)5 Test (org.junit.Test)3 FlowAndStatisticsMapList (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList)3 FlowAndStatisticsMapListBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListBuilder)3 AggregatedFlowStatisticsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatisticsBuilder)3 MultipartReplyFlowAggregateStatsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.multipart.reply.multipart.reply.body.MultipartReplyFlowAggregateStatsBuilder)3 MultipartReplyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReplyBuilder)3 QueueIdAndStatisticsMap (org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMap)3 GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder)2 GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput)2 FlowTableAndStatisticsMap (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMap)2 FlowTableAndStatisticsMapBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMapBuilder)2