Search in sources :

Example 1 with GroupStatsBuilder

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

the class GroupStatsResponseConvertorTest method testSingleGroupStat.

/**
 * Test single GroupStat conversion.
 */
@Test
public void testSingleGroupStat() {
    GroupStatsBuilder statsBuilder = new GroupStatsBuilder();
    statsBuilder.setByteCount(new BigInteger("12345"));
    statsBuilder.setDurationNsec(1000000L);
    statsBuilder.setDurationSec(5000L);
    statsBuilder.setGroupId(new GroupId(42L));
    statsBuilder.setPacketCount(new BigInteger("54321"));
    statsBuilder.setRefCount(24L);
    statsBuilder.setBucketStats(new ArrayList<BucketStats>());
    List<GroupStats> groupStats = new ArrayList<>();
    groupStats.add(statsBuilder.build());
    Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats>> salGroupStatsOptional = convertorManager.convert(groupStats, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
    Assert.assertTrue("Group stats response convertor not found", salGroupStatsOptional.isPresent());
    List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats> salGroupStats = salGroupStatsOptional.get();
    Assert.assertEquals("Wrong group stats size", 1, salGroupStats.size());
    org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats stat = salGroupStats.get(0);
    Assert.assertEquals("Wrong group-id", 42, stat.getGroupId().getValue().intValue());
    Assert.assertEquals("Wrong ref-count", 24, stat.getRefCount().getValue().intValue());
    Assert.assertEquals("Wrong packet count", 54321, stat.getPacketCount().getValue().intValue());
    Assert.assertEquals("Wrong byte count", 12345, stat.getByteCount().getValue().intValue());
    Assert.assertEquals("Wrong duration sec", 5000, stat.getDuration().getSecond().getValue().intValue());
    Assert.assertEquals("Wrong duration n sec", 1000000, stat.getDuration().getNanosecond().getValue().intValue());
    Assert.assertEquals("Wrong bucket stats", 0, stat.getBuckets().getBucketCounter().size());
}
Also used : ArrayList(java.util.ArrayList) GroupStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStatsBuilder) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId) VersionConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData) BigInteger(java.math.BigInteger) GroupStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStats) ArrayList(java.util.ArrayList) List(java.util.List) BucketStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.group.stats.BucketStats) Test(org.junit.Test)

Example 2 with GroupStatsBuilder

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

the class GroupStatNotificationSupplierImpl method createNotification.

@Override
public GroupStatisticsUpdated createNotification(final GroupStatistics groupStatistics, final InstanceIdentifier<GroupStatistics> path) {
    Preconditions.checkArgument(groupStatistics != null);
    Preconditions.checkArgument(path != null);
    final GroupStatisticsUpdatedBuilder builder = new GroupStatisticsUpdatedBuilder();
    builder.setId(getNodeId(path));
    builder.setMoreReplies(Boolean.FALSE);
    // TODO : fix if it needs, but we have to ask DataStore for the NodeConnector list
    builder.setNodeConnector(Collections.<NodeConnector>emptyList());
    builder.setGroupStats(Collections.singletonList(new GroupStatsBuilder(groupStatistics).build()));
    return builder.build();
}
Also used : GroupStatisticsUpdatedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdatedBuilder) GroupStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStatsBuilder)

Example 3 with GroupStatsBuilder

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

the class StatisticsGatheringUtilsTest method testGatherStatistics_group.

