use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStats in project openflowplugin by opendaylight.
the class GroupDescriptionService method transformToNotification.
@Override
public GroupDescStatsUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
GroupDescStatsUpdatedBuilder notification = new GroupDescStatsUpdatedBuilder();
notification.setId(getDeviceInfo().getNodeId());
notification.setMoreReplies(Boolean.FALSE);
notification.setTransactionId(emulatedTxId);
notification.setGroupDescStats(new ArrayList<>());
final VersionConvertorData data = new VersionConvertorData(getVersion());
for (MultipartReply mpReply : result) {
MultipartReplyGroupDescCase caseBody = (MultipartReplyGroupDescCase) mpReply.getMultipartReplyBody();
MultipartReplyGroupDesc replyBody = caseBody.getMultipartReplyGroupDesc();
final Optional<List<GroupDescStats>> groupDescStatsList = convertorExecutor.convert(replyBody.getGroupDesc(), data);
groupDescStatsList.ifPresent(groupDescStats -> notification.getGroupDescStats().addAll(groupDescStats));
}
return notification.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStats in project openflowplugin by opendaylight.
the class MultipartReplyTranslatorTest method testTranslateGroupDesc.
@Test
public void testTranslateGroupDesc() {
DeviceContext mockedDeviceContext = mock(DeviceContext.class);
MultipartReplyMessage multipartReplyMessage = prepareMocks(mockedDeviceContext, prepareMultipartReplyGroupDesc(), MultipartType.OFPMPGROUPDESC);
DataContainer result = MultipartReplyTranslatorUtil.translate(multipartReplyMessage, mockedDeviceContext.getDeviceInfo(), CONVERTOR_MANAGER, mockedDeviceContext.oook()).get();
DataContainer dataObject = validateOutput(result);
assertTrue(dataObject instanceof GroupDescStatsReply);
GroupDescStatsReply groupStatistics = (GroupDescStatsReply) dataObject;
List<GroupDescStats> groupDescStats = groupStatistics.getGroupDescStats();
assertEquals(1, groupDescStats.size());
GroupDescStats groupDescStat = groupDescStats.get(0);
assertEquals(DUMMY_GROUP_ID.getValue(), groupDescStat.getGroupId().getValue());
assertEquals(DUMMY_GROUPS_TYPE, groupDescStat.getGroupType());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStats in project openflowplugin by opendaylight.
the class OpenflowpluginStatsTestCommandProvider method _groupDescStats.
public void _groupDescStats(CommandInterpreter ci) {
int groupCount = 0;
int groupDescStatsCount = 0;
NodeGroupDescStats data = null;
List<Node> nodes = getNodes();
for (Node node2 : nodes) {
NodeKey nodeKey = node2.getKey();
InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class);
ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction();
FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef);
if (node != null) {
if (node.getGroup() != null) {
List<Group> groups = node.getGroup();
for (Group group2 : groups) {
groupCount++;
GroupKey groupKey = group2.getKey();
InstanceIdentifier<Group> groupRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Group.class, groupKey);
Group group = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, groupRef);
if (group != null) {
data = group.getAugmentation(NodeGroupDescStats.class);
if (null != data) {
groupDescStatsCount++;
}
}
}
}
}
if (groupCount == groupDescStatsCount) {
LOG.debug("---------------------groupDescStats - Success-------------------------------");
} else {
LOG.debug("------------------------------groupDescStats - Failed--------------------------");
LOG.debug("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStats 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