Search in sources :

Example 6 with Counter32

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32 in project openflowplugin by opendaylight.

the class QueueStatisticsToNotificationTransformer 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
 * @return notification containing flow stats
 */
public static QueueStatisticsUpdate transformToNotification(final List<MultipartReply> mpReplyList, final DeviceInfo deviceInfo, final OpenflowVersion ofVersion, final TransactionId emulatedTxId) {
    QueueStatisticsUpdateBuilder notification = new QueueStatisticsUpdateBuilder();
    notification.setId(deviceInfo.getNodeId());
    notification.setMoreReplies(Boolean.FALSE);
    notification.setTransactionId(emulatedTxId);
    notification.setQueueIdAndStatisticsMap(new ArrayList<>());
    for (MultipartReply mpReply : mpReplyList) {
        MultipartReplyQueueCase caseBody = (MultipartReplyQueueCase) mpReply.getMultipartReplyBody();
        MultipartReplyQueue replyBody = caseBody.getMultipartReplyQueue();
        for (QueueStats queueStats : replyBody.getQueueStats()) {
            QueueIdAndStatisticsMapBuilder statsBuilder = new QueueIdAndStatisticsMapBuilder();
            statsBuilder.setNodeConnectorId(InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(deviceInfo.getDatapathId(), queueStats.getPortNo(), ofVersion));
            statsBuilder.setTransmissionErrors(new Counter64(queueStats.getTxErrors()));
            statsBuilder.setTransmittedBytes(new Counter64(queueStats.getTxBytes()));
            statsBuilder.setTransmittedPackets(new Counter64(queueStats.getTxPackets()));
            DurationBuilder durationBuilder = new DurationBuilder();
            durationBuilder.setSecond(new Counter32(queueStats.getDurationSec()));
            durationBuilder.setNanosecond(new Counter32(queueStats.getDurationNsec()));
            statsBuilder.setDuration(durationBuilder.build());
            statsBuilder.setQueueId(new QueueId(queueStats.getQueueId()));
            notification.getQueueIdAndStatisticsMap().add(statsBuilder.build());
        }
    }
    return notification.build();
}
Also used : Counter32(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32) Counter64(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) QueueIdAndStatisticsMapBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMapBuilder) MultipartReplyQueueCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCase) QueueId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId) QueueStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.multipart.reply.queue.QueueStats) MultipartReplyQueue(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueue) QueueStatisticsUpdateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.QueueStatisticsUpdateBuilder) DurationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.duration.DurationBuilder)

Example 7 with Counter32

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32 in project openflowplugin by opendaylight.

the class MultipartReplyTranslatorUtil method translatePortStats.