@Test
public void testGatherStatistics_group() throws Exception {
    final MultipartType type = MultipartType.OFPMPGROUP;
    final long groupIdValue = 19L;
    final GroupStatsBuilder groupStatsBld = new GroupStatsBuilder().setBucketStats(Lists.newArrayList(createBucketStat(21L, 42L))).setByteCount(BigInteger.valueOf(84L)).setPacketCount(BigInteger.valueOf(63L)).setDurationSec(11L).setDurationNsec(12L).setRefCount(13L).setGroupId(new GroupId(groupIdValue));
    final MultipartReplyGroupBuilder mpReplyGroupBld = new MultipartReplyGroupBuilder();
    mpReplyGroupBld.setGroupStats(Lists.newArrayList(groupStatsBld.build()));
    final MultipartReplyGroupCaseBuilder mpReplyGroupCaseBld = new MultipartReplyGroupCaseBuilder();
    mpReplyGroupCaseBld.setMultipartReplyGroup(mpReplyGroupBld.build());
    final MultipartReply groupStatsUpdated = assembleMPReplyMessage(type, mpReplyGroupCaseBld.build());
    final List<MultipartReply> statsData = Collections.singletonList(groupStatsUpdated);
    fireAndCheck(type, statsData);
    final InstanceIdentifier<GroupStatistics> groupPath = dummyNodePath.augmentation(FlowCapableNode.class).child(Group.class, new GroupKey(new org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId(groupIdValue))).augmentation(NodeGroupStatistics.class).child(GroupStatistics.class);
    verify(deviceContext).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.eq(groupPath), Matchers.any(GroupStatistics.class));
}
Also used : MultipartReplyGroupCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupCaseBuilder) MultipartType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) MultipartReplyGroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.MultipartReplyGroupBuilder) GroupKey(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey) GroupStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStatsBuilder) NodeGroupStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupStatistics) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId) NodeGroupStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupStatistics) GroupStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.statistics.GroupStatistics) Test(org.junit.Test)

Example 4 with GroupStatsBuilder

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

the class MultipartReplyMessageFactory method setGroup.

private static MultipartReplyGroupCase setGroup(final ByteBuf input) {
    MultipartReplyGroupCaseBuilder caseBuilder = new MultipartReplyGroupCaseBuilder();
    MultipartReplyGroupBuilder builder = new MultipartReplyGroupBuilder();
    List<GroupStats> groupStatsList = new ArrayList<>();
    while (input.readableBytes() > 0) {
        GroupStatsBuilder groupStatsBuilder = new GroupStatsBuilder();
        final int bodyLength = input.readUnsignedShort();
        input.skipBytes(PADDING_IN_GROUP_HEADER_01);
        groupStatsBuilder.setGroupId(new GroupId(input.readUnsignedInt()));
        groupStatsBuilder.setRefCount(input.readUnsignedInt());
        input.skipBytes(PADDING_IN_GROUP_HEADER_02);
        byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        input.readBytes(packetCount);
        groupStatsBuilder.setPacketCount(new BigInteger(1, packetCount));
        byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        input.readBytes(byteCount);
        groupStatsBuilder.setByteCount(new BigInteger(1, byteCount));
        groupStatsBuilder.setDurationSec(input.readUnsignedInt());
        groupStatsBuilder.setDurationNsec(input.readUnsignedInt());
        int actualLength = GROUP_BODY_LENGTH;
        List<BucketStats> bucketStatsList = new ArrayList<>();
        while (actualLength < bodyLength) {
            BucketStatsBuilder bucketStatsBuilder = new BucketStatsBuilder();
            byte[] packetCountBucket = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
            input.readBytes(packetCountBucket);
            bucketStatsBuilder.setPacketCount(new BigInteger(1, packetCountBucket));
            byte[] byteCountBucket = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
            input.readBytes(byteCountBucket);
            bucketStatsBuilder.setByteCount(new BigInteger(1, byteCountBucket));
            bucketStatsList.add(bucketStatsBuilder.build());
            actualLength += BUCKET_COUNTER_LENGTH;
        }
        groupStatsBuilder.setBucketStats(bucketStatsList);
        groupStatsList.add(groupStatsBuilder.build());
    }
    builder.setGroupStats(groupStatsList);
    caseBuilder.setMultipartReplyGroup(builder.build());
    return caseBuilder.build();
}
Also used : MultipartReplyGroupCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupCaseBuilder) MultipartReplyGroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.MultipartReplyGroupBuilder) ArrayList(java.util.ArrayList) BucketStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.group.stats.BucketStatsBuilder) GroupStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStatsBuilder) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId) GroupStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStats) BigInteger(java.math.BigInteger) BucketStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.group.stats.BucketStats)

Example 5 with GroupStatsBuilder

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

the class GroupStatsResponseConvertorTest method testTwoGroupStats.

/**
 * Test two GroupStats conversion.
 */
