Search in sources :

Example 11 with GetFlowStatisticsOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsOutput in project openflowplugin by opendaylight.

the class FlowDirectStatisticsService method buildReply.

@Override
protected GetFlowStatisticsOutput buildReply(List<MultipartReply> input, boolean success) {
    final List<FlowAndStatisticsMapList> statsList = new ArrayList<>();
    if (success) {
        for (final MultipartReply mpReply : input) {
            final MultipartReplyFlowCase caseBody = (MultipartReplyFlowCase) mpReply.getMultipartReplyBody();
            final MultipartReplyFlow replyBody = caseBody.getMultipartReplyFlow();
            final Optional<List<FlowAndStatisticsMapList>> statsListPart = getConvertorExecutor().convert(replyBody.getFlowStats(), data);
            statsListPart.ifPresent(flowAndStatisticsMapLists -> {
                for (final FlowAndStatisticsMapList part : flowAndStatisticsMapLists) {
                    final FlowId flowId = new FlowId(generateFlowId(part).getValue());
                    statsList.add(new FlowAndStatisticsMapListBuilder(part).setKey(new FlowAndStatisticsMapListKey(flowId)).setFlowId(flowId).build());
                }
            });
        }
    }
    return new GetFlowStatisticsOutputBuilder().setFlowAndStatisticsMapList(statsList).build();
}
Also used : FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowId) FlowAndStatisticsMapListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListBuilder) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) ArrayList(java.util.ArrayList) MultipartReplyFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow) FlowAndStatisticsMapListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListKey) ArrayList(java.util.ArrayList) FlowAndStatisticsMapList(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList) List(java.util.List) FlowAndStatisticsMapList(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList) MultipartReplyFlowCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase) GetFlowStatisticsOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsOutputBuilder)

Example 12 with GetFlowStatisticsOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsOutput in project genius by opendaylight.

the class NodeConnectorStatsImpl method processFlowStatistics.

/**
 * This method processes FlowStatistics RPC result.
 * It performs:
 * - fetches all flows of node
 * - stores flows count per table in local map
 * - creates/updates Flow table counters using Infrautils metrics API
 * - set counter with values fetched from FlowStatistics
 */
private void processFlowStatistics(GetFlowStatisticsOutput flowStatsOutput, BigInteger dpid) {
    Map<Short, AtomicInteger> flowTableMap = new HashMap<>();
    // Get all flows for node from RPC result
    List<FlowAndStatisticsMapList> flowTableAndStatisticsMapList = flowStatsOutput.getFlowAndStatisticsMapList();
    for (FlowAndStatisticsMapList flowAndStatisticsMap : flowTableAndStatisticsMapList) {
        short tableId = flowAndStatisticsMap.getTableId();
        // populate map to maintain flow count per table
        flowTableMap.computeIfAbsent(tableId, key -> new AtomicInteger(0)).incrementAndGet();
    }
    LOG.trace("FlowTableStatistics (tableId:counter): {} for node: {}", flowTableMap.entrySet(), dpid.toString());
    for (Map.Entry<Short, AtomicInteger> flowTable : flowTableMap.entrySet()) {
        Short tableId = flowTable.getKey();
        AtomicInteger flowCount = flowTable.getValue();
        Counter counter = getCounter(CounterConstants.IFM_FLOW_TBL_COUNTER_FLOWS_PER_TBL, dpid, null, null, tableId.toString());
        // update counter value
        updateCounter(counter, flowCount.longValue());
    }
}
Also used : InterfaceChildEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info._interface.parent.entry.InterfaceChildEntry) ScheduledFuture(java.util.concurrent.ScheduledFuture) MetricDescriptor(org.opendaylight.infrautils.metrics.MetricDescriptor) UncheckedCloseable(org.opendaylight.infrautils.utils.UncheckedCloseable) LoggerFactory(org.slf4j.LoggerFactory) AsyncClusteredDataTreeChangeListenerBase(org.opendaylight.genius.datastoreutils.AsyncClusteredDataTreeChangeListenerBase) GetFlowStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsOutput) PreDestroy(javax.annotation.PreDestroy) Future(java.util.concurrent.Future) InterfaceChildCache(org.opendaylight.genius.interfacemanager.listeners.InterfaceChildCache) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Optional(com.google.common.base.Optional) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) Map(java.util.Map) BigInteger(java.math.BigInteger) ThreadFactory(java.util.concurrent.ThreadFactory) GetFlowStatisticsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsInputBuilder) GetFlowStatisticsInput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsInput) GetNodeConnectorStatisticsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsInputBuilder) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) EntityOwnershipUtils(org.opendaylight.genius.utils.clustering.EntityOwnershipUtils) IfmConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.config.rev160406.IfmConfig) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) Set(java.util.Set) Executors(java.util.concurrent.Executors) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) OpendaylightDirectStatisticsService(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.OpendaylightDirectStatisticsService) NodeConnectorStatisticsAndPortNumberMap(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap) List(java.util.List) GetNodeConnectorStatisticsInput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsInput) Labeled(org.opendaylight.infrautils.metrics.Labeled) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) ThreadFactoryBuilder(com.google.common.util.concurrent.ThreadFactoryBuilder) IfmConstants(org.opendaylight.genius.interfacemanager.IfmConstants) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) MetricProvider(org.opendaylight.infrautils.metrics.MetricProvider) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) HashMap(java.util.HashMap) Singleton(javax.inject.Singleton) JdkFutureAdapters(com.google.common.util.concurrent.JdkFutureAdapters) Inject(javax.inject.Inject) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) FlowAndStatisticsMapList(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Nonnull(javax.annotation.Nonnull) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) Logger(org.slf4j.Logger) FutureCallback(com.google.common.util.concurrent.FutureCallback) TimeUnit(java.util.concurrent.TimeUnit) Futures(com.google.common.util.concurrent.Futures) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) PortNameCache(org.opendaylight.genius.interfacemanager.listeners.PortNameCache) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) Counter(org.opendaylight.infrautils.metrics.Counter) GetNodeConnectorStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsOutput) Counter(org.opendaylight.infrautils.metrics.Counter) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) FlowAndStatisticsMapList(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) NodeConnectorStatisticsAndPortNumberMap(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap) HashMap(java.util.HashMap)

Aggregations

GetFlowStatisticsOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsOutput)9 FlowAndStatisticsMapList (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList)8 ArrayList (java.util.ArrayList)4 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)4 BigInteger (java.math.BigInteger)3 GetFlowStatisticsInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsInputBuilder)3 NodeRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef)3 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)3 List (java.util.List)2 ExecutionException (java.util.concurrent.ExecutionException)2 GetFlowStatisticsOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsOutputBuilder)2 FlowAndStatisticsMap (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowAndStatisticsMap)2 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)2 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)2 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)2 Optional (com.google.common.base.Optional)1 FutureCallback (com.google.common.util.concurrent.FutureCallback)1 Futures (com.google.common.util.concurrent.Futures)1 JdkFutureAdapters (com.google.common.util.concurrent.JdkFutureAdapters)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1