private static org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.multipart.reply.multipart.reply.body.MultipartReplyPortStats translatePortStats(final MultipartReply msg, final OpenflowVersion ofVersion, final BigInteger datapathId) {
    MultipartReplyPortStatsBuilder message = new MultipartReplyPortStatsBuilder();
    MultipartReplyPortStatsCase caseBody = (MultipartReplyPortStatsCase) msg.getMultipartReplyBody();
    MultipartReplyPortStats replyBody = caseBody.getMultipartReplyPortStats();
    List<NodeConnectorStatisticsAndPortNumberMap> statsMap = new ArrayList<>();
    for (PortStats portStats : replyBody.getPortStats()) {
        NodeConnectorStatisticsAndPortNumberMapBuilder statsBuilder = new NodeConnectorStatisticsAndPortNumberMapBuilder();
        statsBuilder.setNodeConnectorId(InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(datapathId, portStats.getPortNo(), ofVersion));
        BytesBuilder bytesBuilder = new BytesBuilder();
        bytesBuilder.setReceived(portStats.getRxBytes());
        bytesBuilder.setTransmitted(portStats.getTxBytes());
        statsBuilder.setBytes(bytesBuilder.build());
        PacketsBuilder packetsBuilder = new PacketsBuilder();
        packetsBuilder.setReceived(portStats.getRxPackets());
        packetsBuilder.setTransmitted(portStats.getTxPackets());
        statsBuilder.setPackets(packetsBuilder.build());
        DurationBuilder durationBuilder = new DurationBuilder();
        if (portStats.getDurationSec() != null) {
            durationBuilder.setSecond(new Counter32(portStats.getDurationSec()));
        }
        if (portStats.getDurationNsec() != null) {
            durationBuilder.setNanosecond(new Counter32(portStats.getDurationNsec()));
        }
        statsBuilder.setDuration(durationBuilder.build());
        statsBuilder.setCollisionCount(portStats.getCollisions());
        statsBuilder.setKey(new NodeConnectorStatisticsAndPortNumberMapKey(statsBuilder.getNodeConnectorId()));
        statsBuilder.setReceiveCrcError(portStats.getRxCrcErr());
        statsBuilder.setReceiveDrops(portStats.getRxDropped());
        statsBuilder.setReceiveErrors(portStats.getRxErrors());
        statsBuilder.setReceiveFrameError(portStats.getRxFrameErr());
        statsBuilder.setReceiveOverRunError(portStats.getRxOverErr());
        statsBuilder.setTransmitDrops(portStats.getTxDropped());
        statsBuilder.setTransmitErrors(portStats.getTxErrors());
        statsMap.add(statsBuilder.build());
    }
    message.setNodeConnectorStatisticsAndPortNumberMap(statsMap);
    return message.build();
}
Also used : MultipartReplyPortStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats) ArrayList(java.util.ArrayList) PacketsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.node.connector.statistics.PacketsBuilder) Counter32(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32) NodeConnectorStatisticsAndPortNumberMapKey(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapKey) MultipartReplyPortStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.multipart.reply.multipart.reply.body.MultipartReplyPortStatsBuilder) NodeConnectorStatisticsAndPortNumberMapBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapBuilder) MultipartReplyPortStatsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCase) PortStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.multipart.reply.port.stats.PortStats) MultipartReplyPortStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats) NodeConnectorStatisticsAndPortNumberMap(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap) BytesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.node.connector.statistics.BytesBuilder) DurationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.duration.DurationBuilder)

Example 8 with Counter32

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32 in project openflowplugin by opendaylight.

the class MultipartReplyTranslatorUtil method translateTable.

private static MultipartReplyFlowTableStats translateTable(final MultipartReply msg) {
    MultipartReplyFlowTableStatsBuilder message = new MultipartReplyFlowTableStatsBuilder();
    MultipartReplyTableCase caseBody = (MultipartReplyTableCase) msg.getMultipartReplyBody();
    MultipartReplyTable replyBody = caseBody.getMultipartReplyTable();
    List<TableStats> swTablesStats = replyBody.getTableStats();
    List<FlowTableAndStatisticsMap> salFlowStats = new ArrayList<>();
    // TODO: Duplicate code: look at OpendaylightFlowTableStatisticsServiceImpl method transformToNotification
    for (TableStats swTableStats : swTablesStats) {
        FlowTableAndStatisticsMapBuilder statisticsBuilder = new FlowTableAndStatisticsMapBuilder();
        statisticsBuilder.setActiveFlows(new Counter32(swTableStats.getActiveCount()));
        statisticsBuilder.setPacketsLookedUp(new Counter64(swTableStats.getLookupCount()));
        statisticsBuilder.setPacketsMatched(new Counter64(swTableStats.getMatchedCount()));
        statisticsBuilder.setTableId(new TableId(swTableStats.getTableId()));
        salFlowStats.add(statisticsBuilder.build());
    }
    message.setFlowTableAndStatisticsMap(salFlowStats);
    return message.build();
}
Also used : MultipartReplyFlowTableStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.multipart.reply.multipart.reply.body.MultipartReplyFlowTableStatsBuilder) FlowTableAndStatisticsMap(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMap) Counter32(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32) TableId(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId) Counter64(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64) MultipartReplyTableCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCase) ArrayList(java.util.ArrayList) MultipartReplyTable(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTable) FlowTableAndStatisticsMapBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMapBuilder) MultipartReplyFlowTableStats(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.multipart.reply.multipart.reply.body.MultipartReplyFlowTableStats) TableStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStats)