@Test
public void testTwoGroupStats() {
    GroupStatsBuilder statsBuilder = new GroupStatsBuilder();
    statsBuilder.setByteCount(new BigInteger("12345"));
    statsBuilder.setDurationNsec(1000000L);
    statsBuilder.setDurationSec(5000L);
    statsBuilder.setGroupId(new GroupId(42L));
    statsBuilder.setPacketCount(new BigInteger("54321"));
    statsBuilder.setRefCount(24L);
    statsBuilder.setBucketStats(new ArrayList<BucketStats>());
    List<GroupStats> groupStats = new ArrayList<>();
    groupStats.add(statsBuilder.build());
    statsBuilder = new GroupStatsBuilder();
    statsBuilder.setByteCount(new BigInteger("1"));
    statsBuilder.setDurationNsec(2L);
    statsBuilder.setDurationSec(3L);
    statsBuilder.setGroupId(new GroupId(4L));
    statsBuilder.setPacketCount(new BigInteger("5"));
    statsBuilder.setRefCount(6L);
    statsBuilder.setBucketStats(new ArrayList<BucketStats>());
    groupStats.add(statsBuilder.build());
    Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats>> salGroupStatsOptional = convertorManager.convert(groupStats, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
    Assert.assertTrue("Group stats response convertor not found", salGroupStatsOptional.isPresent());
    List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats> salGroupStats = salGroupStatsOptional.get();
    Assert.assertEquals("Wrong group stats size", 2, salGroupStats.size());
    org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats stat = salGroupStats.get(0);
    Assert.assertEquals("Wrong group-id", 42, stat.getGroupId().getValue().intValue());
    Assert.assertEquals("Wrong key", 42, stat.getKey().getGroupId().getValue().intValue());
    Assert.assertEquals("Wrong ref-count", 24, stat.getRefCount().getValue().intValue());
    Assert.assertEquals("Wrong packet count", 54321, stat.getPacketCount().getValue().intValue());
    Assert.assertEquals("Wrong byte count", 12345, stat.getByteCount().getValue().intValue());
    Assert.assertEquals("Wrong duration sec", 5000, stat.getDuration().getSecond().getValue().intValue());
    Assert.assertEquals("Wrong duration n sec", 1000000, stat.getDuration().getNanosecond().getValue().intValue());
    Assert.assertEquals("Wrong bucket stats", 0, stat.getBuckets().getBucketCounter().size());
    stat = salGroupStats.get(1);
    Assert.assertEquals("Wrong group-id", 4, stat.getGroupId().getValue().intValue());
    Assert.assertEquals("Wrong key", 4, stat.getKey().getGroupId().getValue().intValue());
    Assert.assertEquals("Wrong ref-count", 6, stat.getRefCount().getValue().intValue());
    Assert.assertEquals("Wrong packet count", 5, stat.getPacketCount().getValue().intValue());
    Assert.assertEquals("Wrong byte count", 1, stat.getByteCount().getValue().intValue());
    Assert.assertEquals("Wrong duration sec", 3, stat.getDuration().getSecond().getValue().intValue());
    Assert.assertEquals("Wrong duration n sec", 2, stat.getDuration().getNanosecond().getValue().intValue());
    Assert.assertEquals("Wrong bucket stats", 0, stat.getBuckets().getBucketCounter().size());
}
Also used : ArrayList(java.util.ArrayList) GroupStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStatsBuilder) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId) VersionConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData) BigInteger(java.math.BigInteger) GroupStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStats) ArrayList(java.util.ArrayList) List(java.util.List) BucketStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.group.stats.BucketStats) Test(org.junit.Test)

Aggregations

GroupStatsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStatsBuilder)8 ArrayList (java.util.ArrayList)7 GroupId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId)6 GroupStats (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStats)6 BigInteger (java.math.BigInteger)5 Test (org.junit.Test)4 GroupId (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId)4 GroupStatsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStatsBuilder)4 BucketStats (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.group.stats.BucketStats)4 List (java.util.List)3 VersionConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData)3 GroupStats (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats)3 MultipartReplyGroupCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupCaseBuilder)3 MultipartReplyGroupBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.MultipartReplyGroupBuilder)3 Counter32 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32)2 Counter64 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64)2 GetGroupStatisticsOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetGroupStatisticsOutput)2 MultipartReplyGroupStatsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyGroupStatsBuilder)2 DurationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.DurationBuilder)2 BucketCounter (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.buckets.BucketCounter)2