Merge "BUG 2335 : Add jolokia feature"
authorEd Warnicke <eaw@cisco.com>
Tue, 2 Dec 2014 14:49:28 +0000 (14:49 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 2 Dec 2014 14:49:29 +0000 (14:49 +0000)
32 files changed:
features/flow/pom.xml
features/flow/src/main/resources/features.xml
opendaylight/commons/opendaylight/pom.xml
opendaylight/md-sal/pom.xml
opendaylight/md-sal/statistics-manager-config/pom.xml [new file with mode: 0644]
opendaylight/md-sal/statistics-manager-config/src/main/resources/initial/30-statistics-manager.xml [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/pom.xml
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/config/yang/md/sal/statistics_manager/StatisticsManagerModule.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/config/yang/md/sal/statistics_manager/StatisticsManagerModuleFactory.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsManager.java
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsManagerActivator.java [deleted file]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatisticsManagerConfig.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatisticsManagerImpl.java
opendaylight/md-sal/statistics-manager/src/main/yang/statistics-manager.yang [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/test/java/org/opendaylight/controller/md/statistics/manager/StatisticsManagerProvider.java [deleted file]
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/FlowStatisticsTest.java [deleted file]
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/GroupStatisticsTest.java [deleted file]
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/MeterStatisticsTest.java [deleted file]
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/NodeRegistrationTest.java
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/PortStatisticsTest.java [deleted file]
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/QueueStatisticsTest.java [deleted file]
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/StatCollectorTest.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/TableStatisticsTest.java [deleted file]
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/OpendaylightFlowStatisticsServiceMock.java
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/OpendaylightFlowTableStatisticsServiceMock.java
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/OpendaylightGroupStatisticsServiceMock.java
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/OpendaylightMeterStatisticsServiceMock.java
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/OpendaylightPortStatisticsServiceMock.java
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/OpendaylightQueueStatisticsServiceMock.java
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/ProviderContextMock.java [deleted file]
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/StatisticsManagerTest.java
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/TestUtils.java

index ab30b0b..53b45d2 100644 (file)
       <classifier>features</classifier>
       <type>xml</type>
     </dependency>
+
+  <dependency>
+      <groupId>org.opendaylight.controller.md</groupId>
+      <artifactId>statistics-manager-config</artifactId>
+      <version>${mdsal.version}</version>
+      <type>xml</type>
+      <classifier>config</classifier>
+  </dependency>
+
     <dependency>
       <groupId>org.opendaylight.controller.model</groupId>
       <artifactId>model-flow-base</artifactId>
index 0540458..cf54e8b 100644 (file)
@@ -21,6 +21,7 @@
         <bundle>mvn:org.opendaylight.controller.md/inventory-manager/${project.version}</bundle>
         <bundle>mvn:org.opendaylight.controller.md/forwardingrules-manager/${project.version}</bundle>
         <bundle>mvn:org.opendaylight.controller/liblldp/${sal.version}</bundle>
+        <configfile finalname="${config.configfile.directory}/${config.statistics.manager.configfile}">mvn:org.opendaylight.controller.md/statistics-manager-config/${mdsal.version}/xml/config</configfile>
     </feature>
 
 </features>
index b2585ad..1030be5 100644 (file)
@@ -87,6 +87,7 @@
     <controllermanager.northbound.version>0.1.0-SNAPSHOT</controllermanager.northbound.version>
     <devices.web.version>0.5.0-SNAPSHOT</devices.web.version>
     <dummy-console.version>1.2.0-SNAPSHOT</dummy-console.version>
+    <config.statistics.manager.configfile>30-statistics-manager.xml</config.statistics.manager.configfile>
     <eclipse.persistence.version>2.5.0</eclipse.persistence.version>
     <eclipse.jdt.core.compiler.batch.version>3.8.0.I20120518-2145</eclipse.jdt.core.compiler.batch.version>
     <!-- enforcer version -->
index 38756f2..d21f16c 100644 (file)
@@ -51,6 +51,7 @@
 
     <module>inventory-manager</module>
     <module>statistics-manager</module>
+    <module>statistics-manager-config</module>
     <module>topology-manager</module>
     <module>forwardingrules-manager</module>
     <module>topology-lldp-discovery</module>
diff --git a/opendaylight/md-sal/statistics-manager-config/pom.xml b/opendaylight/md-sal/statistics-manager-config/pom.xml
new file mode 100644 (file)
index 0000000..f4b5f76
--- /dev/null
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+
+ This program and the accompanying materials are made available under the
+ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.opendaylight.controller</groupId>
+        <artifactId>sal-parent</artifactId>
+        <version>1.2.0-SNAPSHOT</version>
+    </parent>
+
+    <groupId>org.opendaylight.controller.md</groupId>
+    <artifactId>statistics-manager-config</artifactId>
+    <description>Configuration files for statistics manager</description>
+    <packaging>jar</packaging>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>attach-artifacts</id>
+                        <goals>
+                            <goal>attach-artifact</goal>
+                        </goals>
+                        <phase>package</phase>
+                        <configuration>
+                            <artifacts>
+                                <artifact>
+                                    <file>${project.build.directory}/classes/initial/30-statistics-manager.xml</file>
+                                    <type>xml</type>
+                                    <classifier>config</classifier>
+                                </artifact>
+                            </artifacts>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/opendaylight/md-sal/statistics-manager-config/src/main/resources/initial/30-statistics-manager.xml b/opendaylight/md-sal/statistics-manager-config/src/main/resources/initial/30-statistics-manager.xml
new file mode 100644 (file)
index 0000000..797c14e
--- /dev/null
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+ Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+
+ This program and the accompanying materials are made available under the
+ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+<snapshot>
+    <configuration>
+        <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+            <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+                <module>
+                    <type xmlns:statsmanager="urn:opendaylight:params:xml:ns:yang:controller:md:sal:statistics-manager">
+                        statsmanager:statistics-manager
+                    </type>
+                    <name>statistics-manager</name>
+
+                    <rpc-registry>
+                        <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-rpc-registry</type>
+                        <name>binding-rpc-broker</name>
+                    </rpc-registry>
+
+                    <data-broker>
+                        <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-async-data-broker</type>
+                        <name>binding-data-broker</name>
+                    </data-broker>
+
+                    <notification-service>
+                        <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">
+                            binding:binding-notification-service
+                        </type>
+                        <name>binding-notification-broker</name>
+                    </notification-service>
+
+                    <statistics-manager-settings>
+                        <min-request-net-monitor-interval>3000</min-request-net-monitor-interval>
+                        <max-nodes-for-collector>16</max-nodes-for-collector>
+                    </statistics-manager-settings>
+
+                </module>
+            </modules>
+        </data>
+    </configuration>
+
+    <required-capabilities>
+        <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:statistics-manager?module=statistics-manager&amp;revision=2014-09-25</capability>
+    </required-capabilities>
+
+</snapshot>
+
index eb6c51b..234e108 100644 (file)
       <artifactId>org.osgi.core</artifactId>
       <scope>provided</scope>
     </dependency>
+      <dependency>
+          <groupId>org.opendaylight.controller</groupId>
+          <artifactId>sal-binding-config</artifactId>
+      </dependency>
+      <dependency>
+          <groupId>org.opendaylight.controller</groupId>
+          <artifactId>config-api</artifactId>
+      </dependency>
     <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-log4j12</artifactId>
 
   <build>
     <plugins>
-      <plugin>
-        <groupId>org.apache.felix</groupId>
-        <artifactId>maven-bundle-plugin</artifactId>
-        <configuration>
-          <instructions>
-            <Bundle-Activator>org.opendaylight.controller.md.statistics.manager.StatisticsManagerActivator</Bundle-Activator>
-          </instructions>
-        </configuration>
-      </plugin>
+        <plugin>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>maven-bundle-plugin</artifactId>
+            <configuration>
+                <instructions>
+                    <Import-Package>*</Import-Package>
+                </instructions>
+            </configuration>
+        </plugin>
+        <plugin>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>yang-maven-plugin</artifactId>
+            <executions>
+                <execution>
+                    <id>config</id>
+                    <goals>
+                        <goal>generate-sources</goal>
+                    </goals>
+                    <configuration>
+                        <codeGenerators>
+                            <generator>
+                                <codeGeneratorClass>org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator</codeGeneratorClass>
+                                <outputBaseDir>${jmxGeneratorPath}</outputBaseDir>
+                                <additionalConfiguration>
+                                    <namespaceToPackage1>urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang</namespaceToPackage1>
+                                </additionalConfiguration>
+                            </generator>
+                            <generator>
+                                <codeGeneratorClass>org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl</codeGeneratorClass>
+                                <outputBaseDir>${salGeneratorPath}</outputBaseDir>
+                            </generator>
+                        </codeGenerators>
+                        <inspectDependencies>true</inspectDependencies>
+                    </configuration>
+                </execution>
+            </executions>
+        </plugin>
     </plugins>
   </build>
   <scm>
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/config/yang/md/sal/statistics_manager/StatisticsManagerModule.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/config/yang/md/sal/statistics_manager/StatisticsManagerModule.java
new file mode 100644 (file)
index 0000000..fb920a6
--- /dev/null
@@ -0,0 +1,71 @@
+package org.opendaylight.controller.config.yang.md.sal.statistics_manager;
+
+import org.opendaylight.controller.md.statistics.manager.StatisticsManager;
+import org.opendaylight.controller.md.statistics.manager.impl.StatisticsManagerConfig;
+import org.opendaylight.controller.md.statistics.manager.impl.StatisticsManagerImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class StatisticsManagerModule extends org.opendaylight.controller.config.yang.md.sal.statistics_manager.AbstractStatisticsManagerModule {
+    private final static Logger LOG = LoggerFactory.getLogger(StatisticsManagerModule.class);
+
+    private final static int MAX_NODES_FOR_COLLECTOR_DEFAULT = 16;
+    private final static int MIN_REQUEST_NET_MONITOR_INTERVAL_DEFAULT = 3000;
+
+    private StatisticsManager statisticsManagerProvider;
+
+    public StatisticsManagerModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+        super(identifier, dependencyResolver);
+    }
+
+    public StatisticsManagerModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, final StatisticsManagerModule oldModule, final java.lang.AutoCloseable oldInstance) {
+        super(identifier, dependencyResolver, oldModule, oldInstance);
+    }
+
+    @Override
+    public void customValidation() {
+        // add custom validation form module attributes here.
+    }
+
+    @Override
+    public java.lang.AutoCloseable createInstance() {
+        LOG.info("StatisticsManager module initialization.");
+        final StatisticsManagerConfig config = createConfig();
+        statisticsManagerProvider = new StatisticsManagerImpl(getDataBrokerDependency(), config);
+        statisticsManagerProvider.start(getNotificationServiceDependency(), getRpcRegistryDependency());
+        LOG.info("StatisticsManager started successfully.");
+        return new AutoCloseable() {
+            @Override
+            public void close() throws Exception {
+                try {
+                    statisticsManagerProvider.close();
+                }
+                catch (final Exception e) {
+                    LOG.error("Unexpected error by stopping StatisticsManager module", e);
+                }
+                LOG.info("StatisticsManager module stopped.");
+            }
+        };
+    }
+
+    public StatisticsManagerConfig createConfig() {
+        final StatisticsManagerConfig.StatisticsManagerConfigBuilder builder = StatisticsManagerConfig.builder();
+        if (getStatisticsManagerSettings() != null && getStatisticsManagerSettings().getMaxNodesForCollector() != null) {
+            builder.setMaxNodesForCollector(getStatisticsManagerSettings().getMaxNodesForCollector());
+        } else {
+            LOG.warn("Load the xml ConfigSubsystem input value fail! MaxNodesForCollector value is set to {} ",
+                    MAX_NODES_FOR_COLLECTOR_DEFAULT);
+            builder.setMaxNodesForCollector(MAX_NODES_FOR_COLLECTOR_DEFAULT);
+        }
+        if (getStatisticsManagerSettings() != null &&
+                getStatisticsManagerSettings().getMinRequestNetMonitorInterval() != null) {
+            builder.setMinRequestNetMonitorInterval(getStatisticsManagerSettings().getMinRequestNetMonitorInterval());
+        } else {
+            LOG.warn("Load the xml CofnigSubsystem input value fail! MinRequestNetMonitorInterval value is set to {} ",
+                    MIN_REQUEST_NET_MONITOR_INTERVAL_DEFAULT);
+            builder.setMinRequestNetMonitorInterval(MIN_REQUEST_NET_MONITOR_INTERVAL_DEFAULT);
+        }
+        return builder.build();
+    }
+
+}
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/config/yang/md/sal/statistics_manager/StatisticsManagerModuleFactory.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/config/yang/md/sal/statistics_manager/StatisticsManagerModuleFactory.java
new file mode 100644 (file)
index 0000000..dc37447
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+* Generated file
+*
+* Generated from: yang module name: statistics-manager yang module local name: statistics-manager
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Tue Oct 07 14:09:47 CEST 2014
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.md.sal.statistics_manager;
+public class StatisticsManagerModuleFactory extends org.opendaylight.controller.config.yang.md.sal.statistics_manager.AbstractStatisticsManagerModuleFactory {
+
+}
index 7d57067..831dc22 100644 (file)
@@ -13,6 +13,7 @@ import java.util.List;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
 import org.opendaylight.controller.md.statistics.manager.StatPermCollector.StatCapabTypes;
+import org.opendaylight.controller.md.statistics.manager.impl.StatisticsManagerConfig;
 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
 import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
@@ -70,7 +71,7 @@ public interface StatisticsManager extends AutoCloseable, TransactionChainListen
      * @param minReqNetMonitInt
      */
     void start(final NotificationProviderService notifService,
-            final RpcConsumerRegistry rpcRegistry, final long minReqNetMonitInt);
+            final RpcConsumerRegistry rpcRegistry);
 
     /**
      * Method provides read/write DataStore functionality cross applyOperation
@@ -185,5 +186,7 @@ public interface StatisticsManager extends AutoCloseable, TransactionChainListen
      */
     StatNotifyCommiter<OpendaylightPortStatisticsListener> getPortNotifyCommit();
 
