Search in sources :

Example 6 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 testGroupStatsWithBuckets.

/**
 * Test GroupStats with buckets conversion.
 */
@Test
public void testGroupStatsWithBuckets() {
    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);
    List<BucketStats> bucketStats = new ArrayList<>();
    BucketStatsBuilder bucketStatsBuilder = new BucketStatsBuilder();
    bucketStatsBuilder.setByteCount(new BigInteger("987"));
    bucketStatsBuilder.setPacketCount(new BigInteger("654"));
    bucketStats.add(bucketStatsBuilder.build());
    bucketStatsBuilder = new BucketStatsBuilder();
    bucketStatsBuilder.setByteCount(new BigInteger("123"));
    bucketStatsBuilder.setPacketCount(new BigInteger("456"));
    bucketStats.add(bucketStatsBuilder.build());
    statsBuilder.setBucketStats(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", 2, stat.getBuckets().getBucketCounter().size());
    List<BucketCounter> list = stat.getBuckets().getBucketCounter();
    Assert.assertEquals("Wrong bucket-id", 0, list.get(0).getBucketId().getValue().intValue());
    Assert.assertEquals("Wrong bucket packet count", 654, list.get(0).getPacketCount().getValue().intValue());
    Assert.assertEquals("Wrong bucket byte count", 987, list.get(0).getByteCount().getValue().intValue());
    Assert.assertEquals("Wrong bucket-id", 1, list.get(1).getBucketId().getValue().intValue());
    Assert.assertEquals("Wrong bucket packet count", 456, list.get(1).getPacketCount().getValue().intValue());
    Assert.assertEquals("Wrong bucket byte count", 123, list.get(1).getByteCount().getValue().intValue());
}
Also used : 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) 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) BucketCounter(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.buckets.BucketCounter) 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) Test(org.junit.Test)

Example 7 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 MultipartReplyMessageFactoryTest method createGroupStats.

private static List<GroupStats> createGroupStats() {
    GroupStatsBuilder builder = new GroupStatsBuilder();
    builder.setGroupId(new GroupId(1L));
    builder.setRefCount(1L);
    builder.setPacketCount(BigInteger.valueOf(1L));
    builder.setByteCount(BigInteger.valueOf(1L));
    builder.setDurationSec(1L);
    builder.setDurationNsec(1L);
    builder.setBucketStats(createBucketStats());
    List<GroupStats> list = new ArrayList<>();
    list.add(builder.build());
    return list;
}
Also used : ArrayList(java.util.ArrayList) GroupStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStats) 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)

Example 8 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 GroupDirectStatisticsServiceTest method testBuildReply.

@Override
public void testBuildReply() throws Exception {
    final MultipartReply reply = mock(MultipartReply.class);
    final MultipartReplyGroupCase groupCase = mock(MultipartReplyGroupCase.class);
    final MultipartReplyGroup group = mock(MultipartReplyGroup.class);
    final GroupStats groupStat = new GroupStatsBuilder().setGroupId(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId(GROUP_NO)).setByteCount(BigInteger.ONE).setPacketCount(BigInteger.ONE).setBucketStats(Collections.emptyList()).setDurationSec(1L).setDurationNsec(1L).setRefCount(0L).build();
    final List<GroupStats> groupStats = Collections.singletonList(groupStat);
    final List<MultipartReply> input = Collections.singletonList(reply);
    when(group.getGroupStats()).thenReturn(groupStats);
    when(groupCase.getMultipartReplyGroup()).thenReturn(group);
    when(reply.getMultipartReplyBody()).thenReturn(groupCase);
    final GetGroupStatisticsOutput output = service.buildReply(input, true);
    assertTrue(output.getGroupStats().size() > 0);
    final org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats stats = output.getGroupStats().get(0);
    assertEquals(stats.getGroupId().getValue(), GROUP_NO);
}
Also used : MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) 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.group.types.rev131018.GroupId) GetGroupStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetGroupStatisticsOutput) 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) GroupStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStats)

Example 9 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 MultipartReplyTranslatorTest method prepareMultipartReplyGroup.

private MultipartReplyBody prepareMultipartReplyGroup() {
    GroupStatsBuilder groupStatsBuilder = new GroupStatsBuilder();
    groupStatsBuilder.setByteCount(DUMMY_BYTE_COUNT);
    groupStatsBuilder.setBucketStats(Collections.<BucketStats>emptyList());
    groupStatsBuilder.setDurationSec(DUMMY_DURATION_SEC);
    groupStatsBuilder.setDurationNsec(DUMMY_DURATION_NSEC);
    groupStatsBuilder.setGroupId(DUMMY_GROUP_ID);
    groupStatsBuilder.setPacketCount(DUMMY_PACKET_COUNT);
    groupStatsBuilder.setRefCount(DUMMY_REF_COUNT);
    MultipartReplyGroupBuilder multipartReplyGroupBuilder = new MultipartReplyGroupBuilder();
    multipartReplyGroupBuilder.setGroupStats(Lists.newArrayList(groupStatsBuilder.build()));
    MultipartReplyGroupCaseBuilder multipartReplyGroupCaseBuilder = new MultipartReplyGroupCaseBuilder();
    multipartReplyGroupCaseBuilder.setMultipartReplyGroup(multipartReplyGroupBuilder.build());
    return multipartReplyGroupCaseBuilder.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) GroupStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStatsBuilder)

Example 10 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 GroupDirectStatisticsServiceTest method testBuildReply.

@Override
public void testBuildReply() throws Exception {
    final GroupStats groupStat = new GroupStatsBuilder().setGroupId(new GroupId(GROUP_NO)).build();
    final MultipartReply reply = new MultipartReplyBuilder().setMultipartReplyBody(new MultipartReplyGroupStatsBuilder().setGroupStats(Collections.singletonList(groupStat)).build()).build();
    final List<MultipartReply> input = Collections.singletonList(reply);
    final GetGroupStatisticsOutput output = service.buildReply(input, true);
    assertTrue(output.getGroupStats().size() > 0);
    final org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats stats = output.getGroupStats().get(0);
    assertEquals(stats.getGroupId().getValue(), GROUP_NO);
}
Also used : MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReply) 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) GroupStats(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats) 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) GetGroupStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetGroupStatisticsOutput) MultipartRequestGroupStats(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.request.multipart.request.body.MultipartRequestGroupStats) GroupStats(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats) MultipartReplyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReplyBuilder)

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