Search in sources :

Example 96 with GroupId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId in project openflowplugin by opendaylight.

the class MultipartRequestGroupInputMessageFactoryTest method createRequestGroup.

private static MultipartRequestGroupCase createRequestGroup() {
    MultipartRequestGroupCaseBuilder caseBuilder = new MultipartRequestGroupCaseBuilder();
    MultipartRequestGroupBuilder builder = new MultipartRequestGroupBuilder();
    builder.setGroupId(new GroupId(2258L));
    caseBuilder.setMultipartRequestGroup(builder.build());
    return caseBuilder.build();
}
Also used : MultipartRequestGroupCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupCaseBuilder) MultipartRequestGroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group._case.MultipartRequestGroupBuilder) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId)

Example 97 with GroupId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId 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 98 with GroupId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId in project openflowplugin by opendaylight.

the class GroupStatsService method buildRequest.

@Override
protected OfHeader buildRequest(final Xid xid, final GetGroupStatisticsInput input) throws ServiceException {
    final MultipartRequestGroupCaseBuilder caseBuilder = new MultipartRequestGroupCaseBuilder();
    final MultipartRequestGroupBuilder mprGroupBuild = new MultipartRequestGroupBuilder();
    mprGroupBuild.setGroupId(new GroupId(input.getGroupId().getValue()));
    caseBuilder.setMultipartRequestGroup(mprGroupBuild.build());
    final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(MultipartType.OFPMPGROUP, xid.getValue(), getVersion());
    mprInput.setMultipartRequestBody(caseBuilder.build());
    return mprInput.build();
}
Also used : MultipartRequestGroupCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupCaseBuilder) MultipartRequestInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder) MultipartRequestGroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group._case.MultipartRequestGroupBuilder) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId)

Example 99 with GroupId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId 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)

Example 100 with GroupId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId in project openflowplugin by opendaylight.

the class GroupConvertor method convert.

@Override
public GroupModInputBuilder convert(Group source, VersionDatapathIdConvertorData data) {
    GroupModInputBuilder groupModInputBuilder = new GroupModInputBuilder();
    if (source instanceof AddGroupInput) {
        groupModInputBuilder.setCommand(GroupModCommand.OFPGCADD);
    } else if (source instanceof RemoveGroupInput) {
        groupModInputBuilder.setCommand(GroupModCommand.OFPGCDELETE);
    } else if (source instanceof UpdatedGroup) {
        groupModInputBuilder.setCommand(GroupModCommand.OFPGCMODIFY);
    }
    if (GroupTypes.GroupAll.equals(source.getGroupType())) {
        groupModInputBuilder.setType(GroupType.OFPGTALL);
    }
    if (GroupTypes.GroupSelect.equals(source.getGroupType())) {
        groupModInputBuilder.setType(GroupType.OFPGTSELECT);
    }
    if (GroupTypes.GroupIndirect.equals(source.getGroupType())) {
        groupModInputBuilder.setType(GroupType.OFPGTINDIRECT);
    }
    if (GroupTypes.GroupFf.equals(source.getGroupType())) {
        groupModInputBuilder.setType(GroupType.OFPGTFF);
    }
    groupModInputBuilder.setGroupId(new GroupId(source.getGroupId().getValue()));
    // During group deletion do not push the buckets
    if (groupModInputBuilder.getCommand() != GroupModCommand.OFPGCDELETE) {
        if (source.getBuckets() != null && source.getBuckets().getBucket().size() != 0) {
            Collections.sort(source.getBuckets().getBucket(), COMPARATOR);
            List<BucketsList> bucketLists = salToOFBucketList(source.getBuckets(), data.getVersion(), source.getGroupType().getIntValue(), data.getDatapathId());
            groupModInputBuilder.setBucketsList(bucketLists);
        }
    }
    groupModInputBuilder.setVersion(data.getVersion());
    return groupModInputBuilder;
}
Also used : RemoveGroupInput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput) AddGroupInput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput) GroupModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInputBuilder) UpdatedGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.UpdatedGroup) BucketsList(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId)

Aggregations

ArrayList (java.util.ArrayList)41 GroupId (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId)36 Test (org.junit.Test)28 Bucket (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket)27 GroupId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId)22 Group (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group)21 BigInteger (java.math.BigInteger)19 ActionGroup (org.opendaylight.genius.mdsalutil.actions.ActionGroup)18 GroupBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder)12 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)11 BucketsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder)10 BucketBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketBuilder)10 ByteBuf (io.netty.buffer.ByteBuf)9 GroupKey (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey)9 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)8 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)8 AddGroupInput (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput)8 AddGroupInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder)8 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder)7 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action)6