Search in sources :

Example 1 with GroupStatisticsUpdated

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdated in project openflowplugin by opendaylight.

the class GroupStatNotificationSupplierImpl method createNotification.

@Override
public GroupStatisticsUpdated createNotification(final GroupStatistics groupStatistics, final InstanceIdentifier<GroupStatistics> path) {
    Preconditions.checkArgument(groupStatistics != null);
    Preconditions.checkArgument(path != null);
    final GroupStatisticsUpdatedBuilder builder = new GroupStatisticsUpdatedBuilder();
    builder.setId(getNodeId(path));
    builder.setMoreReplies(Boolean.FALSE);
    // TODO : fix if it needs, but we have to ask DataStore for the NodeConnector list
    builder.setNodeConnector(Collections.<NodeConnector>emptyList());
    builder.setGroupStats(Collections.singletonList(new GroupStatsBuilder(groupStatistics).build()));
    return builder.build();
}
Also used : GroupStatisticsUpdatedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdatedBuilder) GroupStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStatsBuilder)

Example 2 with GroupStatisticsUpdated

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdated in project openflowplugin by opendaylight.

the class GroupStatisticsToNotificationTransformer method transformToNotification.

/**
 * Transform statistics to notification.
 * @param mpReplyList   raw multipart response from device
 * @param deviceInfo   device state
 * @param emulatedTxId emulated transaction id
 * @param convertorExecutor convertor executor
 * @return notification containing flow stats
 */
public static GroupStatisticsUpdated transformToNotification(final List<MultipartReply> mpReplyList, final DeviceInfo deviceInfo, final TransactionId emulatedTxId, final ConvertorExecutor convertorExecutor) {
    VersionConvertorData data = new VersionConvertorData(deviceInfo.getVersion());
    GroupStatisticsUpdatedBuilder notification = new GroupStatisticsUpdatedBuilder();
    notification.setId(deviceInfo.getNodeId());
    notification.setMoreReplies(Boolean.FALSE);
    notification.setTransactionId(emulatedTxId);
    notification.setGroupStats(new ArrayList<>());
    for (MultipartReply mpReply : mpReplyList) {
        MultipartReplyGroupCase caseBody = (MultipartReplyGroupCase) mpReply.getMultipartReplyBody();
        MultipartReplyGroup replyBody = caseBody.getMultipartReplyGroup();
        final Optional<List<GroupStats>> groupStatsList = convertorExecutor.convert(replyBody.getGroupStats(), data);
        groupStatsList.ifPresent(groupStats -> notification.getGroupStats().addAll(groupStats));
    }
    return notification.build();
}
Also used : VersionConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData) MultipartReplyGroupCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupCase) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) GroupStatisticsUpdatedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdatedBuilder) MultipartReplyGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.MultipartReplyGroup) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with GroupStatisticsUpdated

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdated in project openflowplugin by opendaylight.

the class GroupStatNotificationSupplierImplTest method testCreate.

@Test
public void testCreate() {
    final GroupStatisticsUpdated notification = notifSupplierImpl.createNotification(createTestGroupStat(), createTestGroupStatPath());
    assertNotNull(notification);
    assertEquals(FLOW_NODE_ID, notification.getId().getValue());
}
Also used : GroupStatisticsUpdated(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdated) Test(org.junit.Test)

Aggregations

GroupStatisticsUpdatedBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdatedBuilder)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Test (org.junit.Test)1 VersionConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData)1 GroupStatisticsUpdated (org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdated)1 GroupStatsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStatsBuilder)1 MultipartReply (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply)1 MultipartReplyGroupCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupCase)1 MultipartReplyGroup (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.MultipartReplyGroup)1