X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflowplugin%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fopenflow%2Fmd%2Fcore%2Ftranslator%2FMultipartReplyTranslator.java;h=56f2ebec56c37c3aa8f893869959975d8fa12202;hb=611180ac770b6038b526c54994701db16d1a8567;hp=bed00bf975d99dd1dfdae6d917be13d9e17225c9;hpb=814231b32b75c57ee7eb499938cf41dc8b27f41d;p=openflowplugin.git diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/translator/MultipartReplyTranslator.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/translator/MultipartReplyTranslator.java index bed00bf975..56f2ebec56 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/translator/MultipartReplyTranslator.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/translator/MultipartReplyTranslator.java @@ -12,17 +12,23 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; -import org.opendaylight.openflowplugin.openflow.md.core.IMDMessageTranslator; -import org.opendaylight.openflowplugin.openflow.md.core.SwitchConnectionDistinguisher; +import org.opendaylight.openflowplugin.api.openflow.md.core.IMDMessageTranslator; +import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher; +import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext; +import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion; import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.FlowStatsResponseConvertor; import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.GroupStatsResponseConvertor; import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.MeterStatsResponseConvertor; -import org.opendaylight.openflowplugin.openflow.md.core.session.SessionContext; +import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter32; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter64; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsUpdateBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdateBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsUpdateBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMap; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMapBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupDescStatsUpdatedBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupFeaturesUpdatedBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdatedBuilder; @@ -48,6 +54,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.Meter import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterKbps; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterPktps; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.duration.DurationBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.node.connector.statistics.BytesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.node.connector.statistics.PacketsBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase; @@ -58,6 +67,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfigCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregate; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.MultipartReplyGroup; @@ -66,6 +78,20 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.MultipartReplyMeter; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.MultipartReplyMeterConfig; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeatures; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats; +import 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; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueue; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.multipart.reply.queue.QueueStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTable; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsUpdateBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap; +import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.QueueStatisticsUpdateBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMap; +import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMapBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId; import org.opendaylight.yangtools.yang.binding.DataObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -91,26 +117,28 @@ public class MultipartReplyTranslator implements IMDMessageTranslator listDataObject = new CopyOnWriteArrayList(); + OpenflowVersion ofVersion = OpenflowVersion.get(sc.getPrimaryConductor().getVersion()); + if(msg instanceof MultipartReplyMessage){ MultipartReplyMessage mpReply = (MultipartReplyMessage)msg; NodeId node = this.nodeIdFromDatapathId(sc.getFeatures().getDatapathId()); switch (mpReply.getType()){ case OFPMPFLOW: { - logger.info("Received flow statistics reponse from openflow {} switch",msg.getVersion()==1?"1.0":"1.3+"); + logger.debug("Received flow statistics reponse from openflow {} switch",msg.getVersion()==1?"1.0":"1.3+"); FlowsStatisticsUpdateBuilder message = new FlowsStatisticsUpdateBuilder(); message.setId(node); message.setMoreReplies(mpReply.getFlags().isOFPMPFREQMORE()); message.setTransactionId(generateTransactionId(mpReply.getXid())); MultipartReplyFlowCase caseBody = (MultipartReplyFlowCase)mpReply.getMultipartReplyBody(); MultipartReplyFlow replyBody = caseBody.getMultipartReplyFlow(); - message.setFlowAndStatisticsMapList(flowStatsConvertor.toSALFlowStatsList(replyBody.getFlowStats())); + message.setFlowAndStatisticsMapList(flowStatsConvertor.toSALFlowStatsList(replyBody.getFlowStats(),sc.getFeatures().getDatapathId(), ofVersion)); - logger.info("Converted flow statistics : {}",message.build().toString()); + logger.debug("Converted flow statistics : {}",message.build().toString()); listDataObject.add(message.build()); return listDataObject; } case OFPMPAGGREGATE: { - logger.info("Received aggregate flow statistics reponse from openflow {} switch",msg.getVersion()==1?"1.0":"1.3+"); + logger.debug("Received aggregate flow statistics reponse from openflow {} switch",msg.getVersion()==1?"1.0":"1.3+"); AggregateFlowStatisticsUpdateBuilder message = new AggregateFlowStatisticsUpdateBuilder(); message.setId(node); message.setMoreReplies(mpReply.getFlags().isOFPMPFREQMORE()); @@ -122,13 +150,69 @@ public class MultipartReplyTranslator implements IMDMessageTranslator statsMap = + new ArrayList(); + for (PortStats portStats: replyBody.getPortStats()){ + + NodeConnectorStatisticsAndPortNumberMapBuilder statsBuilder = + new NodeConnectorStatisticsAndPortNumberMapBuilder(); + statsBuilder.setNodeConnectorId( + InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(sc.getFeatures().getDatapathId(), + 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); + + logger.debug("Converted ports statistics : {}",message.build().toString()); + + listDataObject.add(message.build()); + return listDataObject; } case OFPMPGROUP:{ - logger.info("Received group statistics multipart reponse"); + logger.debug("Received group statistics multipart reponse"); GroupStatisticsUpdatedBuilder message = new GroupStatisticsUpdatedBuilder(); message.setId(node); message.setMoreReplies(mpReply.getFlags().isOFPMPFREQMORE()); @@ -142,7 +226,7 @@ public class MultipartReplyTranslator implements IMDMessageTranslator swTablesStats = replyBody.getTableStats(); + + List salFlowStats = new ArrayList(); + 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); + + logger.debug("Converted flow table statistics : {}",message.build().toString()); + listDataObject.add(message.build()); + return listDataObject; + } + case OFPMPQUEUE: { + logger.debug("Received queue statistics multipart response"); + + QueueStatisticsUpdateBuilder message = new QueueStatisticsUpdateBuilder(); + message.setId(node); + message.setMoreReplies(mpReply.getFlags().isOFPMPFREQMORE()); + message.setTransactionId(generateTransactionId(mpReply.getXid())); + + MultipartReplyQueueCase caseBody = (MultipartReplyQueueCase)mpReply.getMultipartReplyBody(); + MultipartReplyQueue replyBody = caseBody.getMultipartReplyQueue(); + + List statsMap = + new ArrayList(); + + for (QueueStats queueStats: replyBody.getQueueStats()){ + + QueueIdAndStatisticsMapBuilder statsBuilder = + new QueueIdAndStatisticsMapBuilder(); + statsBuilder.setNodeConnectorId( + InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(sc.getFeatures().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())); + statsBuilder.setNodeConnectorId(InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(sc.getFeatures().getDatapathId(), + queueStats.getPortNo(), ofVersion)); + + statsMap.add(statsBuilder.build()); + } + message.setQueueIdAndStatisticsMap(statsMap); - //Send update notification to all the listeners + logger.debug("Converted queue statistics : {}",message.build().toString()); + listDataObject.add(message.build()); return listDataObject; } + default: return listDataObject; } @@ -320,24 +470,23 @@ public class MultipartReplyTranslator implements IMDMessageTranslator supportActionByGroups = new ArrayList(); for(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType supportedActions : actionsSupported){ long supportActionBitmap = 0; - supportActionBitmap |= supportedActions.isOFPATOUTPUT()?(1 << 0): ~(1 << 0); - supportActionBitmap |= supportedActions.isOFPATCOPYTTLOUT()?(1 << 11): ~(1 << 11); - supportActionBitmap |= supportedActions.isOFPATCOPYTTLIN()?(1 << 12): ~(1 << 12); - supportActionBitmap |= supportedActions.isOFPATSETMPLSTTL()?(1 << 15): ~(1 << 15); - supportActionBitmap |= supportedActions.isOFPATDECMPLSTTL()?(1 << 16): ~(1 << 16); - supportActionBitmap |= supportedActions.isOFPATPUSHVLAN()?(1 << 16): ~(1 << 16); - supportActionBitmap |= supportedActions.isOFPATPOPVLAN()?(1 << 17): ~(1 << 17); - supportActionBitmap |= supportedActions.isOFPATPUSHMPLS()?(1 << 18): ~(1 << 18); - supportActionBitmap |= supportedActions.isOFPATPOPMPLS()?(1 << 19): ~(1 << 19); - supportActionBitmap |= supportedActions.isOFPATSETQUEUE()?(1 << 20): ~(1 << 20); - supportActionBitmap |= supportedActions.isOFPATGROUP()?(1 << 21): ~(1 << 21); - supportActionBitmap |= supportedActions.isOFPATSETNWTTL()?(1 << 22): ~(1 << 22); - supportActionBitmap |= supportedActions.isOFPATDECNWTTL()?(1 << 23): ~(1 << 23); - supportActionBitmap |= supportedActions.isOFPATSETFIELD()?(1 << 24): ~(1 << 24); - supportActionBitmap |= supportedActions.isOFPATPUSHPBB()?(1 << 25): ~(1 << 25); - supportActionBitmap |= supportedActions.isOFPATPOPPBB()?(1 << 26): ~(1 << 26); - supportActionBitmap |= supportedActions.isOFPATEXPERIMENTER()?(1 << 27): ~(1 << 27); - supportActionByGroups.add(new Long(supportActionBitmap)); + supportActionBitmap |= supportedActions.isOFPATOUTPUT()?(1 << 0): 0; + supportActionBitmap |= supportedActions.isOFPATCOPYTTLOUT()?(1 << 11): 0; + supportActionBitmap |= supportedActions.isOFPATCOPYTTLIN()?(1 << 12): 0; + supportActionBitmap |= supportedActions.isOFPATSETMPLSTTL()?(1 << 15): 0; + supportActionBitmap |= supportedActions.isOFPATDECMPLSTTL()?(1 << 16): 0; + supportActionBitmap |= supportedActions.isOFPATPUSHVLAN()?(1 << 17): 0; + supportActionBitmap |= supportedActions.isOFPATPOPVLAN()?(1 << 18): 0; + supportActionBitmap |= supportedActions.isOFPATPUSHMPLS()?(1 << 19): 0; + supportActionBitmap |= supportedActions.isOFPATPOPMPLS()?(1 << 20): 0; + supportActionBitmap |= supportedActions.isOFPATSETQUEUE()?(1 << 21): 0; + supportActionBitmap |= supportedActions.isOFPATGROUP()?(1 << 22): 0; + supportActionBitmap |= supportedActions.isOFPATSETNWTTL()?(1 << 23): 0; + supportActionBitmap |= supportedActions.isOFPATDECNWTTL()?(1 << 24): 0; + supportActionBitmap |= supportedActions.isOFPATSETFIELD()?(1 << 25): 0; + supportActionBitmap |= supportedActions.isOFPATPUSHPBB()?(1 << 26): 0; + supportActionBitmap |= supportedActions.isOFPATPOPPBB()?(1 << 27): 0; + supportActionByGroups.add(Long.valueOf(supportActionBitmap)); } return supportActionByGroups; }