+    StatisticsManagerConfig getConfiguration();
+
 }
 
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsManagerActivator.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsManagerActivator.java
deleted file mode 100644 (file)
index c505af4..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright IBM Corporation, 2013.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.controller.md.statistics.manager;
-
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.statistics.manager.impl.StatisticsManagerImpl;
-import org.opendaylight.controller.sal.binding.api.AbstractBindingAwareProvider;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
-import org.osgi.framework.BundleContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.annotations.VisibleForTesting;
-
-/**
- * Statistics Manager Activator
- *
- * OSGi bundle activator
- *
- */
-public class StatisticsManagerActivator extends AbstractBindingAwareProvider {
-
-    private final static Logger LOG = LoggerFactory.getLogger(StatisticsManagerActivator.class);
-
-    /* TODO move it to ConfigSubsystem */
-    private static final long DEFAULT_MIN_REQUEST_NET_MONITOR_INTERVAL = 3000L;
-    private static final int MAX_NODES_FOR_COLLECTOR = 16;
-
-    private StatisticsManager statsProvider;
-
-    @Override
-    public void onSessionInitiated(final ProviderContext session) {
-        LOG.info("StatisticsManagerActivator initialization.");
-        try {
-            final DataBroker dataBroker = session.getSALService(DataBroker.class);
-            final NotificationProviderService notifService =
-                    session.getSALService(NotificationProviderService.class);
-            statsProvider = new StatisticsManagerImpl(dataBroker, MAX_NODES_FOR_COLLECTOR);
-            statsProvider.start(notifService, session, DEFAULT_MIN_REQUEST_NET_MONITOR_INTERVAL);
-            LOG.info("StatisticsManagerActivator started successfully.");
-        }
-        catch (final Exception e) {
-            LOG.error("Unexpected error by initialization of StatisticsManagerActivator", e);
-            stopImpl(null);
-        }
-    }
-
-    @VisibleForTesting
-    StatisticsManager getStatisticManager() {
-        return statsProvider;
-    }
-
-    @Override
-    protected void stopImpl(final BundleContext context) {
-        if (statsProvider != null) {
-            try {
-                statsProvider.close();
-            }
-            catch (final Exception e) {
-                LOG.error("Unexpected error by stopping StatisticsManagerActivator", e);
-            }
-            statsProvider = null;
-        }
-        LOG.info("StatisticsManagerActivator stoped.");
-    }
-}
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatisticsManagerConfig.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatisticsManagerConfig.java
new file mode 100644 (file)
index 0000000..0f56ea9
--- /dev/null
@@ -0,0 +1,48 @@
+package org.opendaylight.controller.md.statistics.manager.impl;
+
+public class StatisticsManagerConfig {
+    private final int maxNodesForCollector;
+    private final int minRequestNetMonitorInterval;
+
+    private StatisticsManagerConfig(StatisticsManagerConfigBuilder builder) {
+        this.maxNodesForCollector = builder.getMaxNodesForCollector();
+        this.minRequestNetMonitorInterval = builder.getMinRequestNetMonitorInterval();
+    }
+
+    public int getMaxNodesForCollector() {
+        return maxNodesForCollector;
+    }
+
+    public int getMinRequestNetMonitorInterval() {
+        return minRequestNetMonitorInterval;
+    }
+
+    public static StatisticsManagerConfigBuilder builder() {
+        return new StatisticsManagerConfigBuilder();
+    }
+
+    public static class StatisticsManagerConfigBuilder {
+        private int maxNodesForCollector;
+        private int minRequestNetMonitorInterval;
+
+        public int getMaxNodesForCollector() {
+            return maxNodesForCollector;
+        }
+
+        public void setMaxNodesForCollector(int maxNodesForCollector) {
+            this.maxNodesForCollector = maxNodesForCollector;
+        }
+
+        public int getMinRequestNetMonitorInterval() {
+            return minRequestNetMonitorInterval;
+        }
+
+        public void setMinRequestNetMonitorInterval(int minRequestNetMonitorInterval) {
+            this.minRequestNetMonitorInterval = minRequestNetMonitorInterval;
+        }
+
+        public StatisticsManagerConfig build() {
+            return new StatisticsManagerConfig(this);
+        }
+    }
+}
index 396ff0e..edf9fad 100644 (file)
@@ -8,15 +8,8 @@
 
 package org.opendaylight.controller.md.statistics.manager.impl;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.LinkedBlockingDeque;
-import java.util.concurrent.ThreadFactory;
-
+import com.google.common.base.Preconditions;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
 import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