Example 9 with Counter32

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32 in project openflowplugin by opendaylight.

the class MultipartReplyTranslatorUtil method translateMeterFeatures.

private static org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterFeatures translateMeterFeatures(final MultipartReply msg) {
    MultipartReplyMeterFeaturesBuilder message = new MultipartReplyMeterFeaturesBuilder();
    MultipartReplyMeterFeaturesCase caseBody = (MultipartReplyMeterFeaturesCase) msg.getMultipartReplyBody();
    MultipartReplyMeterFeatures replyBody = caseBody.getMultipartReplyMeterFeatures();
    message.setMaxBands(replyBody.getMaxBands());
    message.setMaxColor(replyBody.getMaxColor());
    message.setMaxMeter(new Counter32(replyBody.getMaxMeter()));
    List<Class<? extends MeterCapability>> supportedCapabilities = new ArrayList<>();
    if (replyBody.getCapabilities().isOFPMFBURST()) {
        supportedCapabilities.add(MeterBurst.class);
    }
    if (replyBody.getCapabilities().isOFPMFKBPS()) {
        supportedCapabilities.add(MeterKbps.class);
    }
    if (replyBody.getCapabilities().isOFPMFPKTPS()) {
        supportedCapabilities.add(MeterPktps.class);
    }
    if (replyBody.getCapabilities().isOFPMFSTATS()) {
        supportedCapabilities.add(MeterStats.class);
    }
    message.setMeterCapabilitiesSupported(supportedCapabilities);
    List<Class<? extends MeterBand>> supportedMeterBand = new ArrayList<>();
    if (replyBody.getBandTypes().isOFPMBTDROP()) {
        supportedMeterBand.add(MeterBandDrop.class);
    }
    if (replyBody.getBandTypes().isOFPMBTDSCPREMARK()) {
        supportedMeterBand.add(MeterBandDscpRemark.class);
    }
    message.setMeterBandSupported(supportedMeterBand);
    return message.build();
}
Also used : Counter32(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32) MeterBand(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBand) MultipartReplyMeterFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesBuilder) MultipartReplyMeterFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeatures) ArrayList(java.util.ArrayList) MeterCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterCapability) MultipartReplyMeterFeaturesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCase)

Example 10 with Counter32

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32 in project openflowplugin by opendaylight.

the class MultipartReplyFlowAggregateStatsDeserializer method deserialize.

@Override
public MultipartReplyBody deserialize(ByteBuf message) {
    final byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    message.readBytes(packetCount);
    final byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    message.readBytes(byteCount);
    final MultipartReplyFlowAggregateStatsBuilder builder = new MultipartReplyFlowAggregateStatsBuilder().setPacketCount(new Counter64(new BigInteger(1, packetCount))).setByteCount(new Counter64(new BigInteger(1, byteCount))).setFlowCount(new Counter32(message.readUnsignedInt()));
    message.skipBytes(PADDING_IN_AGGREGATE_HEADER);
    return builder.build();
}
Also used : MultipartReplyFlowAggregateStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.multipart.reply.multipart.reply.body.MultipartReplyFlowAggregateStatsBuilder) Counter32(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32) Counter64(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64) BigInteger(java.math.BigInteger)

Aggregations

Counter32 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32)28 Counter64 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64)20 ArrayList (java.util.ArrayList)16 DurationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.duration.DurationBuilder)11 BigInteger (java.math.BigInteger)7 MultipartReply (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply)6 TableId (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId)5 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)4 BytesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.node.connector.statistics.BytesBuilder)4 PacketsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.node.connector.statistics.PacketsBuilder)4 NodeConnectorStatisticsAndPortNumberMapBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapBuilder)4 NodeConnectorStatisticsAndPortNumberMapKey (org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapKey)4 Test (org.junit.Test)3 FlowAndStatisticsMapList (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList)3 FlowAndStatisticsMapListBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListBuilder)3 AggregatedFlowStatisticsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatisticsBuilder)3 QueueId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId)3 NodeConnectorStatisticsAndPortNumberMap (org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap)3 QueueIdAndStatisticsMap (org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMap)3 QueueIdAndStatisticsMapBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMapBuilder)3