Search in sources :

Example 1 with FlowTableStatistics

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.statistics.FlowTableStatistics in project openflowplugin by opendaylight.

the class FlowTableStatNotificationSupplierImpl method createNotification.

@Override
public FlowTableStatisticsUpdate createNotification(final FlowTableStatistics flowTableStatistics, final InstanceIdentifier<FlowTableStatistics> path) {
    Preconditions.checkArgument(flowTableStatistics != null);
    Preconditions.checkArgument(path != null);
    final FlowTableAndStatisticsMapBuilder ftsmBuilder = new FlowTableAndStatisticsMapBuilder(flowTableStatistics);
    ftsmBuilder.setKey(new FlowTableAndStatisticsMapKey(new TableId(path.firstKeyOf(Table.class, TableKey.class).getId())));
    final FlowTableStatisticsUpdateBuilder builder = new FlowTableStatisticsUpdateBuilder();
    builder.setId(getNodeId(path));
    builder.setMoreReplies(Boolean.FALSE);
    // NOTE : fix if it needs, but we have to ask DataStore for the NodeConnector list
    builder.setNodeConnector(Collections.<NodeConnector>emptyList());
    builder.setFlowTableAndStatisticsMap(Collections.singletonList(ftsmBuilder.build()));
    return builder.build();
}
Also used : TableId(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId) FlowTableAndStatisticsMapKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMapKey) FlowTableStatisticsUpdateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsUpdateBuilder) FlowTableAndStatisticsMapBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMapBuilder)

Example 2 with FlowTableStatistics

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.statistics.FlowTableStatistics in project openflowplugin by opendaylight.

the class FlowTableStatNotificationSupplierImplTest method testCreateChangeEvent.

@Test
public void testCreateChangeEvent() {
    final TestData testData = new TestData(createTestFlowTableStatPath(), null, createTestFlowTableStat(), DataObjectModification.ModificationType.WRITE);
    Collection<DataTreeModification<FlowTableStatistics>> collection = new ArrayList<>();
    collection.add(testData);
    notifSupplierImpl.onDataTreeChanged(collection);
    verify(notifProviderService, times(1)).publish(Matchers.any(FlowTableStatisticsUpdate.class));
}
Also used : DataTreeModification(org.opendaylight.controller.md.sal.binding.api.DataTreeModification) FlowTableStatisticsUpdate(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsUpdate) TestData(org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 3 with FlowTableStatistics

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.statistics.FlowTableStatistics in project openflowplugin by opendaylight.

the class StatisticsGatheringUtilsTest method testGatherStatistics_table.

@Test
public void testGatherStatistics_table() throws Exception {
    final MultipartType type = MultipartType.OFPMPTABLE;
    final TableStatsBuilder tableStatsBld = new TableStatsBuilder().setActiveCount(33L).setLookupCount(BigInteger.valueOf(34L)).setMatchedCount(BigInteger.valueOf(35L)).setTableId((short) 0);
    final MultipartReplyTableBuilder mpReplyTableBld = new MultipartReplyTableBuilder();
    mpReplyTableBld.setTableStats(Lists.newArrayList(tableStatsBld.build()));
    final MultipartReplyTableCaseBuilder mpReplyTableCaseBld = new MultipartReplyTableCaseBuilder();
    mpReplyTableCaseBld.setMultipartReplyTable(mpReplyTableBld.build());
    final MultipartReply meterStatsUpdated = assembleMPReplyMessage(type, mpReplyTableCaseBld.build());
    final List<MultipartReply> statsData = Collections.singletonList(meterStatsUpdated);
    fireAndCheck(type, statsData);
    final InstanceIdentifier<FlowTableStatistics> tablePath = dummyNodePath.augmentation(FlowCapableNode.class).child(Table.class, new TableKey((short) 0)).augmentation(FlowTableStatisticsData.class).child(FlowTableStatistics.class);
    verify(deviceContext).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.eq(tablePath), Matchers.any(FlowTableStatistics.class));
}
Also used : FlowTableStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.statistics.FlowTableStatistics) MultipartReplyTableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTableBuilder) FlowTableStatisticsData(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsData) MultipartType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) TableStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStatsBuilder) MultipartReplyTableCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCaseBuilder) Test(org.junit.Test)

Example 4 with FlowTableStatistics

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.statistics.FlowTableStatistics 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

Test (org.junit.Test)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 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)1 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)1 BigInteger (java.math.BigInteger)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Executors (java.util.concurrent.Executors)1 Future (java.util.concurrent.Future)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 ScheduledFuture (java.util.concurrent.ScheduledFuture)1 ThreadFactory (java.util.concurrent.ThreadFactory)1