use of 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 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());
}
use of 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 in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactoryTest method createBucketStats.
private static List<BucketStats> createBucketStats() {
BucketStatsBuilder builder = new BucketStatsBuilder();
builder.setPacketCount(BigInteger.valueOf(1L));
builder.setByteCount(BigInteger.valueOf(1L));
List<BucketStats> list = new ArrayList<>();
list.add(builder.build());
return list;
}
use of 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 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();
}
use of 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 in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactory method serializeGroupBody.
private void serializeGroupBody(final MultipartReplyBody body, final ByteBuf outBuffer) {
MultipartReplyGroupCase groupCase = (MultipartReplyGroupCase) body;
MultipartReplyGroup group = groupCase.getMultipartReplyGroup();
for (GroupStats groupStats : group.getGroupStats()) {
ByteBuf groupStatsBuff = UnpooledByteBufAllocator.DEFAULT.buffer();
groupStatsBuff.writeShort(EncodeConstants.EMPTY_LENGTH);
groupStatsBuff.writeZero(GROUP_STATS_PADDING_1);
groupStatsBuff.writeInt(groupStats.getGroupId().getValue().intValue());
groupStatsBuff.writeInt(groupStats.getRefCount().intValue());
groupStatsBuff.writeZero(GROUP_STATS_PADDING_2);
groupStatsBuff.writeLong(groupStats.getPacketCount().longValue());
groupStatsBuff.writeLong(groupStats.getByteCount().longValue());
groupStatsBuff.writeInt(groupStats.getDurationSec().intValue());
groupStatsBuff.writeInt(groupStats.getDurationNsec().intValue());
for (BucketStats bucketStats : groupStats.getBucketStats()) {
groupStatsBuff.writeLong(bucketStats.getPacketCount().longValue());
groupStatsBuff.writeLong(bucketStats.getByteCount().longValue());
}
groupStatsBuff.setShort(GROUP_STATS_LENGTH_INDEX, groupStatsBuff.readableBytes());
outBuffer.writeBytes(groupStatsBuff);
}
}
Aggregations