@@ -46,8 +39,14 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.LinkedBlockingDeque;
+import java.util.concurrent.ThreadFactory;
 
 /**
 * statistics-manager
@@ -73,8 +72,6 @@ public class StatisticsManagerImpl implements StatisticsManager, Runnable {
    private final BlockingQueue<StatDataStoreOperation> dataStoreOperQueue = new LinkedBlockingDeque<>(QUEUE_DEPTH);
 
    private final DataBroker dataBroker;
-   private final int maxNodesForCollectors;
-   private long minReqNetMonitInt;
    private final ExecutorService statRpcMsgManagerExecutor;
    private final ExecutorService statDataStoreOperationServ;
    private StatRpcMsgManager rpcMsgManager;
@@ -91,23 +88,24 @@ public class StatisticsManagerImpl implements StatisticsManager, Runnable {
    private StatNotifyCommiter<OpendaylightFlowTableStatisticsListener> tableNotifCommiter;
    private StatNotifyCommiter<OpendaylightPortStatisticsListener> portNotifyCommiter;
 
-   public StatisticsManagerImpl (final DataBroker dataBroker, final int maxNodesForCollector) {
+   private final StatisticsManagerConfig statManagerConfig;
+
+   public StatisticsManagerImpl (final DataBroker dataBroker, StatisticsManagerConfig statManagerconfig) {
+       this.statManagerConfig = Preconditions.checkNotNull(statManagerconfig);
        this.dataBroker = Preconditions.checkNotNull(dataBroker, "DataBroker can not be null!");
        ThreadFactory threadFact;
        threadFact = new ThreadFactoryBuilder().setNameFormat("odl-stat-rpc-oper-thread-%d").build();
        statRpcMsgManagerExecutor = Executors.newSingleThreadExecutor(threadFact);
        threadFact = new ThreadFactoryBuilder().setNameFormat("odl-stat-ds-oper-thread-%d").build();
        statDataStoreOperationServ = Executors.newSingleThreadExecutor(threadFact);
-       maxNodesForCollectors = maxNodesForCollector;
        txChain =  dataBroker.createTransactionChain(this);
    }
 
    @Override
    public void start(final NotificationProviderService notifService,
-           final RpcConsumerRegistry rpcRegistry, final long minReqNetMonitInt) {
+           final RpcConsumerRegistry rpcRegistry) {
        Preconditions.checkArgument(rpcRegistry != null, "RpcConsumerRegistry can not be null !");
-       this.minReqNetMonitInt = minReqNetMonitInt;
-       rpcMsgManager = new StatRpcMsgManagerImpl(this, rpcRegistry, minReqNetMonitInt);
+       rpcMsgManager = new StatRpcMsgManagerImpl(this, rpcRegistry, statManagerConfig.getMinRequestNetMonitorInterval());
        statCollectors = Collections.emptyList();
        nodeRegistrator = new StatNodeRegistrationImpl(this, dataBroker, notifService);
        flowListeningCommiter = new StatListenCommitFlow(this, dataBroker, notifService);
@@ -272,7 +270,8 @@ public class StatisticsManagerImpl implements StatisticsManager, Runnable {
                }
            }
            final StatPermCollectorImpl newCollector = new StatPermCollectorImpl(this,
-                   minReqNetMonitInt, statCollectors.size() + 1, maxNodesForCollectors);
+                   statManagerConfig.getMinRequestNetMonitorInterval(), statCollectors.size() + 1,
+                   statManagerConfig.getMaxNodesForCollector());
            final List<StatPermCollector> statCollectorsNew = new ArrayList<>(statCollectors);
            newCollector.connectedNodeRegistration(nodeIdent, statTypes, nrOfSwitchTables);
            statCollectorsNew.add(newCollector);
@@ -355,5 +354,10 @@ public class StatisticsManagerImpl implements StatisticsManager, Runnable {
    public StatNotifyCommiter<OpendaylightPortStatisticsListener> getPortNotifyCommit() {
        return portNotifyCommiter;
    }
+
+    @Override
+    public StatisticsManagerConfig getConfiguration() {
+        return statManagerConfig;
+    }
 }
 
diff --git a/opendaylight/md-sal/statistics-manager/src/main/yang/statistics-manager.yang b/opendaylight/md-sal/statistics-manager/src/main/yang/statistics-manager.yang
new file mode 100644 (file)
index 0000000..5f35f70
--- /dev/null
@@ -0,0 +1,66 @@
+module statistics-manager {
+
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:statistics-manager";
+    prefix "statistics-manager";
+
+    import config { prefix config; revision-date 2013-04-05; }
+    import opendaylight-md-sal-binding { prefix mdsal; revision-date 2013-10-28; }
+
+    description
+        "This module contains the base YANG definitions for
+        statitics-manager implementation.";
+
+    revision "2014-09-25" {
+        description
+            "Initial revision.";
+    }
+
+    identity statistics-manager {
+            base config:module-type;
+            config:java-name-prefix StatisticsManager;
+    }
+
+    augment "/config:modules/config:module/config:configuration" {
+        case statistics-manager {
+            when "/config:modules/config:module/config:type = 'statistics-manager'";
+
+            container rpc-registry {
+                uses config:service-ref {
+                    refine type {
+                        mandatory true;
+                        config:required-identity mdsal:binding-rpc-registry;
+                    }
+                }
+            }
+
+            container notification-service {
+                uses config:service-ref {
+                    refine type {
+                        mandatory true;
+                        config:required-identity mdsal:binding-notification-service;
+                    }
+                }
+            }
+
+            container data-broker {
+                uses config:service-ref {
+                    refine type {
+                        mandatory false;
+                        config:required-identity mdsal:binding-async-data-broker;
+                    }
+                }
+            }
+
+            container statistics-manager-settings {
+                leaf min-request-net-monitor-interval {
+                    type int32;
+                }
+                leaf max-nodes-for-collector {
+                    type int32;
+                }
+            }
+        }
+    }
+
+}
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/org/opendaylight/controller/md/statistics/manager/StatisticsManagerProvider.java b/opendaylight/md-sal/statistics-manager/src/test/java/org/opendaylight/controller/md/statistics/manager/StatisticsManagerProvider.java
deleted file mode 100644 (file)
index 6a01cd2..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.controller.md.statistics.manager;
-
-/**
- * statistics-manager
- * org.opendaylight.controller.md.statistics.manager
- *
- *
- *
- * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
- *
- * Created: Sep 6, 2014
- */
-public class StatisticsManagerProvider {
-
-    private final StatisticsManagerActivator activator;
-
-    public StatisticsManagerProvider(final StatisticsManagerActivator activator) {
-        this.activator = activator;
-    }
-
-    /**
-     * Method provides Initialized {@link StatisticsManager}
-     * from {@link StatisticsManagerActivator} for all tests
-     * suites;
-     *
-     * @return
-     */
-    public StatisticsManager getStatisticsManager() {
-        return activator.getStatisticManager();
-    }
-}
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/FlowStatisticsTest.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/FlowStatisticsTest.java
deleted file mode 100644 (file)
index 7fc171c..0000000
+++ /dev/null
@@ -1,159 +0,0 @@
-package test.mock;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Collections;
-import java.util.concurrent.ExecutionException;
-
-import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.md.statistics.manager.StatisticsManagerActivator;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowFeatureCapabilityFlowStats;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowStatisticsData;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-import test.mock.util.StatisticsManagerTest;
-
-import com.google.common.base.Optional;
-
-public class FlowStatisticsTest extends StatisticsManagerTest {
-    private final Object waitObject = new Object();
-
-//    @Test(timeout = 5000)
-    public void addedFlowOnDemandStatsTest() throws ExecutionException, InterruptedException, ReadFailedException {
-        final StatisticsManagerActivator activator = new StatisticsManagerActivator();
-        activator.onSessionInitiated(providerContext);
-
-        addFlowCapableNode(s1Key);
-
-        final Flow flow = getFlow();
-
-        final InstanceIdentifier<Flow> flowII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
-                .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(flow.getTableId()))
-                .child(Flow.class, flow.getKey());
-        final InstanceIdentifier<Table> tableII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
-                .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(flow.getTableId()));
-        final Table table = new TableBuilder().setKey(new TableKey(flow.getTableId())).setFlow(Collections.<Flow>emptyList()).build();
-
-        final WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
-        writeTx.put(LogicalDatastoreType.CONFIGURATION, tableII, table);
-        writeTx.put(LogicalDatastoreType.CONFIGURATION, flowII, flow);
-        writeTx.put(LogicalDatastoreType.OPERATIONAL, tableII, table);
-        writeTx.put(LogicalDatastoreType.OPERATIONAL, flowII, flow);
-        assertCommit(writeTx.submit());
-
-        getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
-                flowII.augmentation(FlowStatisticsData.class), new ChangeListener(), AsyncDataBroker.DataChangeScope.BASE);
-
-        synchronized (waitObject) {
-            waitObject.wait();
-        }
-
-        final ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
-        final Optional<FlowStatisticsData> flowStatDataOptional = readTx.read(LogicalDatastoreType.OPERATIONAL, flowII.augmentation(FlowStatisticsData.class))
-                .checkedGet();
-        assertTrue(flowStatDataOptional.isPresent());
-        assertEquals(COUNTER_64_TEST_VALUE, flowStatDataOptional.get().getFlowStatistics().getByteCount());
-
-    }
-
-//    @Test(timeout = 5000)
-    public void deletedFlowStatsRemovalTest() throws ExecutionException, InterruptedException, ReadFailedException {
-        final StatisticsManagerActivator activator = new StatisticsManagerActivator();
-        activator.onSessionInitiated(providerContext);
-
-        addFlowCapableNode(s1Key);
-
-        final Flow flow = getFlow();
-
-        final InstanceIdentifier<Flow> flowII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
-                .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(flow.getTableId()))
-                .child(Flow.class, flow.getKey());
-        final InstanceIdentifier<Table> tableII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
-                .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(flow.getTableId()));
-        final Table table = new TableBuilder().setKey(new TableKey(flow.getTableId())).setFlow(Collections.<Flow>emptyList()).build();
-
-        WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
-        writeTx.put(LogicalDatastoreType.CONFIGURATION, tableII, table);
-        writeTx.put(LogicalDatastoreType.CONFIGURATION, flowII, flow);
-        writeTx.put(LogicalDatastoreType.OPERATIONAL, tableII, table);
-        writeTx.put(LogicalDatastoreType.OPERATIONAL, flowII, flow);
-
-        getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
-                flowII.augmentation(FlowStatisticsData.class), new ChangeListener(), AsyncDataBroker.DataChangeScope.BASE);
-
-        assertCommit(writeTx.submit());
-
-        synchronized (waitObject) {
-            waitObject.wait();
-        }
-
-        ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
-        Optional<Flow> flowStatDataOptional = readTx.read(LogicalDatastoreType.OPERATIONAL, flowII).checkedGet();
-        assertTrue(flowStatDataOptional.isPresent());
-//        assertEquals(COUNTER_64_TEST_VALUE, flowStatDataOptional.get().getFlowStatistics().getByteCount());
-
-        writeTx = getDataBroker().newWriteOnlyTransaction();
-        writeTx.delete(LogicalDatastoreType.CONFIGURATION, flowII);
-        assertCommit(writeTx.submit());
-
-        readTx = getDataBroker().newReadOnlyTransaction();
-        flowStatDataOptional = readTx.read(LogicalDatastoreType.OPERATIONAL, flowII).checkedGet();
-        assertFalse(flowStatDataOptional.isPresent());
-    }
-
-//    @Test(timeout = 23000)
-    public void getAllStatsWhenNodeIsConnectedTest() throws ExecutionException, InterruptedException, ReadFailedException {
-        final StatisticsManagerActivator activator = new StatisticsManagerActivator();
-        activator.onSessionInitiated(providerContext);
-
-        addFlowCapableNodeWithFeatures(s1Key, false, FlowFeatureCapabilityFlowStats.class);
-
-        final Flow flow = getFlow();
-
-        final InstanceIdentifier<Table> tableII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
-                .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(flow.getTableId()));
-
-        getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
-                tableII.child(Flow.class), new ChangeListener(), AsyncDataBroker.DataChangeScope.BASE);
-
-        synchronized (waitObject) {
-            waitObject.wait();
-        }
-
-        final ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
-        final Optional<Table> tableOptional = readTx.read(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Nodes.class)
-                .child(Node.class, s1Key).augmentation(FlowCapableNode.class)
-                .child(Table.class, new TableKey(flow.getTableId()))).checkedGet();
-        assertTrue(tableOptional.isPresent());
-        final FlowStatisticsData flowStats = tableOptional.get().getFlow().get(0).getAugmentation(FlowStatisticsData.class);
-        assertTrue(flowStats != null);
-        assertEquals(COUNTER_64_TEST_VALUE, flowStats.getFlowStatistics().getByteCount());
-    }
-
-    public class ChangeListener implements DataChangeListener {
-
-        @Override
-        public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
-            synchronized (waitObject) {
-                waitObject.notify();
-            }
-        }
-    }
-}
-
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/GroupStatisticsTest.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/GroupStatisticsTest.java
deleted file mode 100644 (file)
index 7a61bf2..0000000
+++ /dev/null
@@ -1,151 +0,0 @@
-package test.mock;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.concurrent.ExecutionException;
-
-import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.md.statistics.manager.StatisticsManagerActivator;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowFeatureCapabilityGroupStats;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupDescStats;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupFeatures;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupStatistics;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.features.GroupFeatures;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-import test.mock.util.StatisticsManagerTest;
-
-import com.google.common.base.Optional;
-
-public class GroupStatisticsTest extends StatisticsManagerTest {
-    private final Object waitObject = new Object();
-
-//    @Test(timeout = 5000)
-    public void addedGroupOnDemandStatsTest() throws ExecutionException, InterruptedException, ReadFailedException {
-        final StatisticsManagerActivator activator = new StatisticsManagerActivator();
-        activator.onSessionInitiated(providerContext);
-
-        addFlowCapableNode(s1Key);
-
-        final Group group = getGroup();
-
-        final InstanceIdentifier<Group> groupII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
-                .augmentation(FlowCapableNode.class).child(Group.class, group.getKey());
-
-        final WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
-        writeTx.put(LogicalDatastoreType.CONFIGURATION, groupII, group);
-        writeTx.put(LogicalDatastoreType.OPERATIONAL, groupII, group);
-        assertCommit(writeTx.submit());
-
-        getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
-                groupII.augmentation(NodeGroupStatistics.class), new ChangeListener(), AsyncDataBroker.DataChangeScope.BASE);
-
-        synchronized (waitObject) {
-            waitObject.wait();
-        }
-
-        final ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
-        final Optional<NodeGroupStatistics> groupOptional = readTx.read(LogicalDatastoreType.OPERATIONAL, groupII.augmentation(NodeGroupStatistics.class)).checkedGet();
-        assertTrue(groupOptional.isPresent());
-        assertEquals(COUNTER_64_TEST_VALUE, groupOptional.get().getGroupStatistics().getByteCount());
-    }
-
-//    @Test(timeout = 5000)
-    public void deletedGroupStasRemovalTest() throws ExecutionException, InterruptedException, ReadFailedException {
-        final StatisticsManagerActivator activator = new StatisticsManagerActivator();
-        activator.onSessionInitiated(providerContext);
-
-        addFlowCapableNode(s1Key);
-
-        final Group group = getGroup();
-        final InstanceIdentifier<Group> groupII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
-                .augmentation(FlowCapableNode.class).child(Group.class, group.getKey());
-
-        WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
-        writeTx.put(LogicalDatastoreType.CONFIGURATION, groupII, group);
-        writeTx.put(LogicalDatastoreType.OPERATIONAL, groupII, group);
-        assertCommit(writeTx.submit());
-
-        getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
-                groupII.augmentation(NodeGroupStatistics.class), new ChangeListener(), AsyncDataBroker.DataChangeScope.BASE);
-
-        synchronized (waitObject) {
-            waitObject.wait();
-        }
-
-        ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
-        Optional<NodeGroupStatistics> groupOptional = readTx.read(LogicalDatastoreType.OPERATIONAL,
-                groupII.augmentation(NodeGroupStatistics.class)).checkedGet();
-        assertTrue(groupOptional.isPresent());
-        assertEquals(COUNTER_64_TEST_VALUE, groupOptional.get().getGroupStatistics().getByteCount());
-
-        writeTx = getDataBroker().newWriteOnlyTransaction();
-        writeTx.delete(LogicalDatastoreType.CONFIGURATION, groupII);
-        assertCommit(writeTx.submit());
-
-        readTx = getDataBroker().newReadOnlyTransaction();
-        groupOptional = readTx.read(LogicalDatastoreType.OPERATIONAL,
-                groupII.augmentation(NodeGroupStatistics.class)).checkedGet();
-        assertFalse(groupOptional.isPresent());
-
-    }
-
-//    @Test(timeout = 23000)
-    public void getAllStatsFromConnectedNodeTest() throws ExecutionException, InterruptedException {
-        final StatisticsManagerActivator activator = new StatisticsManagerActivator();
-        activator.onSessionInitiated(providerContext);
-
-        addFlowCapableNodeWithFeatures(s1Key, false, FlowFeatureCapabilityGroupStats.class);
-
-        final InstanceIdentifier<Group> groupII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
-                .augmentation(FlowCapableNode.class).child(Group.class, getGroup().getKey());
-        getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
-                groupII.augmentation(NodeGroupStatistics.class), new ChangeListener(), AsyncDataBroker.DataChangeScope.BASE);
-
-        synchronized (waitObject) {
-            waitObject.wait();
-        }
-
-        ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
-        final Optional<Group> optionalGroup = readTx.read(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Nodes.class)
-                .child(Node.class, s1Key).augmentation(FlowCapableNode.class)
-                .child(Group.class, getGroup().getKey())).get();
-
-        assertTrue(optionalGroup.isPresent());
-        assertTrue(optionalGroup.get().getAugmentation(NodeGroupDescStats.class) != null);
-        final NodeGroupStatistics groupStats = optionalGroup.get().getAugmentation(NodeGroupStatistics.class);
-        assertTrue(groupStats != null);
-        assertEquals(COUNTER_64_TEST_VALUE, groupStats.getGroupStatistics().getByteCount());
-
-        readTx = getDataBroker().newReadOnlyTransaction();
-        final Optional<GroupFeatures> optionalGroupFeatures = readTx.read(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Nodes.class)
-                .child(Node.class, s1Key).augmentation(NodeGroupFeatures.class).child(GroupFeatures.class)).get();
-        assertTrue(optionalGroupFeatures.isPresent());
-        assertEquals(1, optionalGroupFeatures.get().getMaxGroups().size());
-        assertEquals(MAX_GROUPS_TEST_VALUE, optionalGroupFeatures.get().getMaxGroups().get(0));
-    }
-
-    private class ChangeListener implements DataChangeListener {
-
-        @Override
-        public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
-            synchronized (waitObject) {
-                waitObject.notify();
-            }
-        }
-    }
-}
-
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/MeterStatisticsTest.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/MeterStatisticsTest.java
deleted file mode 100644 (file)
index a0f360c..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-package test.mock;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.concurrent.ExecutionException;
-
-import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.md.statistics.manager.StatisticsManagerActivator;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterConfigStats;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterFeatures;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterStatistics;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.nodes.node.MeterFeatures;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-import test.mock.util.StatisticsManagerTest;
-
-import com.google.common.base.Optional;
-
-public class MeterStatisticsTest extends StatisticsManagerTest {
-    private final Object waitObject = new Object();
-
-//    @Test(timeout = 5000)
-    public void addedMeterOnDemandStatsTest() throws ExecutionException, InterruptedException, ReadFailedException {
-        final StatisticsManagerActivator activator = new StatisticsManagerActivator();
-        activator.onSessionInitiated(providerContext);
-
-        addFlowCapableNode(s1Key);
-
-        final Meter meter = getMeter();
-        final InstanceIdentifier<Meter> meterII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
-                .augmentation(FlowCapableNode.class).child(Meter.class, meter.getKey());
-
-        final WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
-        writeTx.put(LogicalDatastoreType.CONFIGURATION, meterII, meter);
-        writeTx.put(LogicalDatastoreType.OPERATIONAL, meterII, meter);
-        assertCommit(writeTx.submit());
-
-        getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
-                meterII.augmentation(NodeMeterStatistics.class), new ChangeListener(), AsyncDataBroker.DataChangeScope.BASE);
-
-        synchronized (waitObject) {
-            waitObject.wait();
-        }
-
-        final ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
-        final Optional<NodeMeterStatistics> meterStatsOptional = readTx.read(LogicalDatastoreType.OPERATIONAL,
-                meterII.augmentation(NodeMeterStatistics.class)).checkedGet();
-        assertTrue(meterStatsOptional.isPresent());
-        assertEquals(COUNTER_64_TEST_VALUE, meterStatsOptional.get().getMeterStatistics().getByteInCount());
-        assertEquals(COUNTER_64_TEST_VALUE, meterStatsOptional.get().getMeterStatistics().getPacketInCount());
-    }
-
-//    @Test(timeout = 5000)
-    public void deletedMeterStatsRemovalTest() throws ExecutionException, InterruptedException, ReadFailedException {
-        final StatisticsManagerActivator activator = new StatisticsManagerActivator();
-        activator.onSessionInitiated(providerContext);
-
-        addFlowCapableNode(s1Key);
-
-        final Meter meter = getMeter();
-        final InstanceIdentifier<Meter> meterII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
-                .augmentation(FlowCapableNode.class).child(Meter.class, meter.getKey());
-
-        WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
-        writeTx.put(LogicalDatastoreType.CONFIGURATION, meterII, meter);
-        writeTx.put(LogicalDatastoreType.OPERATIONAL, meterII, meter);
-        assertCommit(writeTx.submit());
-
-        getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
-                meterII.augmentation(NodeMeterStatistics.class), new ChangeListener(), AsyncDataBroker.DataChangeScope.BASE);
-
-        synchronized (waitObject) {
-            waitObject.wait();
-        }
-
-        ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
-        final Optional<NodeMeterStatistics> meterStatsOptional = readTx.read(LogicalDatastoreType.OPERATIONAL,
-                meterII.augmentation(NodeMeterStatistics.class)).checkedGet();
-        assertTrue(meterStatsOptional.isPresent());
-        assertEquals(COUNTER_64_TEST_VALUE, meterStatsOptional.get().getMeterStatistics().getByteInCount());
-        assertEquals(COUNTER_64_TEST_VALUE, meterStatsOptional.get().getMeterStatistics().getPacketInCount());
-
-        writeTx = getDataBroker().newWriteOnlyTransaction();
-        writeTx.delete(LogicalDatastoreType.CONFIGURATION, meterII);
-        assertCommit(writeTx.submit());
-
-        readTx = getDataBroker().newReadOnlyTransaction();
-        final Optional<Meter> meterOptional = readTx.read(LogicalDatastoreType.OPERATIONAL, meterII).checkedGet();
-        assertFalse(meterOptional.isPresent());
-    }
-
-//    @Test(timeout = 23000)
-    public void getAllStatsFromConnectedNodeTest() throws ExecutionException, InterruptedException {
-        final StatisticsManagerActivator activator = new StatisticsManagerActivator();
-        activator.onSessionInitiated(providerContext);
-
-        addFlowCapableNodeWithFeatures(s1Key, true);
-
-        final InstanceIdentifier<Meter> meterII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
-                .augmentation(FlowCapableNode.class).child(Meter.class, getMeter().getKey());
-        getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
-                meterII.augmentation(NodeMeterStatistics.class), new ChangeListener(), AsyncDataBroker.DataChangeScope.BASE);
-
-        synchronized (waitObject) {
-            waitObject.wait();
-        }
-
-        ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
-        final Optional<Meter> optionalMeter = readTx.read(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Nodes.class)
-                .child(Node.class, s1Key).augmentation(FlowCapableNode.class)
-                .child(Meter.class, getMeter().getKey())).get();
-
-        assertTrue(optionalMeter.isPresent());
-        assertTrue(optionalMeter.get().getAugmentation(NodeMeterConfigStats.class) != null);
-        final NodeMeterStatistics meterStats = optionalMeter.get().getAugmentation(NodeMeterStatistics.class);
-        assertTrue(meterStats != null);
-        assertEquals(COUNTER_64_TEST_VALUE, meterStats.getMeterStatistics().getByteInCount());
-        assertEquals(COUNTER_64_TEST_VALUE, meterStats.getMeterStatistics().getPacketInCount());
-
-        readTx = getDataBroker().newReadOnlyTransaction();
-        final Optional<MeterFeatures> optionalMeterFeautures = readTx.read(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Nodes.class)
-                .child(Node.class, s1Key).augmentation(NodeMeterFeatures.class).child(MeterFeatures.class)).get();
-        assertTrue(optionalMeterFeautures.isPresent());
-        assertEquals(COUNTER_32_TEST_VALUE, optionalMeterFeautures.get().getMaxMeter());
-    }
-
-    private class ChangeListener implements DataChangeListener {
-
-        @Override
-        public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
-            synchronized (waitObject) {
-                waitObject.notify();
-            }
-        }
-    }
-}
-
index 18bd2d4..79eb236 100644 (file)
@@ -1,48 +1,43 @@
 package test.mock;
 
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.concurrent.ExecutionException;
-
-import org.opendaylight.controller.md.statistics.manager.StatisticsManagerActivator;
-import org.opendaylight.controller.md.statistics.manager.StatisticsManagerProvider;
+import org.junit.Test;
+import org.opendaylight.controller.md.statistics.manager.StatisticsManager;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
 import test.mock.util.StatisticsManagerTest;
 
