use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStatsBuilder in project openflowplugin by opendaylight.
the class MultipartReplyGroupDescDeserializer method deserialize.
@Override
public MultipartReplyBody deserialize(ByteBuf message) {
final MultipartReplyGroupDescBuilder builder = new MultipartReplyGroupDescBuilder();
final List<GroupDescStats> items = new ArrayList<>();
while (message.readableBytes() > 0) {
final int itemLength = message.readUnsignedShort();
final GroupDescStatsBuilder itemBuilder = new GroupDescStatsBuilder().setGroupType(GroupTypes.forValue(message.readUnsignedByte()));
message.skipBytes(PADDING_IN_GROUP_DESC_HEADER);
itemBuilder.setGroupId(new GroupId(message.readUnsignedInt()));
itemBuilder.setKey(new GroupDescStatsKey(itemBuilder.getGroupId()));
final List<Bucket> subItems = new ArrayList<>();
int actualLength = GROUP_DESC_HEADER_LENGTH;
long bucketKey = 0;
while (actualLength < itemLength) {
final int bucketsLength = message.readUnsignedShort();
final BucketBuilder bucketBuilder = new BucketBuilder().setBucketId(new BucketId(bucketKey)).setKey(new BucketKey(new BucketId(bucketKey))).setWeight(message.readUnsignedShort()).setWatchPort(message.readUnsignedInt()).setWatchGroup(message.readUnsignedInt());
message.skipBytes(PADDING_IN_BUCKETS_HEADER);
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actions = new ArrayList<>();
final int startIndex = message.readerIndex();
final int bucketLength = bucketsLength - BUCKETS_HEADER_LENGTH;
int offset = 0;
while (message.readerIndex() - startIndex < bucketLength) {
actions.add(new ActionBuilder().setKey(new ActionKey(offset)).setOrder(offset).setAction(ActionUtil.readAction(EncodeConstants.OF13_VERSION_ID, message, registry, ActionPath.GROUP_DESC_STATS_UPDATED_BUCKET_ACTION)).build());
offset++;
}
bucketBuilder.setAction(actions);
subItems.add(bucketBuilder.build());
bucketKey++;
actualLength += bucketsLength;
}
items.add(itemBuilder.setBuckets(new BucketsBuilder().setBucket(subItems).build()).build());
}
return builder.setGroupDescStats(items).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStatsBuilder in project openflowplugin by opendaylight.
the class GroupDescStatsResponseConvertor method convert.
@Override
public List<GroupDescStats> convert(List<GroupDesc> source, VersionConvertorData data) {
List<GroupDescStats> convertedSALGroupsDesc = new ArrayList<>();
for (GroupDesc groupDesc : source) {
GroupDescStatsBuilder salGroupDescStats = new GroupDescStatsBuilder();
salGroupDescStats.setBuckets(toSALBucketsDesc(groupDesc.getBucketsList(), data.getVersion()));
salGroupDescStats.setGroupId(new GroupId(groupDesc.getGroupId().getValue()));
salGroupDescStats.setGroupType(GroupTypes.forValue(groupDesc.getType().getIntValue()));
salGroupDescStats.setKey(new GroupDescStatsKey(salGroupDescStats.getGroupId()));
convertedSALGroupsDesc.add(salGroupDescStats.build());
}
return convertedSALGroupsDesc;
}
Aggregations