Search in sources :

Example 41 with GroupId

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

the class FlowNodeReconciliationImpl method getDeleteAllGroup.

private Group getDeleteAllGroup() {
    final GroupBuilder groupBuilder = new GroupBuilder();
    groupBuilder.setGroupType(GroupTypes.GroupAll);
    groupBuilder.setGroupId(new GroupId(OFConstants.OFPG_ALL));
    return groupBuilder.build();
}
Also used : GroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId)

Example 42 with GroupId

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

the class GroupMessageDeserializer method deserialize.

@Override
public GroupMessage deserialize(ByteBuf message) {
    final GroupMessageBuilder builder = new GroupMessageBuilder().setVersion((short) EncodeConstants.OF13_VERSION_ID).setXid(message.readUnsignedInt()).setCommand(GroupModCommand.forValue(message.readUnsignedShort()));
    builder.setGroupType(GroupTypes.forValue(message.readUnsignedByte()));
    message.skipBytes(PADDING);
    builder.setGroupId(new GroupId(message.readUnsignedInt()));
    final List<Bucket> buckets = new ArrayList<>();
    while (message.readableBytes() > 0) {
        final int length = message.readUnsignedShort();
        final BucketBuilder bucket = new BucketBuilder().setWeight(message.readUnsignedShort()).setWatchPort(message.readUnsignedInt()).setWatchGroup(message.readUnsignedInt());
        message.skipBytes(PADDING_IN_BUCKETS_HEADER);
        if (message.readableBytes() > 0) {
            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 = length - 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++;
            }
            bucket.setAction(actions);
        }
        buckets.add(bucket.build());
    }
    buckets.sort(COMPARATOR);
    return builder.setBuckets(new BucketsBuilder().setBucket(buckets).build()).build();
}
Also used : ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder) ArrayList(java.util.ArrayList) ActionKey(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey) BucketsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId) BucketBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketBuilder) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) GroupMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupMessageBuilder)

Example 43 with GroupId

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

the class GroupDirectStatisticsServiceTest method testBuildRequestBody.

@Override
public void testBuildRequestBody() throws Exception {
    final GetGroupStatisticsInput input = mock(GetGroupStatisticsInput.class);
    when(input.getNode()).thenReturn(createNodeRef(NODE_ID));
    when(input.getGroupId()).thenReturn(new GroupId(GROUP_NO));
    final MultipartRequestGroupCase body = (MultipartRequestGroupCase) ((MultipartRequestInput) service.buildRequest(new Xid(42L), input)).getMultipartRequestBody();
    final MultipartRequestGroup group = body.getMultipartRequestGroup();
    assertEquals(GROUP_NO, group.getGroupId().getValue());
}
Also used : MultipartRequestGroupCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupCase) Xid(org.opendaylight.openflowplugin.api.openflow.device.Xid) MultipartRequestGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group._case.MultipartRequestGroup) GetGroupStatisticsInput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetGroupStatisticsInput) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId)

Example 44 with GroupId

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

the class DeviceGroupRegistryImplTest method setUp.

@Before
public void setUp() throws Exception {
    deviceGroupRegistry = new DeviceGroupRegistryImpl();
    groupId = new GroupId(42L);
    groupId2 = new GroupId(84L);
    Assert.assertEquals(0, deviceGroupRegistry.getAllGroupIds().size());
    deviceGroupRegistry.store(groupId);
    Assert.assertEquals(1, deviceGroupRegistry.getAllGroupIds().size());
}
Also used : GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId) Before(org.junit.Before)

Example 45 with GroupId

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

the class MultipartReplyMessageFactoryTest method testMultipartReplyGroupBody.

/**
 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
 */