+import java.util.concurrent.ExecutionException;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
 public class NodeRegistrationTest extends StatisticsManagerTest {
 
-//    @Test
+    @Test
     public void nodeRegistrationTest() throws ExecutionException, InterruptedException {
-        final StatisticsManagerActivator activator = new StatisticsManagerActivator();
-        final StatisticsManagerProvider statisticsManagerProvider = new StatisticsManagerProvider(activator);
-        activator.onSessionInitiated(providerContext);
+        StatisticsManager statisticsManager = setupStatisticsManager();
 
         addFlowCapableNode(s1Key);
-        Thread.sleep(1000);
+        Thread.sleep(2000);
         final InstanceIdentifier<Node> nodeII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key);
 
-        assertTrue(statisticsManagerProvider.getStatisticsManager().isProvidedFlowNodeActive(nodeII));
+        assertTrue(statisticsManager.isProvidedFlowNodeActive(nodeII));
     }
 
-//    @Test
+    @Test
     public void nodeUnregistrationTest() throws ExecutionException, InterruptedException {
-        final StatisticsManagerActivator activator = new StatisticsManagerActivator();
-        final StatisticsManagerProvider statisticsManagerProvider = new StatisticsManagerProvider(activator);
-        activator.onSessionInitiated(providerContext);
+        StatisticsManager statisticsManager = setupStatisticsManager();
 
         addFlowCapableNode(s1Key);
-        Thread.sleep(1000);
+        Thread.sleep(2000);
         final InstanceIdentifier<Node> nodeII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key);
 
-        assertTrue(statisticsManagerProvider.getStatisticsManager().isProvidedFlowNodeActive(nodeII));
+        assertTrue(statisticsManager.isProvidedFlowNodeActive(nodeII));
 
         removeNode(s1Key);
