use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.MultipartReplyGroup 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);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.MultipartReplyGroup 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