Search in sources :

Example 1 with MeterStatisticsUpdated

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterStatisticsUpdated in project openflowplugin by opendaylight.

the class MeterStatNotificationSupplierImpl method createNotification.

@Override
public MeterStatisticsUpdated createNotification(final MeterStatistics meterStatistics, final InstanceIdentifier<MeterStatistics> path) {
    Preconditions.checkArgument(meterStatistics != null);
    Preconditions.checkArgument(path != null);
    final MeterStatisticsUpdatedBuilder builder = new MeterStatisticsUpdatedBuilder();
    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.setMeterStats(Collections.singletonList(new MeterStatsBuilder(meterStatistics).build()));
    return builder.build();
}
Also used : MeterStatisticsUpdatedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterStatisticsUpdatedBuilder) MeterStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsBuilder)

Example 2 with MeterStatisticsUpdated

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterStatisticsUpdated in project openflowplugin by opendaylight.

the class MeterStatisticsToNotificationTransformer method transformToNotification.

/**
 * Transform statistics to notification.
 *
 * @param mpReplyList   raw multipart response from device
 * @param deviceInfo    device state
 * @param ofVersion     device version
 * @param emulatedTxId  emulated transaction Id
 * @param convertorExecutor convertor executor
 * @return notification containing flow stats
 */
public static MeterStatisticsUpdated transformToNotification(final List<MultipartReply> mpReplyList, final DeviceInfo deviceInfo, final OpenflowVersion ofVersion, final TransactionId emulatedTxId, final ConvertorExecutor convertorExecutor) {
    VersionConvertorData data = new VersionConvertorData(deviceInfo.getVersion());
    MeterStatisticsUpdatedBuilder notification = new MeterStatisticsUpdatedBuilder();
    notification.setId(deviceInfo.getNodeId());
    notification.setMoreReplies(Boolean.FALSE);
    notification.setTransactionId(emulatedTxId);
    notification.setMeterStats(new ArrayList<>());
    for (MultipartReply mpReply : mpReplyList) {
        MultipartReplyMeterCase caseBody = (MultipartReplyMeterCase) mpReply.getMultipartReplyBody();
        MultipartReplyMeter replyBody = caseBody.getMultipartReplyMeter();
        final Optional<List<MeterStats>> meterStatsList = convertorExecutor.convert(replyBody.getMeterStats(), data);
        meterStatsList.ifPresent(meterStats -> notification.getMeterStats().addAll(meterStats));
    }
    return notification.build();
}
Also used : VersionConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData) MultipartReplyMeter(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.MultipartReplyMeter) MeterStatisticsUpdatedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterStatisticsUpdatedBuilder) MultipartReplyMeterCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterCase) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with MeterStatisticsUpdated

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterStatisticsUpdated in project openflowplugin by opendaylight.

the class MeterStatNotificationSupplierImplTest method testCreate.

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

Aggregations

MeterStatisticsUpdatedBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterStatisticsUpdatedBuilder)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 MeterStatisticsUpdated (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterStatisticsUpdated)1 MeterStatsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsBuilder)1 MultipartReply (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply)1 MultipartReplyMeterCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterCase)1 MultipartReplyMeter (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.MultipartReplyMeter)1