Search in sources :

Example 1 with GroupDescStatsKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStatsKey in project openflowplugin by opendaylight.

the class MultipartReplyGroupDescDeserializer method deserialize.

@Override
public MultipartReplyBody deserialize(ByteBuf message) {
    final MultipartReplyGroupDescBuilder builder = new MultipartReplyGroupDescBuilder();
    final List<GroupDescStats> items = new ArrayList<>();
    while (message.readableBytes() > 0) {
        final int itemLength = message.readUnsignedShort();
        final GroupDescStatsBuilder itemBuilder = new GroupDescStatsBuilder().setGroupType(GroupTypes.forValue(message.readUnsignedByte()));
        message.skipBytes(PADDING_IN_GROUP_DESC_HEADER);
        itemBuilder.setGroupId(new GroupId(message.readUnsignedInt()));
        itemBuilder.setKey(new GroupDescStatsKey(itemBuilder.getGroupId()));
        final List<Bucket> subItems = new ArrayList<>();
        int actualLength = GROUP_DESC_HEADER_LENGTH;
        long bucketKey = 0;
        while (actualLength < itemLength) {
            final int bucketsLength = message.readUnsignedShort();
            final BucketBuilder bucketBuilder = new BucketBuilder().setBucketId(new BucketId(bucketKey)).setKey(new BucketKey(new BucketId(bucketKey))).setWeight(message.readUnsignedShort()).setWatchPort(message.readUnsignedInt()).setWatchGroup(message.readUnsignedInt());
            message.skipBytes(PADDING_IN_BUCKETS_HEADER);
            final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actions = new ArrayList<>();
            final int startIndex = message.readerIndex();
            final int bucketLength = bucketsLength - BUCKETS_HEADER_LENGTH;
            int offset = 0;
            while (message.readerIndex() - startIndex < bucketLength) {
                actions.add(new ActionBuilder().setKey(new ActionKey(offset)).setOrder(offset).setAction(ActionUtil.readAction(EncodeConstants.OF13_VERSION_ID, message, registry, ActionPath.GROUP_DESC_STATS_UPDATED_BUCKET_ACTION)).build());
                offset++;
            }
            bucketBuilder.setAction(actions);
            subItems.add(bucketBuilder.build());
            bucketKey++;
            actualLength += bucketsLength;
        }
        items.add(itemBuilder.setBuckets(new BucketsBuilder().setBucket(subItems).build()).build());
    }
    return builder.setGroupDescStats(items).build();
}
Also used : ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder) GroupDescStatsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStatsKey) GroupDescStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStatsBuilder) BucketKey(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketKey) ArrayList(java.util.ArrayList) BucketsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder) BucketId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.BucketId) BucketBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketBuilder) GroupDescStats(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStats) ActionKey(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) MultipartReplyGroupDescBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyGroupDescBuilder)

Example 2 with GroupDescStatsKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStatsKey in project openflowplugin by opendaylight.

the class GroupDescStatsResponseConvertor method convert.

@Override
public List<GroupDescStats> convert(List<GroupDesc> source, VersionConvertorData data) {
    List<GroupDescStats> convertedSALGroupsDesc = new ArrayList<>();
    for (GroupDesc groupDesc : source) {
        GroupDescStatsBuilder salGroupDescStats = new GroupDescStatsBuilder();
        salGroupDescStats.setBuckets(toSALBucketsDesc(groupDesc.getBucketsList(), data.getVersion()));
        salGroupDescStats.setGroupId(new GroupId(groupDesc.getGroupId().getValue()));
        salGroupDescStats.setGroupType(GroupTypes.forValue(groupDesc.getType().getIntValue()));
        salGroupDescStats.setKey(new GroupDescStatsKey(salGroupDescStats.getGroupId()));
        convertedSALGroupsDesc.add(salGroupDescStats.build());
    }
    return convertedSALGroupsDesc;
}
Also used : GroupDesc(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.multipart.reply.group.desc.GroupDesc) GroupDescStatsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStatsKey) GroupDescStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStatsBuilder) ArrayList(java.util.ArrayList) GroupDescStats(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStats) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId)

Aggregations

ArrayList (java.util.ArrayList)2 GroupId (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId)2 GroupDescStats (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStats)2 GroupDescStatsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStatsBuilder)2 GroupDescStatsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStatsKey)2 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder)1 ActionKey (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey)1 MultipartReplyGroupDescBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyGroupDescBuilder)1 BucketId (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.BucketId)1 BucketsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder)1 Bucket (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket)1 BucketBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketBuilder)1 BucketKey (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketKey)1 GroupDesc (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.multipart.reply.group.desc.GroupDesc)1