-        Thread.sleep(1000);
-        assertFalse(statisticsManagerProvider.getStatisticsManager().isProvidedFlowNodeActive(nodeII));
+        Thread.sleep(2000);
+        assertFalse(statisticsManager.isProvidedFlowNodeActive(nodeII));
     }
 }
 
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/PortStatisticsTest.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/PortStatisticsTest.java
deleted file mode 100644 (file)
index 9f193b0..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-package test.mock;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.util.concurrent.ExecutionException;
-
-import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.md.statistics.manager.StatisticsManagerActivator;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowFeatureCapabilityPortStats;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsData;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-import test.mock.util.StatisticsManagerTest;
-
-import com.google.common.base.Optional;
-
-public class PortStatisticsTest extends StatisticsManagerTest {
-    private final Object waitObject = new Object();
-
-//    @Test(timeout = 23000)
-    public void getPortStatisticsTest() throws ExecutionException, InterruptedException, ReadFailedException {
-        final StatisticsManagerActivator activator = new StatisticsManagerActivator();
-        activator.onSessionInitiated(providerContext);
-
-        addFlowCapableNodeWithFeatures(s1Key, false, FlowFeatureCapabilityPortStats.class);
-
-        final InstanceIdentifier<NodeConnector> nodeConnectorII = InstanceIdentifier.create(Nodes.class)
-                .child(Node.class, s1Key).child(NodeConnector.class, new NodeConnectorKey(getNodeConnectorId()));
-
-
-        getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
-                nodeConnectorII.augmentation(FlowCapableNodeConnectorStatisticsData.class),
-                                                new ChangeListener(), AsyncDataBroker.DataChangeScope.BASE);
-
-        synchronized (waitObject) {
-            waitObject.wait();
-        }
-
-        final ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
-        final Optional<FlowCapableNodeConnectorStatisticsData> flowCapableNodeConnectorStatisticsDataOptional =
-                readTx.read(LogicalDatastoreType.OPERATIONAL,
-                        nodeConnectorII.augmentation(FlowCapableNodeConnectorStatisticsData.class)).checkedGet();
-        assertTrue(flowCapableNodeConnectorStatisticsDataOptional.isPresent());
-        assertEquals(BIG_INTEGER_TEST_VALUE,
-                flowCapableNodeConnectorStatisticsDataOptional.get().getFlowCapableNodeConnectorStatistics()
-                        .getReceiveDrops());
-        assertEquals(BIG_INTEGER_TEST_VALUE,
-                flowCapableNodeConnectorStatisticsDataOptional.get().getFlowCapableNodeConnectorStatistics()
-                        .getCollisionCount());
-    }
-
-    private class ChangeListener implements DataChangeListener {
-
-        @Override
-        public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
-            synchronized (waitObject) {
-                waitObject.notify();
-            }
-        }
-    }
-}
-
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/QueueStatisticsTest.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/QueueStatisticsTest.java
deleted file mode 100644 (file)
index bb9bd21..0000000
+++ /dev/null
@@ -1,197 +0,0 @@
-package test.mock;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Collections;
-import java.util.concurrent.ExecutionException;
-
-import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.md.statistics.manager.StatisticsManagerActivator;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowFeatureCapabilityQueueStats;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.Queue;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.QueueBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.FlowCapableNodeConnectorQueueStatisticsData;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-import test.mock.util.StatisticsManagerTest;
-
-import com.google.common.base.Optional;
-
-
-public class QueueStatisticsTest extends StatisticsManagerTest {
-    private final Object waitObject = new Object();
-
-//    @Test(timeout = 5000)
-    public void addedQueueOnDemandStatsTest() throws ExecutionException, InterruptedException, ReadFailedException {
-        final StatisticsManagerActivator activator = new StatisticsManagerActivator();
-        activator.onSessionInitiated(providerContext);
-
-        addFlowCapableNode(s1Key);
-
-        final Port port = getPort();
-
-        final NodeConnectorBuilder ncBuilder = new NodeConnectorBuilder();
-        final FlowCapableNodeConnectorBuilder fcncBuilder = new FlowCapableNodeConnectorBuilder();
-        fcncBuilder.setConfiguration(port.getConfiguration());
-        fcncBuilder.setPortNumber(port.getPortNumber());
-        fcncBuilder.setQueue(Collections.<Queue>emptyList());
-        ncBuilder.setKey(new NodeConnectorKey(new NodeConnectorId("connector.1")));
-        ncBuilder.addAugmentation(FlowCapableNodeConnector.class, fcncBuilder.build());
-
-
-        final Queue queue = getQueue();
-        final InstanceIdentifier<Queue> queueII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
-                .child(NodeConnector.class, ncBuilder.getKey()).augmentation(FlowCapableNodeConnector.class)
-                .child(Queue.class, queue.getKey());
-        final InstanceIdentifier<NodeConnector> nodeConnectorII = InstanceIdentifier.create(Nodes.class)
-                .child(Node.class, s1Key).child(NodeConnector.class, ncBuilder.getKey());
-
-        final WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
-        writeTx.put(LogicalDatastoreType.CONFIGURATION, nodeConnectorII, ncBuilder.build());
-        writeTx.put(LogicalDatastoreType.CONFIGURATION, queueII, queue);
-        writeTx.put(LogicalDatastoreType.OPERATIONAL, nodeConnectorII, ncBuilder.build());
-        writeTx.put(LogicalDatastoreType.OPERATIONAL, queueII, queue);
-        assertCommit(writeTx.submit());
-
-        getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
-                queueII.augmentation(FlowCapableNodeConnectorQueueStatisticsData.class), new ChangeListener(), AsyncDataBroker.DataChangeScope.BASE);
-
-        synchronized (waitObject) {
-            waitObject.wait();
-        }
-
-        final ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
-        final Optional<FlowCapableNodeConnectorQueueStatisticsData> queueStatsOptional = readTx.read(LogicalDatastoreType.OPERATIONAL,
-                queueII.augmentation(FlowCapableNodeConnectorQueueStatisticsData.class)).checkedGet();
-        assertTrue(queueStatsOptional.isPresent());
-        assertEquals(COUNTER_64_TEST_VALUE,
-                queueStatsOptional.get().getFlowCapableNodeConnectorQueueStatistics().getTransmittedBytes());
-    }
-
-//    @Test(timeout = 5000)
-    public void deletedQueueStatsRemovalTest() throws ExecutionException, InterruptedException, ReadFailedException {
-        final StatisticsManagerActivator activator = new StatisticsManagerActivator();
-        activator.onSessionInitiated(providerContext);
-
-        addFlowCapableNode(s1Key);
-
-        final Port port = getPort();
-
-        final NodeConnectorBuilder ncBuilder = new NodeConnectorBuilder();
-        final FlowCapableNodeConnectorBuilder fcncBuilder = new FlowCapableNodeConnectorBuilder();
-        fcncBuilder.setConfiguration(port.getConfiguration());
-        fcncBuilder.setPortNumber(port.getPortNumber());
-        fcncBuilder.setQueue(Collections.<Queue>emptyList());
-        ncBuilder.setKey(new NodeConnectorKey(new NodeConnectorId("connector.1")));
-        ncBuilder.addAugmentation(FlowCapableNodeConnector.class, fcncBuilder.build());
-
-
-        final Queue queue = getQueue();
-        final InstanceIdentifier<Queue> queueII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
-                .child(NodeConnector.class, ncBuilder.getKey()).augmentation(FlowCapableNodeConnector.class)
-                .child(Queue.class, queue.getKey());
-        final InstanceIdentifier<NodeConnector> nodeConnectorII = InstanceIdentifier.create(Nodes.class)
-                .child(Node.class, s1Key).child(NodeConnector.class, ncBuilder.getKey());
-
-        WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
-        writeTx.put(LogicalDatastoreType.CONFIGURATION, nodeConnectorII, ncBuilder.build());
-        writeTx.put(LogicalDatastoreType.CONFIGURATION, queueII, queue);
-        writeTx.put(LogicalDatastoreType.OPERATIONAL, nodeConnectorII, ncBuilder.build());
-        writeTx.put(LogicalDatastoreType.OPERATIONAL, queueII, queue);
-        assertCommit(writeTx.submit());
-
-        getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
-                queueII.augmentation(FlowCapableNodeConnectorQueueStatisticsData.class),
-                                        new ChangeListener(), AsyncDataBroker.DataChangeScope.BASE);
-
-        synchronized (waitObject) {
-            waitObject.wait();
-        }
-
-        ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
-        Optional<FlowCapableNodeConnectorQueueStatisticsData> queueStatsOptional = readTx.read(LogicalDatastoreType.OPERATIONAL,
-                queueII.augmentation(FlowCapableNodeConnectorQueueStatisticsData.class)).checkedGet();
-        assertTrue(queueStatsOptional.isPresent());
-        assertEquals(COUNTER_64_TEST_VALUE,
-                queueStatsOptional.get().getFlowCapableNodeConnectorQueueStatistics().getTransmittedBytes());
-
-        writeTx = getDataBroker().newWriteOnlyTransaction();
-        writeTx.delete(LogicalDatastoreType.CONFIGURATION, queueII);
-        assertCommit(writeTx.submit());
-
-        readTx = getDataBroker().newReadOnlyTransaction();
-        queueStatsOptional = readTx.read(LogicalDatastoreType.OPERATIONAL,
-                queueII.augmentation(FlowCapableNodeConnectorQueueStatisticsData.class)).checkedGet();
-        assertFalse(queueStatsOptional.isPresent());
-    }
-
-//    @Test(timeout = 23000)
-    public void getAllStatsFromConnectedNodeTest() throws ExecutionException, InterruptedException, ReadFailedException {
-        final StatisticsManagerActivator activator = new StatisticsManagerActivator();
-        activator.onSessionInitiated(providerContext);
-
-        addFlowCapableNodeWithFeatures(s1Key, false, FlowFeatureCapabilityQueueStats.class);
-
-        final NodeConnectorBuilder ncBuilder = new NodeConnectorBuilder();
-        final FlowCapableNodeConnectorBuilder fcncBuilder = new FlowCapableNodeConnectorBuilder();
-        ncBuilder.setKey(new NodeConnectorKey(getNodeConnectorId()));
-        ncBuilder.addAugmentation(FlowCapableNodeConnector.class, fcncBuilder.build());
-
-        final InstanceIdentifier<NodeConnector> nodeConnectorII = InstanceIdentifier.create(Nodes.class)
-                .child(Node.class, s1Key)
-                .child(NodeConnector.class, ncBuilder.getKey());
-
-        final WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
-        writeTx.put(LogicalDatastoreType.OPERATIONAL, nodeConnectorII, ncBuilder.build());
-        final InstanceIdentifier<Queue> queueII = nodeConnectorII.augmentation(FlowCapableNodeConnector.class)
-                .child(Queue.class, getQueue().getKey());
-        final QueueBuilder qBuilder = new QueueBuilder(getQueue());
-        writeTx.put(LogicalDatastoreType.OPERATIONAL, queueII, qBuilder.build());
-        assertCommit(writeTx.submit());
-
-        getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
-                queueII.augmentation(FlowCapableNodeConnectorQueueStatisticsData.class), new ChangeListener(), AsyncDataBroker.DataChangeScope.BASE);
-
-        synchronized (waitObject) {
-            waitObject.wait();
-        }
-
-        final ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
-        final Optional<Queue> queueOptional = readTx.read(LogicalDatastoreType.OPERATIONAL, queueII).checkedGet();
-        assertTrue(queueOptional.isPresent());
-        final FlowCapableNodeConnectorQueueStatisticsData queueStats =
-                queueOptional.get().getAugmentation(FlowCapableNodeConnectorQueueStatisticsData.class);
-        assertTrue(queueStats != null);
-        assertEquals(COUNTER_64_TEST_VALUE,
-                queueStats.getFlowCapableNodeConnectorQueueStatistics().getTransmittedBytes());
-    }
-
-    private class ChangeListener implements DataChangeListener {
-
-        @Override
-        public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
-            synchronized (waitObject) {
-                waitObject.notify();
-            }
-        }
-    }
-}
-
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/StatCollectorTest.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/StatCollectorTest.java
new file mode 100644 (file)
index 0000000..48a993e
--- /dev/null
@@ -0,0 +1,298 @@
+package test.mock;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import com.google.common.base.Optional;
+import java.util.concurrent.ExecutionException;
+import org.junit.Test;
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowFeatureCapabilityFlowStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowFeatureCapabilityGroupStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowFeatureCapabilityPortStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowFeatureCapabilityQueueStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowFeatureCapabilityTableStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowStatisticsData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.Queue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.QueueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupDescStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupStatistics;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.features.GroupFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterConfigStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterStatistics;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.nodes.node.MeterFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.FlowCapableNodeConnectorQueueStatisticsData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import test.mock.util.StatisticsManagerTest;
+
+public class StatCollectorTest extends StatisticsManagerTest {
+    private final Object waitObject = new Object();
+
+    @Test(timeout = 200000)
+    public void getAllFlowStatsTest() throws ExecutionException, InterruptedException, ReadFailedException {
+        setupStatisticsManager();
+
+        addFlowCapableNodeWithFeatures(s1Key, false, FlowFeatureCapabilityFlowStats.class);
+
+        final Flow flow = getFlow();
+
+        final InstanceIdentifier<Table> tableII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+                .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(flow.getTableId()));
+
+        getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
+                tableII.child(Flow.class), new ChangeListener(), AsyncDataBroker.DataChangeScope.BASE);
+
+        synchronized (waitObject) {
+            waitObject.wait();
+        }
+
+        final ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
+        final Optional<Table> tableOptional = readTx.read(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Nodes.class)
+                .child(Node.class, s1Key).augmentation(FlowCapableNode.class)
+                .child(Table.class, new TableKey(flow.getTableId()))).checkedGet();
+        assertTrue(tableOptional.isPresent());
+        final FlowStatisticsData flowStats = tableOptional.get().getFlow().get(0).getAugmentation(FlowStatisticsData.class);
+        assertTrue(flowStats != null);
+        assertEquals(COUNTER_64_TEST_VALUE, flowStats.getFlowStatistics().getByteCount());
+    }
+
+    @Test(timeout = 200000)
+    public void getAllGroupStatsFeatureNotAdvertisedTest() throws ExecutionException, InterruptedException {
+        setupStatisticsManager();
+
+        addFlowCapableNodeWithFeatures(s1Key, true);
+
+        final InstanceIdentifier<Group> groupII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+                .augmentation(FlowCapableNode.class).child(Group.class, getGroup().getKey());
+        getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
+                groupII.augmentation(NodeGroupStatistics.class), new ChangeListener(), AsyncDataBroker.DataChangeScope.BASE);
+
+        synchronized (waitObject) {
+            waitObject.wait();
+        }
+
+        ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
+        final Optional<Group> optionalGroup = readTx.read(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Nodes.class)
+                .child(Node.class, s1Key).augmentation(FlowCapableNode.class)
+                .child(Group.class, getGroup().getKey())).get();
+
+        assertTrue(optionalGroup.isPresent());
+        assertTrue(optionalGroup.get().getAugmentation(NodeGroupDescStats.class) != null);
+        final NodeGroupStatistics groupStats = optionalGroup.get().getAugmentation(NodeGroupStatistics.class);
+        assertTrue(groupStats != null);
+        assertEquals(COUNTER_64_TEST_VALUE, groupStats.getGroupStatistics().getByteCount());
+
+        readTx = getDataBroker().newReadOnlyTransaction();
+        final Optional<GroupFeatures> optionalGroupFeatures = readTx.read(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Nodes.class)
+                .child(Node.class, s1Key).augmentation(NodeGroupFeatures.class).child(GroupFeatures.class)).get();
+        assertTrue(optionalGroupFeatures.isPresent());
+        assertEquals(1, optionalGroupFeatures.get().getMaxGroups().size());
+        assertEquals(MAX_GROUPS_TEST_VALUE, optionalGroupFeatures.get().getMaxGroups().get(0));
+    }
+
+    @Test(timeout = 200000)
+    public void getAllGroupStatsFeatureAdvertisedTest() throws ExecutionException, InterruptedException {
+        setupStatisticsManager();
+
+        addFlowCapableNodeWithFeatures(s1Key, false, FlowFeatureCapabilityGroupStats.class);
+
+        final InstanceIdentifier<Group> groupII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+                .augmentation(FlowCapableNode.class).child(Group.class, getGroup().getKey());
+        getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
+                groupII.augmentation(NodeGroupStatistics.class), new ChangeListener(), AsyncDataBroker.DataChangeScope.BASE);
+
+        synchronized (waitObject) {
+            waitObject.wait();
+        }
+
+        ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
+        final Optional<Group> optionalGroup = readTx.read(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Nodes.class)
+                .child(Node.class, s1Key).augmentation(FlowCapableNode.class)
+                .child(Group.class, getGroup().getKey())).get();
+
+        assertTrue(optionalGroup.isPresent());
+        assertTrue(optionalGroup.get().getAugmentation(NodeGroupDescStats.class) != null);
+        final NodeGroupStatistics groupStats = optionalGroup.get().getAugmentation(NodeGroupStatistics.class);
+        assertTrue(groupStats != null);
+        assertEquals(COUNTER_64_TEST_VALUE, groupStats.getGroupStatistics().getByteCount());
+
+        readTx = getDataBroker().newReadOnlyTransaction();
+        final Optional<GroupFeatures> optionalGroupFeatures = readTx.read(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Nodes.class)
+                .child(Node.class, s1Key).augmentation(NodeGroupFeatures.class).child(GroupFeatures.class)).get();
+        assertTrue(optionalGroupFeatures.isPresent());
+        assertEquals(1, optionalGroupFeatures.get().getMaxGroups().size());
+        assertEquals(MAX_GROUPS_TEST_VALUE, optionalGroupFeatures.get().getMaxGroups().get(0));
+    }
+
+    @Test(timeout = 200000)
+    public void getAllMeterStatsTest() throws ExecutionException, InterruptedException {
+        setupStatisticsManager();
+
+        addFlowCapableNodeWithFeatures(s1Key, true);
+
+        final InstanceIdentifier<Meter> meterII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+                .augmentation(FlowCapableNode.class).child(Meter.class, getMeter().getKey());
+        getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
+                meterII.augmentation(NodeMeterStatistics.class), new ChangeListener(), AsyncDataBroker.DataChangeScope.BASE);
+
+        synchronized (waitObject) {
+            waitObject.wait();
+        }
+
+        ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
+        final Optional<Meter> optionalMeter = readTx.read(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Nodes.class)
+                .child(Node.class, s1Key).augmentation(FlowCapableNode.class)
+                .child(Meter.class, getMeter().getKey())).get();
+
+        assertTrue(optionalMeter.isPresent());
+        assertTrue(optionalMeter.get().getAugmentation(NodeMeterConfigStats.class) != null);
+        final NodeMeterStatistics meterStats = optionalMeter.get().getAugmentation(NodeMeterStatistics.class);
+        assertTrue(meterStats != null);
+        assertEquals(COUNTER_64_TEST_VALUE, meterStats.getMeterStatistics().getByteInCount());
+        assertEquals(COUNTER_64_TEST_VALUE, meterStats.getMeterStatistics().getPacketInCount());
+
+        readTx = getDataBroker().newReadOnlyTransaction();
+        final Optional<MeterFeatures> optionalMeterFeautures = readTx.read(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Nodes.class)
+                .child(Node.class, s1Key).augmentation(NodeMeterFeatures.class).child(MeterFeatures.class)).get();
+        assertTrue(optionalMeterFeautures.isPresent());
+        assertEquals(COUNTER_32_TEST_VALUE, optionalMeterFeautures.get().getMaxMeter());
+    }
+
+    @Test(timeout = 200000)
+    public void getAllQueueStatsTest() throws ExecutionException, InterruptedException, ReadFailedException {
+        setupStatisticsManager();
+
+        addFlowCapableNodeWithFeatures(s1Key, false, FlowFeatureCapabilityQueueStats.class);
+
+        final NodeConnectorBuilder ncBuilder = new NodeConnectorBuilder();
+        final FlowCapableNodeConnectorBuilder fcncBuilder = new FlowCapableNodeConnectorBuilder();
+        ncBuilder.setKey(new NodeConnectorKey(getNodeConnectorId()));
+        ncBuilder.addAugmentation(FlowCapableNodeConnector.class, fcncBuilder.build());
+
+        final InstanceIdentifier<NodeConnector> nodeConnectorII = InstanceIdentifier.create(Nodes.class)
+                .child(Node.class, s1Key)
+                .child(NodeConnector.class, ncBuilder.getKey());
+
+        final WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
+        writeTx.put(LogicalDatastoreType.OPERATIONAL, nodeConnectorII, ncBuilder.build());
+        final InstanceIdentifier<Queue> queueII = nodeConnectorII.augmentation(FlowCapableNodeConnector.class)
+                .child(Queue.class, getQueue().getKey());
+        final QueueBuilder qBuilder = new QueueBuilder(getQueue());
+        writeTx.put(LogicalDatastoreType.OPERATIONAL, queueII, qBuilder.build());
+        assertCommit(writeTx.submit());
+
+        getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
+                queueII.augmentation(FlowCapableNodeConnectorQueueStatisticsData.class), new ChangeListener(), AsyncDataBroker.DataChangeScope.BASE);
+
+        synchronized (waitObject) {
+            waitObject.wait();
+        }
+
+        final ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
+        final Optional<Queue> queueOptional = readTx.read(LogicalDatastoreType.OPERATIONAL, queueII).checkedGet();
+        assertTrue(queueOptional.isPresent());
+        final FlowCapableNodeConnectorQueueStatisticsData queueStats =
+                queueOptional.get().getAugmentation(FlowCapableNodeConnectorQueueStatisticsData.class);
+        assertTrue(queueStats != null);
+        assertEquals(COUNTER_64_TEST_VALUE,
+                queueStats.getFlowCapableNodeConnectorQueueStatistics().getTransmittedBytes());
+    }
+
+    @Test(timeout = 200000)
+    public void getAllPortStatsTest() throws ExecutionException, InterruptedException, ReadFailedException {
+        setupStatisticsManager();
+
+        addFlowCapableNodeWithFeatures(s1Key, false, FlowFeatureCapabilityPortStats.class);
+
+        final InstanceIdentifier<NodeConnector> nodeConnectorII = InstanceIdentifier.create(Nodes.class)
+                .child(Node.class, s1Key).child(NodeConnector.class, new NodeConnectorKey(getNodeConnectorId()));
+
+        NodeConnectorBuilder ncBuilder = new NodeConnectorBuilder();
+        ncBuilder.setKey(new NodeConnectorKey(getNodeConnectorId()));
+        WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
+        writeTx.put(LogicalDatastoreType.OPERATIONAL, nodeConnectorII, ncBuilder.build());
+        assertCommit(writeTx.submit());
+
+        getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
+                nodeConnectorII.augmentation(FlowCapableNodeConnectorStatisticsData.class),
+                new ChangeListener(), AsyncDataBroker.DataChangeScope.BASE);
+
+        synchronized (waitObject) {
+            waitObject.wait();
+        }
+
+        final ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
+        final Optional<FlowCapableNodeConnectorStatisticsData> flowCapableNodeConnectorStatisticsDataOptional =
+                readTx.read(LogicalDatastoreType.OPERATIONAL,
+                        nodeConnectorII.augmentation(FlowCapableNodeConnectorStatisticsData.class)).checkedGet();
+        assertTrue(flowCapableNodeConnectorStatisticsDataOptional.isPresent());
+        assertEquals(BIG_INTEGER_TEST_VALUE,
+                flowCapableNodeConnectorStatisticsDataOptional.get().getFlowCapableNodeConnectorStatistics()
+                        .getReceiveDrops());
+        assertEquals(BIG_INTEGER_TEST_VALUE,
+                flowCapableNodeConnectorStatisticsDataOptional.get().getFlowCapableNodeConnectorStatistics()
+                        .getCollisionCount());
+    }
+
+    @Test(timeout = 200000)
+    public void getAllTableStatsTest() throws ExecutionException, InterruptedException, ReadFailedException {
+        setupStatisticsManager();
+
+        addFlowCapableNodeWithFeatures(s1Key, false, FlowFeatureCapabilityTableStats.class);
+
+        final TableId tableId = getTableId();
+        final InstanceIdentifier<Table> tableII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+                .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tableId.getValue()));
+
+        getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
+                tableII.augmentation(FlowTableStatisticsData.class), new ChangeListener(), AsyncDataBroker.DataChangeScope.BASE);
+
+        synchronized (waitObject) {
+            waitObject.wait();
+        }
+
+        final ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
+        final Optional<FlowTableStatisticsData> flowTableStatisticsDataOptional = readTx.read(
+                LogicalDatastoreType.OPERATIONAL, tableII.augmentation(FlowTableStatisticsData.class)).checkedGet();
+        assertTrue(flowTableStatisticsDataOptional.isPresent());
+        assertEquals(COUNTER_32_TEST_VALUE,
+                flowTableStatisticsDataOptional.get().getFlowTableStatistics().getActiveFlows());
+        assertEquals(COUNTER_64_TEST_VALUE,
+                flowTableStatisticsDataOptional.get().getFlowTableStatistics().getPacketsLookedUp());
+    }
+
+    public class ChangeListener implements DataChangeListener {
+
+        @Override
+        public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
+            synchronized (waitObject) {
+                waitObject.notify();
+            }
+        }
+    }
+}
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/TableStatisticsTest.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/TableStatisticsTest.java
deleted file mode 100644 (file)
index f0c0fed..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-package test.mock;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.util.concurrent.ExecutionException;
-
-import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.md.statistics.manager.StatisticsManagerActivator;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowFeatureCapabilityTableStats;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsData;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-import test.mock.util.StatisticsManagerTest;
-
-import com.google.common.base.Optional;
-
-public class TableStatisticsTest extends StatisticsManagerTest {
-    private final Object waitObject = new Object();
-
-//    @Test(timeout = 23000)
-    public void getTableStatisticsTest() throws ExecutionException, InterruptedException, ReadFailedException {
-        final StatisticsManagerActivator activator = new StatisticsManagerActivator();
-        activator.onSessionInitiated(providerContext);
-
-        addFlowCapableNodeWithFeatures(s1Key, false, FlowFeatureCapabilityTableStats.class);
-
-        final TableId tableId = getTableId();
-        final InstanceIdentifier<Table> tableII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
-                .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tableId.getValue()));
-
-        getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
-                tableII.augmentation(FlowTableStatisticsData.class), new ChangeListener(), AsyncDataBroker.DataChangeScope.BASE);
-
-        synchronized (waitObject) {
-            waitObject.wait();
-        }
-
-        final ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
-        final Optional<FlowTableStatisticsData> flowTableStatisticsDataOptional = readTx.read(
-                LogicalDatastoreType.OPERATIONAL, tableII.augmentation(FlowTableStatisticsData.class)).checkedGet();
-        assertTrue(flowTableStatisticsDataOptional.isPresent());
-        assertEquals(COUNTER_32_TEST_VALUE,
-                flowTableStatisticsDataOptional.get().getFlowTableStatistics().getActiveFlows());
-        assertEquals(COUNTER_64_TEST_VALUE,
-                flowTableStatisticsDataOptional.get().getFlowTableStatistics().getPacketsLookedUp());
-    }
-
-    private class ChangeListener implements DataChangeListener {
-
-        @Override
-        public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
-            synchronized (waitObject) {
-                waitObject.notify();
-            }
-        }
-    }
-}
-
index 2628bb9..f483881 100644 (file)
@@ -1,6 +1,10 @@
 package test.mock.util;
 
 import com.google.common.util.concurrent.Futures;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Future;
 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.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput;