@Test
public void testMultipartReplyGroupBody() {
    ByteBuf bb = BufferHelper.buildBuffer("00 06 00 01 00 00 00 00 " + // length
    "00 48 " + // pad1
    "00 00 " + // groupId
    "00 00 00 10 " + // refCount
    "00 00 00 12 " + // pad2
    "00 00 00 00 " + // packetCount
    "FF 01 01 01 01 01 01 01 " + // byteCount
    "FF 01 01 01 01 01 01 01 " + // durationSec
    "00 00 00 08 " + // durationNsec
    "00 00 00 09 " + // packetCountBucket
    "FF 01 01 01 01 01 01 01 " + // byteCountBucket
    "FF 01 01 01 01 01 01 01 " + // packetCountBucket_2
    "FF 02 02 02 02 02 02 02 " + // byteCountBucket_2
    "FF 02 02 02 02 02 02 02 " + // length_2
    "00 48 " + // pad1.2
    "00 00 " + // groupId_2
    "00 00 00 10 " + // refCount_2
    "00 00 00 12 " + // pad2.2
    "00 00 00 00 " + // packetCount_2
    "FF 01 01 01 01 01 01 01 " + // byteCount_2
    "FF 01 01 01 01 01 01 01 " + // durationSec_2
    "00 00 00 08 " + // durationNsec_2
    "00 00 00 09 " + // packetCountBucket_1.2
    "FF 01 01 01 01 01 01 01 " + // byteCountBucket_1.2
    "FF 01 01 01 01 01 01 01 " + // packetCountBucket_2.2
    "FF 02 02 02 02 02 02 02 " + // byteCountBucket_2.2
    "FF 02 02 02 02 02 02 02");
    MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 0x06, builtByFactory.getType().getIntValue());
    Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
    MultipartReplyGroupCase messageCase = (MultipartReplyGroupCase) builtByFactory.getMultipartReplyBody();
    MultipartReplyGroup message = messageCase.getMultipartReplyGroup();
    Assert.assertEquals("Wrong groupId", 16, message.getGroupStats().get(0).getGroupId().getValue().intValue());
    Assert.assertEquals("Wrong refCount", 18, message.getGroupStats().get(0).getRefCount().intValue());
    Assert.assertEquals("Wrong packetCount", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getGroupStats().get(0).getPacketCount());
    Assert.assertEquals("Wrong byteCount", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getGroupStats().get(0).getByteCount());
    Assert.assertEquals("Wrong durationSec", 8, message.getGroupStats().get(0).getDurationSec().intValue());
    Assert.assertEquals("Wrong durationNsec", 9, message.getGroupStats().get(0).getDurationNsec().intValue());
    Assert.assertEquals("Wrong packetCountBucket", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getGroupStats().get(0).getBucketStats().get(0).getPacketCount());
    Assert.assertEquals("Wrong byteCountBucket", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getGroupStats().get(0).getBucketStats().get(0).getByteCount());
    Assert.assertEquals("Wrong packetCountBucket_2", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02 }), message.getGroupStats().get(0).getBucketStats().get(1).getPacketCount());
    Assert.assertEquals("Wrong byteCountBucket_2", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02 }), message.getGroupStats().get(0).getBucketStats().get(1).getByteCount());
    Assert.assertEquals("Wrong groupId_2", 16, message.getGroupStats().get(1).getGroupId().getValue().intValue());
    Assert.assertEquals("Wrong refCount_2", 18, message.getGroupStats().get(1).getRefCount().intValue());
    Assert.assertEquals("Wrong packetCount_2", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getGroupStats().get(1).getPacketCount());
    Assert.assertEquals("Wrong byteCount_2", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getGroupStats().get(1).getByteCount());
    Assert.assertEquals("Wrong durationSec_2", 8, message.getGroupStats().get(1).getDurationSec().intValue());
    Assert.assertEquals("Wrong durationNsec_2", 9, message.getGroupStats().get(1).getDurationNsec().intValue());
    Assert.assertEquals("Wrong packetCountBucket_1.2", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getGroupStats().get(1).getBucketStats().get(0).getPacketCount());
    Assert.assertEquals("Wrong byteCountBucket_1.2", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getGroupStats().get(1).getBucketStats().get(0).getByteCount());
    Assert.assertEquals("Wrong packetCountBucket_2.2", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02 }), message.getGroupStats().get(1).getBucketStats().get(1).getPacketCount());
    Assert.assertEquals("Wrong byteCountBucket_2.2", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02 }), message.getGroupStats().get(1).getBucketStats().get(1).getByteCount());
}
Also used : MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) MultipartReplyGroupCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupCase) MultipartReplyGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.MultipartReplyGroup) BigInteger(java.math.BigInteger) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

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