use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats 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);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats 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);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats 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();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats 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;
}
Aggregations