@@ -27,15 +31,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.Future;
-import java.util.concurrent.atomic.AtomicLong;
-
 public class OpendaylightFlowStatisticsServiceMock implements OpendaylightFlowStatisticsService {
     NotificationProviderServiceHelper notifService;
-    AtomicLong transNum = new AtomicLong();
 
     public OpendaylightFlowStatisticsServiceMock(NotificationProviderServiceHelper notifService) {
         this.notifService = notifService;
@@ -44,7 +41,7 @@ public class OpendaylightFlowStatisticsServiceMock implements OpendaylightFlowSt
     @Override
     public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> getAggregateFlowStatisticsFromFlowTableForAllFlows(GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input) {
         GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder builder = new GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder();
-        TransactionId transId = new TransactionId(BigInteger.valueOf(transNum.incrementAndGet()));
+        TransactionId transId = new TransactionId(BigInteger.valueOf(TestUtils.getNewTransactionId()));
         builder.setTransactionId(transId);
         return Futures.immediateFuture(RpcResultBuilder.success(builder.build()).build());
     }
@@ -52,7 +49,7 @@ public class OpendaylightFlowStatisticsServiceMock implements OpendaylightFlowSt
     @Override
     public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> getAggregateFlowStatisticsFromFlowTableForGivenMatch(GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input) {
         GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder builder = new GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder();
-        TransactionId transId = new TransactionId(BigInteger.valueOf(transNum.incrementAndGet()));
+        TransactionId transId = new TransactionId(BigInteger.valueOf(TestUtils.getNewTransactionId()));
         builder.setTransactionId(transId);
         AggregateFlowStatisticsUpdateBuilder afsuBuilder = new AggregateFlowStatisticsUpdateBuilder();
         afsuBuilder.setMoreReplies(false);
@@ -66,7 +63,7 @@ public class OpendaylightFlowStatisticsServiceMock implements OpendaylightFlowSt
     @Override
     public Future<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> getAllFlowStatisticsFromFlowTable(GetAllFlowStatisticsFromFlowTableInput input) {
         GetAllFlowStatisticsFromFlowTableOutputBuilder builder = new GetAllFlowStatisticsFromFlowTableOutputBuilder();
-        TransactionId transId = new TransactionId(BigInteger.valueOf(transNum.incrementAndGet()));
+        TransactionId transId = new TransactionId(BigInteger.valueOf(TestUtils.getNewTransactionId()));
         builder.setTransactionId(transId);
         return Futures.immediateFuture(RpcResultBuilder.success(builder.build()).build());
     }
@@ -74,7 +71,7 @@ public class OpendaylightFlowStatisticsServiceMock implements OpendaylightFlowSt
     @Override
     public Future<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> getAllFlowsStatisticsFromAllFlowTables(GetAllFlowsStatisticsFromAllFlowTablesInput input) {
         GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder builder = new GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder();
-        TransactionId transId = new TransactionId(BigInteger.valueOf(transNum.incrementAndGet()));
+        TransactionId transId = new TransactionId(BigInteger.valueOf(TestUtils.getNewTransactionId()));
         builder.setTransactionId(transId);
         List<FlowAndStatisticsMapList> flowAndStatisticsMapLists = new ArrayList<>();
         FlowsStatisticsUpdateBuilder flowsStatisticsUpdateBuilder = new FlowsStatisticsUpdateBuilder();
@@ -95,7 +92,7 @@ public class OpendaylightFlowStatisticsServiceMock implements OpendaylightFlowSt
     @Override
     public Future<RpcResult<GetFlowStatisticsFromFlowTableOutput>> getFlowStatisticsFromFlowTable(GetFlowStatisticsFromFlowTableInput input) {
         GetFlowStatisticsFromFlowTableOutputBuilder builder = new GetFlowStatisticsFromFlowTableOutputBuilder();
-        TransactionId transId = new TransactionId(BigInteger.valueOf(transNum.incrementAndGet()));
+        TransactionId transId = new TransactionId(BigInteger.valueOf(TestUtils.getNewTransactionId()));
         builder.setTransactionId(transId);
         List<FlowAndStatisticsMapList> flowAndStatisticsMapLists = new ArrayList<>();
         FlowsStatisticsUpdateBuilder flowsStatisticsUpdateBuilder = new FlowsStatisticsUpdateBuilder();
index 42be708..ea9f403 100644 (file)
@@ -1,6 +1,10 @@
 package test.mock.util;
 
 import com.google.common.util.concurrent.Futures;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Future;
 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;
@@ -15,15 +19,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.Future;
-import java.util.concurrent.atomic.AtomicLong;
-
 public class OpendaylightFlowTableStatisticsServiceMock implements OpendaylightFlowTableStatisticsService {
     NotificationProviderServiceHelper notifService;
-    AtomicLong transNum = new AtomicLong();
 
     public OpendaylightFlowTableStatisticsServiceMock(NotificationProviderServiceHelper notifService) {
         this.notifService = notifService;
@@ -32,7 +29,7 @@ public class OpendaylightFlowTableStatisticsServiceMock implements OpendaylightF
     @Override
     public Future<RpcResult<GetFlowTablesStatisticsOutput>> getFlowTablesStatistics(GetFlowTablesStatisticsInput input) {
         GetFlowTablesStatisticsOutputBuilder builder = new GetFlowTablesStatisticsOutputBuilder();
-        TransactionId transId = new TransactionId(BigInteger.valueOf(transNum.incrementAndGet()));
+        TransactionId transId = new TransactionId(BigInteger.valueOf(TestUtils.getNewTransactionId()));
         builder.setTransactionId(transId);
         FlowTableStatisticsUpdateBuilder ftsBuilder = new FlowTableStatisticsUpdateBuilder();
         FlowTableAndStatisticsMapBuilder ftasmBuilder = new FlowTableAndStatisticsMapBuilder();
index 7e7342f..4b9c047 100644 (file)
@@ -1,6 +1,10 @@
 package test.mock.util;
 
 import com.google.common.util.concurrent.Futures;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Future;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsOutput;
@@ -29,15 +33,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.Future;
-import java.util.concurrent.atomic.AtomicLong;
-
 public class OpendaylightGroupStatisticsServiceMock implements OpendaylightGroupStatisticsService {
     NotificationProviderServiceHelper notifService;
-    AtomicLong transNum = new AtomicLong();
 
     public OpendaylightGroupStatisticsServiceMock(NotificationProviderServiceHelper notifService) {
         this.notifService = notifService;
@@ -46,7 +43,7 @@ public class OpendaylightGroupStatisticsServiceMock implements OpendaylightGroup
     @Override
     public Future<RpcResult<GetAllGroupStatisticsOutput>> getAllGroupStatistics(GetAllGroupStatisticsInput input) {
         GetAllGroupStatisticsOutputBuilder builder = new GetAllGroupStatisticsOutputBuilder();
-        TransactionId transId = new TransactionId(BigInteger.valueOf(transNum.incrementAndGet()));
+        TransactionId transId = new TransactionId(BigInteger.valueOf(TestUtils.getNewTransactionId()));
         builder.setTransactionId(transId);
         List<GroupStats> groupStats = new ArrayList<>();
         GroupStatsBuilder gsBuilder = new GroupStatsBuilder();
@@ -66,7 +63,7 @@ public class OpendaylightGroupStatisticsServiceMock implements OpendaylightGroup
     @Override
     public Future<RpcResult<GetGroupDescriptionOutput>> getGroupDescription(GetGroupDescriptionInput input) {
         GetGroupDescriptionOutputBuilder builder = new GetGroupDescriptionOutputBuilder();
-        TransactionId transId = new TransactionId(BigInteger.valueOf(transNum.incrementAndGet()));
+        TransactionId transId = new TransactionId(BigInteger.valueOf(TestUtils.getNewTransactionId()));
         builder.setTransactionId(transId);
         List<GroupDescStats> groupDescStats = new ArrayList<>();
         GroupDescStatsUpdatedBuilder gdsuBuilder = new GroupDescStatsUpdatedBuilder();
@@ -89,7 +86,7 @@ public class OpendaylightGroupStatisticsServiceMock implements OpendaylightGroup
     @Override
     public Future<RpcResult<GetGroupFeaturesOutput>> getGroupFeatures(GetGroupFeaturesInput input) {
         GetGroupFeaturesOutputBuilder builder = new GetGroupFeaturesOutputBuilder();
-        TransactionId transId = new TransactionId(BigInteger.valueOf(transNum.incrementAndGet()));
+        TransactionId transId = new TransactionId(BigInteger.valueOf(TestUtils.getNewTransactionId()));
         builder.setTransactionId(transId);
         GroupFeaturesUpdatedBuilder gfuBuilder = new GroupFeaturesUpdatedBuilder();
         gfuBuilder.setTransactionId(transId);
@@ -105,7 +102,7 @@ public class OpendaylightGroupStatisticsServiceMock implements OpendaylightGroup
     @Override
     public Future<RpcResult<GetGroupStatisticsOutput>> getGroupStatistics(GetGroupStatisticsInput input) {
         GetGroupStatisticsOutputBuilder builder = new GetGroupStatisticsOutputBuilder();
-        TransactionId transId = new TransactionId(BigInteger.valueOf(transNum.incrementAndGet()));
+        TransactionId transId = new TransactionId(BigInteger.valueOf(TestUtils.getNewTransactionId()));
         builder.setTransactionId(transId);
         GroupStatsBuilder gsBuilder = new GroupStatsBuilder();
         List<GroupStats> groupStats = new ArrayList<>();
index 2d65d1e..d5f0ce5 100644 (file)
@@ -1,6 +1,10 @@
 package test.mock.util;
 
 import com.google.common.util.concurrent.Futures;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Future;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
@@ -28,15 +32,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.Future;
-import java.util.concurrent.atomic.AtomicLong;
-
 public class OpendaylightMeterStatisticsServiceMock implements OpendaylightMeterStatisticsService {
     NotificationProviderServiceHelper notifService;
-    AtomicLong transNum = new AtomicLong();
 
     public OpendaylightMeterStatisticsServiceMock(NotificationProviderServiceHelper notifService) {
         this.notifService = notifService;
@@ -45,7 +42,7 @@ public class OpendaylightMeterStatisticsServiceMock implements OpendaylightMeter
     @Override
     public Future<RpcResult<GetAllMeterConfigStatisticsOutput>> getAllMeterConfigStatistics(GetAllMeterConfigStatisticsInput input) {
         GetAllMeterConfigStatisticsOutputBuilder builder = new GetAllMeterConfigStatisticsOutputBuilder();
-        TransactionId transId = new TransactionId(BigInteger.valueOf(transNum.incrementAndGet()));
+        TransactionId transId = new TransactionId(BigInteger.valueOf(TestUtils.getNewTransactionId()));
         builder.setTransactionId(transId);
         List<MeterConfigStats> meterConfigStats = new ArrayList<>();
         MeterConfigStatsBuilder mcsBuilder = new MeterConfigStatsBuilder();
@@ -66,7 +63,7 @@ public class OpendaylightMeterStatisticsServiceMock implements OpendaylightMeter
     @Override
     public Future<RpcResult<GetAllMeterStatisticsOutput>> getAllMeterStatistics(GetAllMeterStatisticsInput input) {
         GetAllMeterStatisticsOutputBuilder builder = new GetAllMeterStatisticsOutputBuilder();
-        TransactionId transId = new TransactionId(BigInteger.valueOf(transNum.incrementAndGet()));
+        TransactionId transId = new TransactionId(BigInteger.valueOf(TestUtils.getNewTransactionId()));
         builder.setTransactionId(transId);
         MeterStatsBuilder msBuilder = new MeterStatsBuilder();
         msBuilder.setByteInCount(StatisticsManagerTest.COUNTER_64_TEST_VALUE);
@@ -86,7 +83,7 @@ public class OpendaylightMeterStatisticsServiceMock implements OpendaylightMeter
     @Override
     public Future<RpcResult<GetMeterFeaturesOutput>> getMeterFeatures(GetMeterFeaturesInput input) {
         GetMeterFeaturesOutputBuilder builder = new GetMeterFeaturesOutputBuilder();
-        TransactionId transId = new TransactionId(BigInteger.valueOf(transNum.incrementAndGet()));
+        TransactionId transId = new TransactionId(BigInteger.valueOf(TestUtils.getNewTransactionId()));
         builder.setTransactionId(transId);
         MeterFeaturesUpdatedBuilder mfuBuilder = new MeterFeaturesUpdatedBuilder();
         mfuBuilder.setTransactionId(transId);
@@ -100,7 +97,7 @@ public class OpendaylightMeterStatisticsServiceMock implements OpendaylightMeter
     @Override
     public Future<RpcResult<GetMeterStatisticsOutput>> getMeterStatistics(GetMeterStatisticsInput input) {
         GetMeterStatisticsOutputBuilder builder = new GetMeterStatisticsOutputBuilder();
-        TransactionId transId = new TransactionId(BigInteger.valueOf(transNum.incrementAndGet()));
+        TransactionId transId = new TransactionId(BigInteger.valueOf(TestUtils.getNewTransactionId()));
         builder.setTransactionId(transId);
         MeterStatsBuilder msBuilder = new MeterStatsBuilder();
         msBuilder.setKey(new MeterStatsKey(input.getMeterId()));
index 7164c56..c3d13f4 100644 (file)
@@ -1,6 +1,10 @@
 package test.mock.util;
 
 import com.google.common.util.concurrent.Futures;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Future;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
@@ -18,15 +22,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.n
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.Future;
-import java.util.concurrent.atomic.AtomicLong;
-
 public class OpendaylightPortStatisticsServiceMock implements OpendaylightPortStatisticsService {
     NotificationProviderServiceHelper notifService;
-    AtomicLong transNum = new AtomicLong();
 
     public OpendaylightPortStatisticsServiceMock(NotificationProviderServiceHelper notifService) {
         this.notifService = notifService;
@@ -35,7 +32,7 @@ public class OpendaylightPortStatisticsServiceMock implements OpendaylightPortSt
     @Override
     public Future<RpcResult<GetAllNodeConnectorsStatisticsOutput>> getAllNodeConnectorsStatistics(GetAllNodeConnectorsStatisticsInput input) {
         GetAllNodeConnectorsStatisticsOutputBuilder builder = new GetAllNodeConnectorsStatisticsOutputBuilder();
-        TransactionId transId = new TransactionId(BigInteger.valueOf(transNum.incrementAndGet()));
+        TransactionId transId = new TransactionId(BigInteger.valueOf(TestUtils.getNewTransactionId()));
         builder.setTransactionId(transId);
         NodeConnectorStatisticsUpdateBuilder ncsuBuilder = new NodeConnectorStatisticsUpdateBuilder();
         NodeConnectorStatisticsAndPortNumberMapBuilder ncsapnmBuilder = new NodeConnectorStatisticsAndPortNumberMapBuilder();
@@ -43,7 +40,7 @@ public class OpendaylightPortStatisticsServiceMock implements OpendaylightPortSt
         ncsapnmBuilder.setKey(new NodeConnectorStatisticsAndPortNumberMapKey(StatisticsManagerTest.getNodeConnectorId()));
         ncsapnmBuilder.setReceiveDrops(StatisticsManagerTest.BIG_INTEGER_TEST_VALUE);
         nodeConnectorStatisticsAndPortNumberMaps.add(ncsapnmBuilder.build());
-        ncsuBuilder.setTransactionId(new TransactionId(BigInteger.valueOf(1)));
+        ncsuBuilder.setTransactionId(transId);
         ncsuBuilder.setId(input.getNode().getValue().firstKeyOf(Node.class, NodeKey.class).getId());
         ncsuBuilder.setNodeConnectorStatisticsAndPortNumberMap(nodeConnectorStatisticsAndPortNumberMaps);
         ncsuBuilder.setMoreReplies(true);
@@ -60,7 +57,7 @@ public class OpendaylightPortStatisticsServiceMock implements OpendaylightPortSt
     @Override
     public Future<RpcResult<GetNodeConnectorStatisticsOutput>> getNodeConnectorStatistics(GetNodeConnectorStatisticsInput input) {
         GetNodeConnectorStatisticsOutputBuilder builder = new GetNodeConnectorStatisticsOutputBuilder();
-        TransactionId transId = new TransactionId(BigInteger.valueOf(transNum.incrementAndGet()));
+        TransactionId transId = new TransactionId(BigInteger.valueOf(TestUtils.getNewTransactionId()));
         builder.setTransactionId(transId);
         return Futures.immediateFuture(RpcResultBuilder.success(builder.build()).build());
     }
index 4f6806b..8908dd5 100644 (file)
@@ -38,7 +38,7 @@ public class OpendaylightQueueStatisticsServiceMock implements OpendaylightQueue
     @Override
     public Future<RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> getAllQueuesStatisticsFromAllPorts(GetAllQueuesStatisticsFromAllPortsInput input) {
         GetAllQueuesStatisticsFromAllPortsOutputBuilder builder = new GetAllQueuesStatisticsFromAllPortsOutputBuilder();
-        TransactionId transId = new TransactionId(BigInteger.valueOf(transNum.incrementAndGet()));
+        TransactionId transId = new TransactionId(BigInteger.valueOf(TestUtils.getNewTransactionId()));
         builder.setTransactionId(transId);
         QueueStatisticsUpdateBuilder qsuBuilder = new QueueStatisticsUpdateBuilder();
         QueueIdAndStatisticsMapBuilder qiasmBuilder = new QueueIdAndStatisticsMapBuilder();
@@ -57,7 +57,7 @@ public class OpendaylightQueueStatisticsServiceMock implements OpendaylightQueue
     @Override
     public Future<RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>> getAllQueuesStatisticsFromGivenPort(GetAllQueuesStatisticsFromGivenPortInput input) {
         GetAllQueuesStatisticsFromGivenPortOutputBuilder builder = new GetAllQueuesStatisticsFromGivenPortOutputBuilder();
-        TransactionId transId = new TransactionId(BigInteger.valueOf(transNum.incrementAndGet()));
+        TransactionId transId = new TransactionId(BigInteger.valueOf(TestUtils.getNewTransactionId()));
         builder.setTransactionId(transId);
         return Futures.immediateFuture(RpcResultBuilder.success(builder.build()).build());
     }
@@ -65,7 +65,7 @@ public class OpendaylightQueueStatisticsServiceMock implements OpendaylightQueue
     @Override
     public Future<RpcResult<GetQueueStatisticsFromGivenPortOutput>> getQueueStatisticsFromGivenPort(GetQueueStatisticsFromGivenPortInput input) {
         GetQueueStatisticsFromGivenPortOutputBuilder builder = new GetQueueStatisticsFromGivenPortOutputBuilder();
-        TransactionId transId = new TransactionId(BigInteger.valueOf(transNum.incrementAndGet()));
+        TransactionId transId = new TransactionId(BigInteger.valueOf(TestUtils.getNewTransactionId()));
         builder.setTransactionId(transId);
         QueueIdAndStatisticsMapBuilder qiasmBuilder = new QueueIdAndStatisticsMapBuilder();
         List<QueueIdAndStatisticsMap> queueIdAndStatisticsMaps = new ArrayList<>();
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/ProviderContextMock.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/ProviderContextMock.java
deleted file mode 100644 (file)
index 9b40a76..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-package test.mock.util;
-
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
-import org.opendaylight.controller.sal.binding.api.BindingAwareService;
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-
-public class ProviderContextMock implements BindingAwareBroker.ProviderContext {
-
-    RpcProviderRegistry rpcProviderMock;
-    NotificationProviderService notificationProviderService;
-    DataBroker dataBroker;
-
-    public ProviderContextMock(RpcProviderRegistry rpcProviderMock, DataBroker dataBroker,
-                               NotificationProviderService notificationProviderServiceMock) {
-        this.rpcProviderMock = rpcProviderMock;
-        this.dataBroker = dataBroker;
-        this.notificationProviderService = notificationProviderServiceMock;
-    }
-
-    @Override
-    public void registerFunctionality(BindingAwareProvider.ProviderFunctionality functionality) {
-
-    }
-
-    @Override
-    public void unregisterFunctionality(BindingAwareProvider.ProviderFunctionality functionality) {
-
-    }
-
-    @SuppressWarnings("unchecked")
-    @Override
-    public <T extends BindingAwareService> T getSALService(Class<T> service) {
-        if (service.equals(DataBroker.class)) {
-            return (T) dataBroker;
-        }
-        else if (service.equals(NotificationProviderService.class)) {
-            return (T) notificationProviderService;
-        }
-        return null;
-    }
-
-    @Override
-    public <T extends RpcService> BindingAwareBroker.RpcRegistration<T> addRpcImplementation(Class<T> serviceInterface, T implementation) throws IllegalStateException {
-        return null;
-    }
-
-    @Override
-    public <T extends RpcService> BindingAwareBroker.RoutedRpcRegistration<T> addRoutedRpcImplementation(Class<T> serviceInterface, T implementation) throws IllegalStateException {
-        return null;
-    }
-
-    @Override
-    public <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> ListenerRegistration<L> registerRouteChangeListener(L listener) {
-        return null;
-    }
-
-    @Override
-    public <T extends RpcService> T getRpcService(Class<T> serviceInterface) {
-        return rpcProviderMock.getRpcService(serviceInterface);
-    }
-}
index 7f266d9..45765ed 100644 (file)
@@ -1,9 +1,17 @@
 package test.mock.util;
 
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.statistics.manager.StatisticsManager;
+import org.opendaylight.controller.md.statistics.manager.impl.StatisticsManagerConfig;
+import org.opendaylight.controller.md.statistics.manager.impl.StatisticsManagerImpl;
 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.inventory.rev130819.FeatureCapability;
@@ -35,12 +43,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-
 public abstract class StatisticsManagerTest extends AbstractDataBrokerTest {
 
     public static final Counter64 COUNTER_64_TEST_VALUE = new Counter64(BigInteger.valueOf(128));
@@ -48,6 +50,9 @@ public abstract class StatisticsManagerTest extends AbstractDataBrokerTest {
     public static final Long MAX_GROUPS_TEST_VALUE = 2000L;
     public static final BigInteger BIG_INTEGER_TEST_VALUE = BigInteger.valueOf(1000);
 
+    private static final int DEFAULT_MIN_REQUEST_NET_MONITOR_INTERVAL = 5000;
+    private static final int MAX_NODES_FOR_COLLECTOR = 16;
+
     private static Flow flow;
     private static Group group;
     private static Meter meter;
@@ -59,7 +64,6 @@ public abstract class StatisticsManagerTest extends AbstractDataBrokerTest {
     private final NotificationProviderServiceHelper notificationMock = new NotificationProviderServiceHelper();
     protected final NodeKey s1Key = new NodeKey(new NodeId("S1"));
     protected RpcProviderRegistryMock rpcRegistry;
-    protected ProviderContextMock providerContext;
 
     @BeforeClass
     public static void setupTests() {
@@ -75,7 +79,6 @@ public abstract class StatisticsManagerTest extends AbstractDataBrokerTest {
     @Before
     public void init() {
         rpcRegistry = new RpcProviderRegistryMock(notificationMock);
-        providerContext = new ProviderContextMock(rpcRegistry, getDataBroker(), notificationMock.getNotifBroker());
     }
 
     // node with statistics capabilities will enable cyclic statistics collection
@@ -94,7 +97,7 @@ public abstract class StatisticsManagerTest extends AbstractDataBrokerTest {
             capabilitiyList.add(capability);
         }
         sfBuilder.setCapabilities(capabilitiyList);
-        sfBuilder.setMaxTables((short) 2);
+        sfBuilder.setMaxTables((short) 255);
         final NodeBuilder nodeBuilder = new NodeBuilder();
         nodeBuilder.setKey(nodeKey);
         fcnBuilder.setSwitchFeatures(sfBuilder.build());
@@ -137,6 +140,9 @@ public abstract class StatisticsManagerTest extends AbstractDataBrokerTest {
         final FlowCapableNodeBuilder fcnBuilder = new FlowCapableNodeBuilder();
         final NodeBuilder nodeBuilder = new NodeBuilder();
         nodeBuilder.setKey(nodeKey);
+        final SwitchFeaturesBuilder sfBuilder = new SwitchFeaturesBuilder();
+        sfBuilder.setMaxTables((short) 255);
+        fcnBuilder.setSwitchFeatures(sfBuilder.build());
         final FlowCapableNode flowCapableNode = fcnBuilder.build();
         nodeBuilder.addAugmentation(FlowCapableNode.class, flowCapableNode);
         final Node node = nodeBuilder.build();
@@ -167,6 +173,15 @@ public abstract class StatisticsManagerTest extends AbstractDataBrokerTest {
         notificationMock.pushNotification(nrBuilder.build());
     }
 
+    public StatisticsManager setupStatisticsManager() {
+        StatisticsManagerConfig.StatisticsManagerConfigBuilder confBuilder = StatisticsManagerConfig.builder();
+        confBuilder.setMaxNodesForCollector(MAX_NODES_FOR_COLLECTOR);
+        confBuilder.setMinRequestNetMonitorInterval(DEFAULT_MIN_REQUEST_NET_MONITOR_INTERVAL);
+        StatisticsManager statsProvider = new StatisticsManagerImpl(getDataBroker(), confBuilder.build());
+        statsProvider.start(notificationMock.getNotifBroker(), rpcRegistry);
+        return statsProvider;
+    }
+
     public static Flow getFlow() {
         return flow;
     }
index e38a25e..d18dc23 100644 (file)
@@ -1,11 +1,19 @@
 package test.mock.util;
 
 import java.util.Random;
+import java.util.concurrent.atomic.AtomicLong;
 
 public class TestUtils {
+
+    private static AtomicLong transId = new AtomicLong();
+
     private static Random rnd = new Random();
 
     public static long nextLong(long RangeBottom, long rangeTop) {
         return RangeBottom + ((long)(rnd.nextDouble()*(rangeTop - RangeBottom)));
     }
+
+    public static long getNewTransactionId() {
+        return transId.incrementAndGet();
+    }
 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.