X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflowplugin-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fimpl%2Fstatistics%2Fservices%2FOpendaylightFlowTableStatisticsServiceImpl.java;h=2f4483b7e0953fabe2a2ebd5dfd3b35dd9ed5087;hb=7f63d9b25efe493bbafc8b6d5ec4a8ad0327fa79;hp=23433764fb76ef06e664214f55612ae5a15c6791;hpb=ca89c15cbe1661b36d568fd133f8ec6872710e62;p=openflowplugin.git diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowTableStatisticsServiceImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowTableStatisticsServiceImpl.java index 23433764fb..2f4483b7e0 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowTableStatisticsServiceImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowTableStatisticsServiceImpl.java @@ -7,33 +7,57 @@ */ package org.opendaylight.openflowplugin.impl.statistics.services; +import java.util.ArrayList; +import java.util.List; import java.util.concurrent.Future; +import java.util.concurrent.atomic.AtomicLong; +import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack; import org.opendaylight.openflowplugin.api.openflow.device.Xid; -import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService; import org.opendaylight.openflowplugin.impl.services.RequestInputUtils; +import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.AbstractCompatibleStatService; +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.table.statistics.rev131215.FlowTableStatisticsUpdate; +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.GetFlowTablesStatisticsInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsService; +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.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; 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.MultipartReplyTableCase; +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.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table._case.MultipartRequestTableBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId; import org.opendaylight.yangtools.yang.common.RpcResult; -public final class OpendaylightFlowTableStatisticsServiceImpl extends AbstractSimpleService implements +public final class OpendaylightFlowTableStatisticsServiceImpl extends + AbstractCompatibleStatService implements OpendaylightFlowTableStatisticsService { - public OpendaylightFlowTableStatisticsServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) { - super(requestContextStack, deviceContext, GetFlowTablesStatisticsOutput.class); + private final NotificationPublishService notificationPublishService; + + public OpendaylightFlowTableStatisticsServiceImpl(final RequestContextStack requestContextStack, + final DeviceContext deviceContext, + final AtomicLong compatibilityXidSeed, + final NotificationPublishService notificationPublishService) { + super(requestContextStack, deviceContext, compatibilityXidSeed); + this.notificationPublishService = notificationPublishService; } @Override public Future> getFlowTablesStatistics( final GetFlowTablesStatisticsInput input) { - return handleServiceCall(input); + return handleAndNotify(input, notificationPublishService); } @Override @@ -52,4 +76,36 @@ public final class OpendaylightFlowTableStatisticsServiceImpl extends AbstractSi return mprInput.build(); } + + @Override + public GetFlowTablesStatisticsOutput buildTxCapableResult(TransactionId emulatedTxId) { + return new GetFlowTablesStatisticsOutputBuilder().setTransactionId(emulatedTxId).build(); + } + + @Override + public FlowTableStatisticsUpdate transformToNotification(List mpReplyList, TransactionId emulatedTxId) { + FlowTableStatisticsUpdateBuilder notification = new FlowTableStatisticsUpdateBuilder(); + notification.setId(getDeviceInfo().getNodeId()); + notification.setMoreReplies(Boolean.FALSE); + notification.setTransactionId(emulatedTxId); + + final List salFlowStats = new ArrayList<>(); + notification.setFlowTableAndStatisticsMap(salFlowStats); + for (MultipartReply mpReply : mpReplyList) { + MultipartReplyTableCase caseBody = (MultipartReplyTableCase) mpReply.getMultipartReplyBody(); + MultipartReplyTable replyBody = caseBody.getMultipartReplyTable(); + List swTablesStats = replyBody.getTableStats(); + + 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()); + } + } + + return notification.build(); + } }