Merge "Eliminate the use of CompositeObjectRegistration"
authormichal rehak <mirehak@cisco.com>
Mon, 6 Jun 2016 09:43:21 +0000 (09:43 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 6 Jun 2016 09:43:21 +0000 (09:43 +0000)
47 files changed:
.gitignore
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/util/ReconcileUtilTest.java
applications/inventory-manager/src/main/config/default-config.xml
applications/inventory-manager/src/main/java/org/opendaylight/openflowplugin/applications/inventory/manager/InventoryActivator.java
applications/inventory-manager/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/inventory/manager/impl/rev150530/InventoryManagerImplModule.java
applications/inventory-manager/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/inventory/manager/impl/rev150530/InventoryManagerImplModuleFactory.java
applications/inventory-manager/src/main/yang/inventory-manager-impl.yang
applications/statistics-manager-config/src/main/resources/initial/30-statistics-manager.xml
applications/statistics-manager/pom.xml
applications/statistics-manager/src/main/java/org/opendaylight/openflowplugin/applications/config/yang/statistics_manager/StatisticsManagerModule.java
applications/statistics-manager/src/main/java/org/opendaylight/openflowplugin/applications/config/yang/statistics_manager/StatisticsManagerModuleFactory.java
applications/statistics-manager/src/main/java/org/opendaylight/openflowplugin/applications/statistics/manager/StatisticsManagerFactory.java [new file with mode: 0644]
applications/statistics-manager/src/main/java/org/opendaylight/openflowplugin/applications/statistics/manager/impl/StatNodeRegistrationImpl.java
applications/statistics-manager/src/main/java/org/opendaylight/openflowplugin/applications/statistics/manager/impl/StatisticsManagerFactoryImpl.java [new file with mode: 0644]
applications/statistics-manager/src/main/resources/org/opendaylight/blueprint/statistics-manager.xml [new file with mode: 0644]
applications/statistics-manager/src/main/yang/statistics-manager-app-config.yang [new file with mode: 0644]
applications/statistics-manager/src/main/yang/statistics-manager.yang
extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/IpConverter.java
extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/IpConverterTest.java [new file with mode: 0644]
extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/MatchUtilTest.java [moved from extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/MatchUtilTest.java with 98% similarity]
features-li/pom.xml
features-li/src/main/features/features.xml
features/pom.xml
features/src/main/features/features.xml
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/OpenFlowPluginProviderFactory.java [new file with mode: 0644]
openflowplugin-api/src/main/yang/openflow-provider-config.yang [new file with mode: 0644]
openflowplugin-api/src/main/yang/openflow-provider.yang
openflowplugin-blueprint-config-he/pom.xml [new file with mode: 0644]
openflowplugin-blueprint-config-he/src/main/resources/org/opendaylight/blueprint/openflowplugin-helium.xml [new file with mode: 0644]
openflowplugin-blueprint-config/pom.xml [new file with mode: 0644]
openflowplugin-blueprint-config/src/main/resources/org/opendaylight/blueprint/openflowplugin.xml [new file with mode: 0644]
openflowplugin-controller-config/src/main/resources/initial/42-openflowplugin-new.xml
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderFactoryImpl.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/config/openflow/plugin/impl/rev150327/OpenFlowProviderModule.java
openflowplugin-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/config/openflow/plugin/impl/rev150327/OpenFlowProviderModuleFactory.java
openflowplugin-impl/src/main/resources/org/opendaylight/blueprint/commands.xml [moved from openflowplugin-impl/src/main/resources/OSGI-INF/blueprint/commands.xml with 100% similarity]
openflowplugin-impl/src/main/resources/org/opendaylight/blueprint/openflowplugin-impl.xml [new file with mode: 0644]
openflowplugin/.gitignore [deleted file]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/OpenflowPluginProvider.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/SalRegistrationManager.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/util/InventoryDataServiceUtil.java
openflowplugin/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/common/config/impl/rev140326/ConfigurableOpenFlowProviderModule.java
openflowplugin/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/common/config/impl/rev140326/ConfigurableOpenFlowProviderModuleFactory.java
openflowplugin/src/main/yang/openflow-plugin-cfg.yang
parent/pom.xml
pom.xml
test-scripts/.gitignore [deleted file]

index df9979ce4a3be3936d28993761b2f5a23f4765cc..1b78296903f38bf0b5cc8c6cf93b2e88a3335f33 100644 (file)
@@ -1,24 +1,29 @@
-.idea/\r
-target/\r
-*.class\r
-*.iml\r
-**/target\r
-**/bin\r
-dist\r
-**/logs\r
-products\r
-repository\r
-workspace\r
-*~\r
-target\r
-.classpath\r
-.project\r
-.settings\r
-MANIFEST.MF\r
-xtend-gen\r
+.idea/
+target/
+*.class
+*.iml
+**/target
+**/bin
+dist
+**/logs
+products
+repository
+workspace
+*~
+target
+.classpath
+.project
+.settings
+MANIFEST.MF
+xtend-gen
 yang-gen-sal
 yang-gen-config
-.externalToolBuilders\r
-maven-eclipse.xml\r
+.externalToolBuilders
+maven-eclipse.xml
 .metadata/
 .checkstyle
+maven-metadata-local.xml
+*.pyc
+/.pydevproject
+*.log
+.tox/
index b5d68931b916609f0763fd1d82452d87e0536181..75aa3b23bcd36e0f8dbe863aeff8bbbf99e5336c 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.openflowplugin.applications.frsync.util;
 
+import com.google.common.base.Splitter;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.SettableFuture;
@@ -63,6 +64,7 @@ public class ReconcileUtilTest {
     private static final NodeId NODE_ID = new NodeId("unit-node-id");
     private InstanceIdentifier<Node> NODE_IDENT = InstanceIdentifier.create(Nodes.class)
             .child(Node.class, new NodeKey(NODE_ID));
+    private static final Splitter COMMA_SPLITTER = Splitter.on(",");
 
     @Rule
     public ExpectedException thrown = ExpectedException.none();
@@ -328,8 +330,8 @@ public class ReconcileUtilTest {
 
     private ItemSyncBox<String> createSyncBox(final String pushes, final String updates) {
         ItemSyncBox<String> syncBox1 = new ItemSyncBox<>();
-        syncBox1.getItemsToPush().addAll(Arrays.asList(pushes.split(",")));
-        for (String orig : updates.split(",")) {
+        syncBox1.getItemsToPush().addAll(COMMA_SPLITTER.splitToList(pushes));
+        for (String orig : COMMA_SPLITTER.splitToList(updates)) {
             syncBox1.getItemsToUpdate().add(new ItemSyncBox.ItemUpdateTuple<>(orig, orig + "_updated"));
         }
         return syncBox1;
index cfb992a206926e3471dffad31f20dac2066d56a2..8fa1cc456d9310b65bc1b8cbddb709f082f9f336 100644 (file)
@@ -6,6 +6,9 @@ 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
+
+NOTE: This file is deprecated as wiring is now done via blueprint. This file is kept for
+       backwards compatibility. Runtime modifications are not honored.
 -->
 <snapshot>
   <required-capabilities>
index 3610157774a360893d7bca9c26fd4db3ab9711f6..1ed9397e54bd43a33304b64a0b7c3be40a0fa9ff 100644 (file)
@@ -9,41 +9,30 @@ package org.opendaylight.openflowplugin.applications.inventory.manager;
 
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class InventoryActivator implements BindingAwareProvider, AutoCloseable {
+public class InventoryActivator implements AutoCloseable {
     private static final Logger LOG = LoggerFactory.getLogger(InventoryActivator.class);
-    private FlowCapableInventoryProvider provider;
-    final private EntityOwnershipService eos;
-
-    public InventoryActivator(EntityOwnershipService eos) {
-        this.eos = eos;
-    }
 
+    private final FlowCapableInventoryProvider provider;
 
-    @Override
-    public void onSessionInitiated(final ProviderContext session) {
-        DataBroker dataBroker = session.getSALService(DataBroker.class);
-        NotificationProviderService salNotifiService =
-                session.getSALService(NotificationProviderService.class);
+    public InventoryActivator(DataBroker dataBroker, NotificationProviderService notificationService,
+            EntityOwnershipService eos) {
+        provider = new FlowCapableInventoryProvider(dataBroker, notificationService, eos);
+    }
 
-        provider = new FlowCapableInventoryProvider(dataBroker, salNotifiService, eos);
+    public void start() {
         provider.start();
     }
 
     @Override
-    public void close() throws Exception {
-        if (provider != null) {
-            try {
-                provider.close();
-            } catch (InterruptedException e) {
-                LOG.warn("Interrupted while waiting for shutdown", e);
-            }
-            provider = null;
+    public void close() {
+        try {
+            provider.close();
+        } catch (InterruptedException e) {
+            LOG.warn("Interrupted while waiting for shutdown", e);
         }
     }
 }
index 673aa2515861d55cebbe1aa02f6208822f10e287..60bf1fbcac8c15d30019eaf24297c26162947d41 100644 (file)
@@ -1,8 +1,12 @@
 package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.inventory.manager.impl.rev150530;
 
-import org.opendaylight.openflowplugin.applications.inventory.manager.InventoryActivator;
+import org.opendaylight.controller.sal.common.util.NoopAutoCloseable;
 
-public class InventoryManagerImplModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.inventory.manager.impl.rev150530.AbstractInventoryManagerImplModule {
+/**
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
+public class InventoryManagerImplModule extends AbstractInventoryManagerImplModule {
     public InventoryManagerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
         super(identifier, dependencyResolver);
     }
@@ -12,15 +16,8 @@ public class InventoryManagerImplModule extends org.opendaylight.yang.gen.v1.urn
     }
 
     @Override
-    public void customValidation() {
-        // add custom validation form module attributes here.
+    public AutoCloseable createInstance() {
+        // InventoryActivator instance is created via blueprint so this in a no-op.
+        return NoopAutoCloseable.INSTANCE;
     }
-
-    @Override
-    public java.lang.AutoCloseable createInstance() {
-        InventoryActivator provider = new InventoryActivator(getEntityOwnershipServiceDependency());
-        getBrokerDependency().registerProvider(provider);
-        return provider;
-    }
-
 }
index 49369d4a87a87aec800ce80deee05f312bfe382c..b8fe5bc13a3d6b7c6e68a600accdf97b883d10aa 100644 (file)
@@ -8,6 +8,11 @@
 * Do not modify this file unless it is present under src/main directory
 */
 package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.inventory.manager.impl.rev150530;
-public class InventoryManagerImplModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.inventory.manager.impl.rev150530.AbstractInventoryManagerImplModuleFactory {
+
+/**
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
+public class InventoryManagerImplModuleFactory extends AbstractInventoryManagerImplModuleFactory {
 
 }
index f3483ecd8c58c2670a10171fcb45328bcb81cba7..d68891584bf6d5edfc3591b5e0303cbeb4d79e0f 100644 (file)
@@ -18,6 +18,7 @@ module inventory-manager-impl {
     identity inventory-manager-impl {
         base config:module-type;
         config:java-name-prefix InventoryManagerImpl;
+        status deprecated;
     }
 
     augment "/config:modules/config:module/config:configuration" {
index 9962070ccc5c020be374678f94979add2471a36f..5103b5bf6889763320fe6fb036fc039e864e5b54 100644 (file)
@@ -6,6 +6,10 @@
  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
+
+ NOTE: This file is deprecated as wiring is now done via blueprint. This file is kept for
+       backwards compatibility. Runtime modifications are not honored.
+
 -->
 <snapshot>
     <configuration>
index a87ea4f1055dffd97d55a228c4f09e9519cb4d07..5eb232f41d1516e8926a033f09a95ef83860e641 100644 (file)
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal-binding-config</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal-common-util</artifactId>
+    </dependency>
     <dependency>
       <groupId>org.opendaylight.openflowplugin.model</groupId>
       <artifactId>model-flow-base</artifactId>
index 93fecc35b539249f7f0ce36f098bb0a676a7539c..31bedd8ae20e42e36256798d771d89ba990d8999 100644 (file)
@@ -8,19 +8,13 @@
 
 package org.opendaylight.openflowplugin.applications.config.yang.statistics_manager;
 
-import org.opendaylight.openflowplugin.applications.statistics.manager.StatisticsManager;
-import org.opendaylight.openflowplugin.applications.statistics.manager.impl.StatisticsManagerConfig;
-import org.opendaylight.openflowplugin.applications.statistics.manager.impl.StatisticsManagerImpl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class StatisticsManagerModule extends org.opendaylight.openflowplugin.applications.config.yang.statistics_manager.AbstractStatisticsManagerModule {
-
-    private static final Logger LOG = LoggerFactory.getLogger(StatisticsManagerModule.class);
-
-    private static final int MAX_NODES_FOR_COLLECTOR_DEFAULT = 16;
-    private static final int MIN_REQUEST_NET_MONITOR_INTERVAL_DEFAULT = 3000;
+import org.opendaylight.controller.sal.common.util.NoopAutoCloseable;
 
+/**
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
+public class StatisticsManagerModule extends AbstractStatisticsManagerModule {
     public StatisticsManagerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
         super(identifier, dependencyResolver);
     }
@@ -30,51 +24,8 @@ public class StatisticsManagerModule extends org.opendaylight.openflowplugin.app
     }
 
     @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();
-        final StatisticsManager statisticsManagerProvider = new StatisticsManagerImpl(getDataBrokerDependency(), config);
-        statisticsManagerProvider.setOwnershipService(getOwnershipServiceDependency());
-        statisticsManagerProvider.start(getNotificationServiceDependency(), getRpcRegistryDependency());
-
-        final StatisticsManager statisticsManagerProviderExposed = statisticsManagerProvider;
-        LOG.info("StatisticsManager started successfully.");
-        return new AutoCloseable() {
-            @Override
-            public void close() throws Exception {
-                try {
-                    statisticsManagerProviderExposed.close();
-                }
-                catch (final Exception e) {
-                    LOG.error("Unexpected error by stopping StatisticsManager module", e);
-                }
-                LOG.info("StatisticsManager module stopped.");
-            }
-        };
-    }
-
-    private 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();
+    public AutoCloseable createInstance() {
+        // StatisticsManager instance is created via blueprint so this in a no-op.
+        return NoopAutoCloseable.INSTANCE;
     }
 }
index aad063483161b2272e39a942301ff25752ecc910..444459e9f29aec3b20b60e5898efd02747e93cd4 100644 (file)
 * Do not modify this file unless it is present under src/main directory
 */
 package org.opendaylight.openflowplugin.applications.config.yang.statistics_manager;
-public class StatisticsManagerModuleFactory extends org.opendaylight.openflowplugin.applications.config.yang.statistics_manager.AbstractStatisticsManagerModuleFactory {
+
+/**
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
+public class StatisticsManagerModuleFactory extends AbstractStatisticsManagerModuleFactory {
 
 }
diff --git a/applications/statistics-manager/src/main/java/org/opendaylight/openflowplugin/applications/statistics/manager/StatisticsManagerFactory.java b/applications/statistics-manager/src/main/java/org/opendaylight/openflowplugin/applications/statistics/manager/StatisticsManagerFactory.java
new file mode 100644 (file)
index 0000000..fde568e
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2016 Brocade Communications 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.openflowplugin.applications.statistics.manager;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.statistics.manager.config.rev160509.StatisticsManagerAppConfig;
+
+/**
+ * Factory for creating StatisticsManager instances.
+ *
+ * @author Thomas Pantelis
+ */
+public interface StatisticsManagerFactory {
+    StatisticsManager newInstance(StatisticsManagerAppConfig statsManagerAppConfig, DataBroker dataBroker,
+            NotificationProviderService notifService, RpcConsumerRegistry rpcRegistry,
+            EntityOwnershipService entityOwnershipService);
+
+}
index 0b91579b5edc914988b65b7970d2e5dcf0729779..b590f3356eb90ba89feadd77f298454dc5848106 100644 (file)
@@ -245,7 +245,6 @@ public class StatNodeRegistrationImpl implements StatNodeRegistration,EntityOwne
         NodeIdentifierWithPredicates niWPredicates = (NodeIdentifierWithPredicates)yId.getLastPathArgument();
         Map<QName, Object> keyValMap = niWPredicates.getKeyValues();
         String nodeIdStr = (String)(keyValMap.get(ENTITY_NAME));
-        BigInteger dpId = new BigInteger(nodeIdStr.split(":")[1]);
         NodeId nodeId = new NodeId(nodeIdStr);
         setNodeOwnership(nodeId, ownershipChange.isOwner());
     }
diff --git a/applications/statistics-manager/src/main/java/org/opendaylight/openflowplugin/applications/statistics/manager/impl/StatisticsManagerFactoryImpl.java b/applications/statistics-manager/src/main/java/org/opendaylight/openflowplugin/applications/statistics/manager/impl/StatisticsManagerFactoryImpl.java
new file mode 100644 (file)
index 0000000..11fe70d
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2016 Brocade Communications 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.openflowplugin.applications.statistics.manager.impl;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.openflowplugin.applications.statistics.manager.StatisticsManager;
+import org.opendaylight.openflowplugin.applications.statistics.manager.StatisticsManagerFactory;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.statistics.manager.config.rev160509.StatisticsManagerAppConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Implementation of StatisticsManagerFactory.
+ *
+ * @author Thomas Pantelis
+ */
+public class StatisticsManagerFactoryImpl implements StatisticsManagerFactory {
+    private static final Logger LOG = LoggerFactory.getLogger(StatisticsManagerFactoryImpl.class);
+
+    @Override
+    public StatisticsManager newInstance(StatisticsManagerAppConfig statsManagerAppConfig, DataBroker dataBroker,
+            NotificationProviderService notifService, RpcConsumerRegistry rpcRegistry,
+            EntityOwnershipService entityOwnershipService) {
+        LOG.info("StatisticsManager module initialization.");
+
+        StatisticsManagerConfig.StatisticsManagerConfigBuilder configBuilder = StatisticsManagerConfig.builder();
+        configBuilder.setMaxNodesForCollector(statsManagerAppConfig.getMaxNodesForCollector());
+        configBuilder.setMinRequestNetMonitorInterval(statsManagerAppConfig.getMinRequestNetMonitorInterval());
+
+        StatisticsManager statisticsManager = new StatisticsManagerImpl(dataBroker, configBuilder.build());
+        statisticsManager.setOwnershipService(entityOwnershipService);
+        statisticsManager.start(notifService, rpcRegistry);
+
+        LOG.info("StatisticsManager started successfully.");
+
+        return statisticsManager;
+    }
+}
diff --git a/applications/statistics-manager/src/main/resources/org/opendaylight/blueprint/statistics-manager.xml b/applications/statistics-manager/src/main/resources/org/opendaylight/blueprint/statistics-manager.xml
new file mode 100644 (file)
index 0000000..3155c1f
--- /dev/null
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0">
+
+  <bean id="statsManagerFactory" class="org.opendaylight.openflowplugin.applications.statistics.manager.impl.StatisticsManagerFactoryImpl"/>
+
+  <service ref="statsManagerFactory" interface="org.opendaylight.openflowplugin.applications.statistics.manager.StatisticsManagerFactory"
+          odl:type="default"/>
+</blueprint>
\ No newline at end of file
diff --git a/applications/statistics-manager/src/main/yang/statistics-manager-app-config.yang b/applications/statistics-manager/src/main/yang/statistics-manager-app-config.yang
new file mode 100644 (file)
index 0000000..d824326
--- /dev/null
@@ -0,0 +1,25 @@
+module statistics-manager-app-config {
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:openflowplugin:app:statistics-manager:config";
+    prefix "statistics-manager-app-config";
+
+    description
+        "Configuration for Statistics Manager application.";
+
+    revision "2016-05-09" {
+        description
+            "Initial revision";
+    }
+
+    container statistics-manager-app-config {
+        leaf min-request-net-monitor-interval {
+            type int32;
+            default 3000;
+        }
+
+        leaf max-nodes-for-collector {
+            type int32;
+            default 16;
+        }
+    }
+}
\ No newline at end of file
index d982d35bf652e89379df37bedfec9ef6e9605f8a..43acf0a1055ec31ccc6a32af8c635d0556437481 100644 (file)
@@ -20,6 +20,7 @@ module statistics-manager {
     identity statistics-manager {
             base config:module-type;
             config:java-name-prefix StatisticsManager;
+            status deprecated;
     }
 
     augment "/config:modules/config:module/config:configuration" {
index 2054f24bc7089cf16732e1f128d81e68d60b7e43..de26eb09c47e087ca557690dd620daa42b522922 100644 (file)
@@ -7,8 +7,13 @@
  */
 package org.opendaylight.openflowplugin.extension.vendor.nicira.convertor;
 
+import com.google.common.base.Splitter;
+import com.google.common.collect.Lists;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
 
+import java.util.List;
+import java.util.ListIterator;
+
 /**
  * @author msunal
  *
@@ -16,11 +21,19 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.
 public final class IpConverter {
 
     public static long Ipv4AddressToLong(Ipv4Address ipv4Address) {
-        String ipAddress = ipv4Address.getValue();
-        long result = 0;
-        String[] atoms = ipAddress.split("\\.");
-        for (int i = 3; i >= 0; i--) {
-            result |= (Long.parseLong(atoms[3 - i]) << (i * 8));
+        long result = 0 ;
+        Iterable<String> splitted = Splitter.on('.')
+                .trimResults()
+                .omitEmptyStrings()
+                .split(ipv4Address.getValue());
+
+        List<String> splittedAddress = Lists.newArrayList(splitted.iterator());
+        int maxIndex = splittedAddress.size() - 1;
+        ListIterator<String> listIter = splittedAddress.listIterator();
+        while(listIter.hasNext()) {
+            String current = listIter.next();
+            int i = splittedAddress.indexOf(current);
+            result |= (Long.parseLong(current) << ((maxIndex-i) * 8));
         }
         return result & 0xFFFFFFFF;
     }
diff --git a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/IpConverterTest.java b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/IpConverterTest.java
new file mode 100644 (file)
index 0000000..f8e27ff
--- /dev/null
@@ -0,0 +1,24 @@
+package org.opendaylight.openflowplugin.extension.vendor.nicira.convertor;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
+
+public class IpConverterTest {
+
+    @Test
+    public void testIpv4AddressToLong() {
+        Ipv4Address ipAddress = new Ipv4Address("192.168.1.2");
+        long address = 0xc0a80102L;
+        assertEquals(address, IpConverter.Ipv4AddressToLong(ipAddress));
+    }
+
+    @Test
+    public void testIpv4AddressToLong2() {
+        Ipv4Address ipAddress = new Ipv4Address("10.168.1.2");
+        long address = 0x0aa80102L;
+        assertEquals(address, IpConverter.Ipv4AddressToLong(ipAddress));
+    }
+
+}
index 62d49173bbe057832a356a4773a5c3ef93028174..7111c20fe03384fd10265233c547cd59bea4904c 100644 (file)
             <classifier>config</classifier>
             <type>xml</type>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.openflowplugin</groupId>
+            <artifactId>openflowplugin-blueprint-config</artifactId>
+            <version>${project.version}</version>
+        </dependency>
 
         <dependency>
             <groupId>org.opendaylight.dlux</groupId>
index 9872cf47ca44d1960827f6417618694cbe9fc379..638c8a073c6d16bca452f67a9aee8418c5f00c85 100644 (file)
@@ -36,7 +36,8 @@
         <bundle>mvn:org.opendaylight.openflowplugin/openflowplugin/{{VERSION}}</bundle>
         <bundle>mvn:org.opendaylight.openflowplugin/openflowplugin-impl/{{VERSION}}</bundle>
         <bundle>mvn:org.opendaylight.openflowplugin/openflowplugin-extension-api/{{VERSION}}</bundle>
-       <bundle>mvn:org.opendaylight.controller/liblldp/{{VERSION}}</bundle>
+        <bundle>mvn:org.opendaylight.controller/liblldp/{{VERSION}}</bundle>
+        <bundle>mvn:org.opendaylight.openflowplugin/openflowplugin-blueprint-config/{{VERSION}}</bundle>
         <configfile finalname="etc/opendaylight/karaf/42-openflowplugin-Li.xml">mvn:org.opendaylight.openflowplugin/openflowplugin-controller-config/{{VERSION}}/xml/config-Li</configfile>
     </feature>
 
index c02e3c1d8a21be6f033fe23fe272dc226769d7ac..5568bd2c1d9f8db8b4f005978888b1cf0df1cdf2 100644 (file)
             <groupId>org.opendaylight.openflowplugin</groupId>
             <artifactId>openflowplugin-impl</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.openflowplugin</groupId>
+            <artifactId>openflowplugin-blueprint-config-he</artifactId>
+            <version>${project.version}</version>
+        </dependency>
         <dependency>
             <groupId>org.opendaylight.openflowplugin.applications</groupId>
             <artifactId>table-miss-enforcer</artifactId>
index 36e80a25b53b7d085655c8c229f7763d3fd82dd8..214452365c5c7780c16f2063c94ed640cec524d3 100644 (file)
         <bundle>mvn:org.opendaylight.openflowplugin/openflowplugin/{{VERSION}}</bundle>
         <bundle>mvn:org.opendaylight.openflowplugin/openflowplugin-api/{{VERSION}}</bundle>
         <bundle>mvn:org.opendaylight.openflowplugin/openflowplugin-extension-api/{{VERSION}}</bundle>
-       <bundle>mvn:org.opendaylight.controller/liblldp/{{VERSION}}</bundle>
+        <bundle>mvn:org.opendaylight.controller/liblldp/{{VERSION}}</bundle>
         <bundle>mvn:org.opendaylight.openflowplugin.applications/inventory-manager/{{VERSION}}</bundle>
         <bundle>mvn:org.opendaylight.openflowplugin.applications/statistics-manager/{{VERSION}}</bundle>
+        <bundle>mvn:org.opendaylight.openflowplugin/openflowplugin-blueprint-config-he/{{VERSION}}</bundle>
         <configfile finalname="${config.configfile.directory}/${config.statistics.manager.configfile}">mvn:org.opendaylight.openflowplugin.applications/statistics-manager-config/{{VERSION}}/xml/config</configfile>
         <configfile finalname="${config.configfile.directory}/${config.inventory.manager.configfile}">mvn:org.opendaylight.openflowplugin.applications/inventory-manager/{{VERSION}}/xml/config</configfile>
         <configfile finalname="etc/opendaylight/karaf/42-openflowplugin-He.xml">mvn:org.opendaylight.openflowplugin/openflowplugin-controller-config/{{VERSION}}/xml/config-He</configfile>
diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/OpenFlowPluginProviderFactory.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/OpenFlowPluginProviderFactory.java
new file mode 100644 (file)
index 0000000..d5caf2d
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2016 Brocade Communications 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.openflowplugin.api.openflow;
+
+import java.util.List;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
+import org.opendaylight.controller.md.sal.binding.api.NotificationService;
+import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfig;
+
+/**
+ * Factory for creating OpenFlowPluginProvider instances.
+ *
+ * @author Thomas Pantelis
+ */
+public interface OpenFlowPluginProviderFactory {
+    OpenFlowPluginProvider newInstance(OpenflowProviderConfig providerConfig, DataBroker dataBroker,
+            RpcProviderRegistry rpcRegistry, NotificationService notificationService,
+            NotificationPublishService notificationPublishService,
+            EntityOwnershipService entityOwnershipService,
+            List<SwitchConnectionProvider> switchConnectionProviders);
+}
diff --git a/openflowplugin-api/src/main/yang/openflow-provider-config.yang b/openflowplugin-api/src/main/yang/openflow-provider-config.yang
new file mode 100644 (file)
index 0000000..481793e
--- /dev/null
@@ -0,0 +1,68 @@
+module openflow-provider-config {
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:openflow:provider:config";
+    prefix "openflow-provider-config";
+
+    description
+        "Configuration for an Openflow provider.";
+
+    revision "2016-05-10" {
+        description
+            "Initial revision";
+    }
+
+    typedef non-zero-uint32-type {
+        type uint32 {
+            range "1..max";
+        }
+    }
+
+    typedef non-zero-uint16-type {
+        type uint16 {
+            range "1..max";
+        }
+    }
+
+    container openflow-provider-config {
+        leaf rpc-requests-quota {
+            type uint32;
+            default 20000;
+        }
+
+        leaf switch-features-mandatory {
+            type boolean;
+            default false;
+        }
+
+        leaf global-notification-quota {
+            type uint32;
+            default 64000;
+        }
+
+        leaf is-statistics-polling-off {
+            type boolean;
+            default "false";
+        }
+
+        leaf is-statistics-rpc-enabled {
+            description "Deprecated - exposing backward compatible statistics rpcs providing result in form of async notification";
+            type boolean;
+            default "false";
+        }
+
+        leaf barrier-interval-timeout-limit {
+            type non-zero-uint32-type;
+            default 500;
+        }
+
+        leaf barrier-count-limit {
+            type non-zero-uint16-type;
+            default 25600;
+        }
+
+        leaf echo-reply-timeout {
+            type non-zero-uint32-type;
+            default 2000;
+        }
+    }
+}
\ No newline at end of file
index fa640fe401c0a6ec34ddefee2c4f325d758d4049..cb020ef858dac66f0aeb8d732977dfe08eddc133 100644 (file)
@@ -16,5 +16,7 @@ module openflow-provider {
     identity openflow-provider{
         base config:service-type;
         config:java-class "org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProvider";
+        config:disable-osgi-service-registration;
+        status deprecated;
     }
 }
\ No newline at end of file
diff --git a/openflowplugin-blueprint-config-he/pom.xml b/openflowplugin-blueprint-config-he/pom.xml
new file mode 100644 (file)
index 0000000..0e1bf7f
--- /dev/null
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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.openflowplugin</groupId>
+      <artifactId>openflowplugin-parent</artifactId>
+      <version>0.3.0-SNAPSHOT</version>
+      <relativePath>../parent</relativePath>
+    </parent>
+
+    <artifactId>openflowplugin-blueprint-config-he</artifactId>
+    <description>Blueprint configuration for the Helium openflowplugin</description>
+    <packaging>bundle</packaging>
+
+    <build>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.felix</groupId>
+          <artifactId>maven-bundle-plugin</artifactId>
+          <extensions>true</extensions>
+          <configuration>
+            <instructions>
+              <DynamicImport-Package>*</DynamicImport-Package>
+           </instructions>
+         </configuration>
+       </plugin>
+     </plugins>
+   </build>
+</project>
diff --git a/openflowplugin-blueprint-config-he/src/main/resources/org/opendaylight/blueprint/openflowplugin-helium.xml b/openflowplugin-blueprint-config-he/src/main/resources/org/opendaylight/blueprint/openflowplugin-helium.xml
new file mode 100644 (file)
index 0000000..6ef2961
--- /dev/null
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+        odl:use-default-for-reference-types="true">
+
+  <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker" odl:type="pingpong"/>
+  <reference id="rpcRegistry" interface="org.opendaylight.controller.sal.binding.api.RpcProviderRegistry"/>
+  <reference id="notificationService" interface="org.opendaylight.controller.sal.binding.api.NotificationProviderService"/>
+  <reference id="entityOwnershipService" interface="org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService"/>
+
+  <!-- Create the StatisticsManager -->
+  <reference id="statsManagerFactory"
+          interface="org.opendaylight.openflowplugin.applications.statistics.manager.StatisticsManagerFactory"/>
+
+  <odl:clustered-app-config id="statsManagerAppConfig"
+      binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.statistics.manager.config.rev160509.StatisticsManagerAppConfig"/>
+
+  <bean id="statsManager" factory-ref="statsManagerFactory" factory-method="newInstance">
+    <argument ref="statsManagerAppConfig"/>
+    <argument ref="dataBroker"/>
+    <argument ref="notificationService"/>
+    <argument ref="rpcRegistry"/>
+    <argument ref="entityOwnershipService"/>
+  </bean>
+
+  <!-- Create the Inventory manager/provider -->
+  <bean id="inventoryManager" class="org.opendaylight.openflowplugin.applications.inventory.manager.InventoryActivator"
+          init-method="start" destroy-method="close">
+    <argument ref="dataBroker"/>
+    <argument ref="notificationService"/>
+    <argument ref="entityOwnershipService"/>
+  </bean>
+
+  <reference id="switchConnProviderFactory"
+          interface="org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProviderFactory"/>
+
+  <!-- Create OF switch connection provider on port 6633 -->
+  <odl:clustered-app-config id="defaultSwitchConnConfig"
+      binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.config.rev160506.SwitchConnectionConfig"
+      list-key-value="openflow-switch-connection-provider-default-impl">
+    <odl:default-config><![CDATA[
+      <switch-connection-config xmlns="urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:config">
+        <instance-name>openflow-switch-connection-provider-default-impl</instance-name>
+        <port>6633</port>
+        <transport-protocol>TCP</transport-protocol>
+      </switch-connection-config>
+    ]]></odl:default-config>
+  </odl:clustered-app-config>
+
+  <bean id="defaultSwitchConnProvider" factory-ref="switchConnProviderFactory" factory-method="newInstance">
+    <argument ref="defaultSwitchConnConfig"/>
+  </bean>
+
+  <service ref="defaultSwitchConnProvider" interface="org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider"
+          odl:type="openflow-switch-connection-provider-default-impl"/>
+
+  <!-- Create OF switch connection provider on port 6653 -->
+  <odl:clustered-app-config id="legacySwitchConnConfig"
+      binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.config.rev160506.SwitchConnectionConfig"
+      list-key-value="openflow-switch-connection-provider-legacy-impl">
+    <odl:default-config><![CDATA[
+      <switch-connection-config xmlns="urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:config">
+        <instance-name>openflow-switch-connection-provider-legacy-impl</instance-name>
+        <port>6653</port>
+        <transport-protocol>TCP</transport-protocol>
+      </switch-connection-config>
+    ]]></odl:default-config>
+  </odl:clustered-app-config>
+
+  <bean id="legacySwitchConnProvider" factory-ref="switchConnProviderFactory" factory-method="newInstance">
+    <argument ref="legacySwitchConnConfig"/>
+  </bean>
+
+  <service ref="legacySwitchConnProvider" interface="org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider"
+          odl:type="openflow-switch-connection-provider-legacy-impl"/>
+
+  <!-- Create OpenflowPluginProvider instance -->
+
+  <bean id="openflowPluginProvider" class="org.opendaylight.openflowplugin.openflow.md.core.sal.OpenflowPluginProvider"
+          init-method="initialization" destroy-method="close" depends-on="statsManager inventoryManager">
+    <property name="dataBroker" ref="dataBroker"/>
+    <property name="rpcRegistry" ref="rpcRegistry"/>
+    <property name="notificationService" ref="notificationService"/>
+    <property name="entityOwnershipService" ref="entityOwnershipService"/>
+    <property name="role" value="NOCHANGE"/>
+    <property name="skipTableFeatures" value="false" />
+    <property name="switchConnectionProviders">
+      <list>
+        <ref component-id="defaultSwitchConnProvider"/>
+        <ref component-id="legacySwitchConnProvider"/>
+      </list>
+    </property>
+  </bean>
+
+  <service ref="openflowPluginProvider" odl:type="openflow-provider-impl">
+    <interfaces>
+      <value>org.opendaylight.openflowplugin.openflow.md.core.sal.OpenflowPluginProvider</value>
+      <value>org.opendaylight.openflowplugin.extension.api.OpenFlowPluginExtensionRegistratorProvider</value>
+    </interfaces>
+  </service>
+
+</blueprint>
\ No newline at end of file
diff --git a/openflowplugin-blueprint-config/pom.xml b/openflowplugin-blueprint-config/pom.xml
new file mode 100644 (file)
index 0000000..61dd36f
--- /dev/null
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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.openflowplugin</groupId>
+      <artifactId>openflowplugin-parent</artifactId>
+      <version>0.3.0-SNAPSHOT</version>
+      <relativePath>../parent</relativePath>
+    </parent>
+
+    <artifactId>openflowplugin-blueprint-config</artifactId>
+    <description>Blueprint configuration for the openflowplugin</description>
+    <packaging>bundle</packaging>
+
+    <build>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.felix</groupId>
+          <artifactId>maven-bundle-plugin</artifactId>
+          <extensions>true</extensions>
+          <configuration>
+            <instructions>
+              <DynamicImport-Package>*</DynamicImport-Package>
+           </instructions>
+         </configuration>
+       </plugin>
+     </plugins>
+   </build>
+</project>
diff --git a/openflowplugin-blueprint-config/src/main/resources/org/opendaylight/blueprint/openflowplugin.xml b/openflowplugin-blueprint-config/src/main/resources/org/opendaylight/blueprint/openflowplugin.xml
new file mode 100644 (file)
index 0000000..db68c3b
--- /dev/null
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+        odl:use-default-for-reference-types="true">
+
+  <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker" odl:type="pingpong"/>
+  <reference id="rpcRegistry" interface="org.opendaylight.controller.sal.binding.api.RpcProviderRegistry"/>
+  <reference id="notificationService" interface="org.opendaylight.controller.md.sal.binding.api.NotificationService"/>
+  <reference id="notificationPublishService" interface="org.opendaylight.controller.md.sal.binding.api.NotificationPublishService"/>
+  <reference id="entityOwnershipService" interface="org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService"/>
+
+  <reference id="switchConnProviderFactory"
+          interface="org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProviderFactory"/>
+
+  <!-- Create OF switch connection provider on port 6633 -->
+  <odl:clustered-app-config id="defaultSwitchConnConfig"
+      binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.config.rev160506.SwitchConnectionConfig"
+      list-key-value="openflow-switch-connection-provider-default-impl">
+    <odl:default-config><![CDATA[
+      <switch-connection-config xmlns="urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:config">
+        <instance-name>openflow-switch-connection-provider-default-impl</instance-name>
+        <port>6633</port>
+        <transport-protocol>TCP</transport-protocol>
+      </switch-connection-config>
+    ]]></odl:default-config>
+  </odl:clustered-app-config>
+
+  <bean id="defaultSwitchConnProvider" factory-ref="switchConnProviderFactory" factory-method="newInstance">
+    <argument ref="defaultSwitchConnConfig"/>
+  </bean>
+
+  <service ref="defaultSwitchConnProvider" interface="org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider"
+          odl:type="openflow-switch-connection-provider-default-impl"/>
+
+  <!-- Create OF switch connection provider on port 6653 -->
+  <odl:clustered-app-config id="legacySwitchConnConfig"
+      binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.config.rev160506.SwitchConnectionConfig"
+      list-key-value="openflow-switch-connection-provider-legacy-impl">
+    <odl:default-config><![CDATA[
+      <switch-connection-config xmlns="urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:config">
+        <instance-name>openflow-switch-connection-provider-legacy-impl</instance-name>
+        <port>6653</port>
+        <transport-protocol>TCP</transport-protocol>
+      </switch-connection-config>
+    ]]></odl:default-config>
+  </odl:clustered-app-config>
+
+  <bean id="legacySwitchConnProvider" factory-ref="switchConnProviderFactory" factory-method="newInstance">
+    <argument ref="legacySwitchConnConfig"/>
+  </bean>
+
+  <service ref="legacySwitchConnProvider" interface="org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider"
+          odl:type="openflow-switch-connection-provider-legacy-impl"/>
+
+  <!-- Create OpenflowPluginProvider instance -->
+
+  <odl:clustered-app-config id="openflowProviderConfig"
+      binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfig"/>
+
+  <reference id="openflowPluginProviderFactory"
+          interface="org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProviderFactory"/>
+
+  <bean id="openflowPluginProvider" factory-ref="openflowPluginProviderFactory" factory-method="newInstance">
+    <argument ref="openflowProviderConfig"/>
+    <argument ref="dataBroker"/>
+    <argument ref="rpcRegistry"/>
+    <argument ref="notificationService"/>
+    <argument ref="notificationPublishService"/>
+    <argument ref="entityOwnershipService"/>
+    <argument>
+      <list>
+        <ref component-id="defaultSwitchConnProvider"/>
+        <ref component-id="legacySwitchConnProvider"/>
+      </list>
+    </argument>
+  </bean>
+
+  <service ref="openflowPluginProvider" odl:type="openflow-plugin-provider-impl">
+    <interfaces>
+      <value>org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProvider</value>
+      <value>org.opendaylight.openflowplugin.extension.api.OpenFlowPluginExtensionRegistratorProvider</value>
+    </interfaces>
+  </service>
+
+</blueprint>
\ No newline at end of file
index 7a282c09dc0b9c53b21cdc95064bb181b91f8f20..0c9db146a83f134650d5da12538282b19ba1a98b 100644 (file)
@@ -6,6 +6,9 @@ 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
+
+NOTE: This file is deprecated as wiring is now done via blueprint. This file is kept for
+       backwards compatibility. Runtime modifications are not honored.
 -->
 <snapshot>
     <required-capabilities>
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderFactoryImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderFactoryImpl.java
new file mode 100644 (file)
index 0000000..202b177
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2016 Brocade Communications 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.openflowplugin.impl;
+
+import java.util.List;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
+import org.opendaylight.controller.md.sal.binding.api.NotificationService;
+import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
+import org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProvider;
+import org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProviderFactory;
+import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Implementation of OpenFlowPluginProviderFactory.
+ *
+ * @author Thomas Pantelis
+ */
+public class OpenFlowPluginProviderFactoryImpl implements OpenFlowPluginProviderFactory {
+    private static final Logger LOG = LoggerFactory.getLogger(OpenFlowPluginProviderFactoryImpl.class);
+
+    @Override
+    public OpenFlowPluginProvider newInstance(OpenflowProviderConfig providerConfig, DataBroker dataBroker,
+            RpcProviderRegistry rpcRegistry, NotificationService notificationService,
+            NotificationPublishService notificationPublishService,
+            EntityOwnershipService entityOwnershipService,
+            List<SwitchConnectionProvider> switchConnectionProviders) {
+
+        LOG.info("Initializing new OFP southbound.");
+
+        OpenflowPortsUtil.init();
+        OpenFlowPluginProvider openflowPluginProvider = new OpenFlowPluginProviderImpl(providerConfig.getRpcRequestsQuota(),
+                providerConfig.getGlobalNotificationQuota());
+
+        openflowPluginProvider.setSwitchConnectionProviders(switchConnectionProviders);
+        openflowPluginProvider.setDataBroker(dataBroker);
+        openflowPluginProvider.setRpcProviderRegistry(rpcRegistry);
+        openflowPluginProvider.setNotificationProviderService(notificationService);
+        openflowPluginProvider.setNotificationPublishService(notificationPublishService);
+        openflowPluginProvider.setEntityOwnershipService(entityOwnershipService);
+        openflowPluginProvider.setSwitchFeaturesMandatory(providerConfig.isSwitchFeaturesMandatory());
+        openflowPluginProvider.setIsStatisticsPollingOff(providerConfig.isIsStatisticsPollingOff());
+        openflowPluginProvider.setIsStatisticsRpcEnabled(providerConfig.isIsStatisticsRpcEnabled());
+        openflowPluginProvider.setBarrierCountLimit(providerConfig.getBarrierCountLimit().getValue());
+        openflowPluginProvider.setBarrierInterval(providerConfig.getBarrierIntervalTimeoutLimit().getValue());
+        openflowPluginProvider.setEchoReplyTimeout(providerConfig.getEchoReplyTimeout().getValue());
+
+        openflowPluginProvider.initialize();
+
+        LOG.info("Configured values, StatisticsPollingOff:{}, SwitchFeaturesMandatory:{}, BarrierCountLimit:{}, BarrierTimeoutLimit:{}, EchoReplyTimeout:{}",
+                providerConfig.isIsStatisticsPollingOff(), providerConfig.isSwitchFeaturesMandatory(),
+                providerConfig.getBarrierCountLimit().getValue(),
+                providerConfig.getBarrierIntervalTimeoutLimit().getValue(), providerConfig.getEchoReplyTimeout().getValue());
+
+        return openflowPluginProvider;
+    }
+}
index 4717561f7de4d8af3d5837bc0e87466bde33ff7c..b3096bb666b935815a69e226c16a0b59950a80ff 100644 (file)
@@ -1,14 +1,20 @@
 package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.config.openflow.plugin.impl.rev150327;
 
+import com.google.common.reflect.AbstractInvocationHandler;
+import com.google.common.reflect.Reflection;
+import java.lang.reflect.Method;
+import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
 import org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProvider;
-import org.opendaylight.openflowplugin.impl.OpenFlowPluginProviderImpl;
-import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.opendaylight.openflowplugin.extension.api.OpenFlowPluginExtensionRegistratorProvider;
+import org.osgi.framework.BundleContext;
 
-public class OpenFlowProviderModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.config.openflow.plugin.impl.rev150327.AbstractOpenFlowProviderModule {
+/**
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
+public class OpenFlowProviderModule extends AbstractOpenFlowProviderModule {
 
-    private static final Logger LOG = LoggerFactory.getLogger(OpenFlowProviderModule.class);
+    private BundleContext bundleContext;
 
     public OpenFlowProviderModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
         super(identifier, dependencyResolver);
@@ -19,37 +25,38 @@ public class OpenFlowProviderModule extends org.opendaylight.yang.gen.v1.urn.ope
     }
 
     @Override
-    public void customValidation() {
-        // add custom validation form module attributes here.
+    public AutoCloseable createInstance() {
+        // The service is provided via blueprint so wait for and return it here for backwards compatibility.
+        String typeFilter = String.format("(type=%s)", getIdentifier().getInstanceName());
+        final WaitingServiceTracker<OpenFlowPluginProvider> tracker = WaitingServiceTracker.create(
+                OpenFlowPluginProvider.class, bundleContext, typeFilter);
+        final OpenFlowPluginProvider openflowPluginProvider = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
+
+        // We don't want to call close on the actual service as its life cycle is controlled by blueprint but
+        // we do want to close the tracker so create a proxy to override close appropriately.
+        return Reflection.newProxy(OpenFlowPluginProviderProxyInterface.class, new AbstractInvocationHandler() {
+            @Override
+            protected Object handleInvocation(Object proxy, Method method, Object[] args) throws Throwable {
+                if (method.getName().equals("close")) {
+                    tracker.close();
+                    return null;
+                } else {
+                    return method.invoke(openflowPluginProvider, args);
+                }
+            }
+        });
+    }
+
+    public void setBundleContext(BundleContext bundleContext) {
+        this.bundleContext = bundleContext;
     }
 
     @Override
-    public java.lang.AutoCloseable createInstance() {
-        LOG.info("Initializing new OFP southbound.");
-        OpenflowPortsUtil.init();
-        final OpenFlowPluginProvider openflowPluginProvider = new OpenFlowPluginProviderImpl(getRpcRequestsQuota(), getGlobalNotificationQuota());
-
-        openflowPluginProvider.setSwitchConnectionProviders(getOpenflowSwitchConnectionProviderDependency());
-        openflowPluginProvider.setDataBroker(getDataBrokerDependency());
-        openflowPluginProvider.setRpcProviderRegistry(getRpcRegistryDependency());
-        openflowPluginProvider.setNotificationProviderService(getNotificationAdapterDependency());
-        openflowPluginProvider.setNotificationPublishService(getNotificationPublishAdapterDependency());
-        openflowPluginProvider.setSwitchFeaturesMandatory(getSwitchFeaturesMandatory());
-        openflowPluginProvider.setIsStatisticsPollingOff(getIsStatisticsPollingOff());
-        openflowPluginProvider.setEntityOwnershipService(getEntityOwnershipServiceDependency());
-        openflowPluginProvider.setIsStatisticsRpcEnabled(getIsStatisticsRpcEnabled());
-        openflowPluginProvider.setBarrierCountLimit(getBarrierCountLimit().getValue());
-        openflowPluginProvider.setBarrierInterval(getBarrierIntervalTimeoutLimit().getValue());
-        openflowPluginProvider.setEchoReplyTimeout(getEchoReplyTimeout().getValue());
-
-        openflowPluginProvider.initialize();
-
-        LOG.info("Configured values, StatisticsPollingOff:{}, SwitchFeaturesMandatory:{}, BarrierCountLimit:{}, BarrierTimeoutLimit:{}, EchoReplyTimeout:{}",
-                getIsStatisticsPollingOff(), getSwitchFeaturesMandatory(), getBarrierCountLimit().getValue(),
-                getBarrierIntervalTimeoutLimit().getValue(), getEchoReplyTimeout().getValue());
-
-
-        return openflowPluginProvider;
+    public boolean canReuseInstance(AbstractOpenFlowProviderModule oldModule) {
+        return true;
     }
 
+    private static interface OpenFlowPluginProviderProxyInterface extends OpenFlowPluginProvider,
+            OpenFlowPluginExtensionRegistratorProvider {
+    }
 }
index e7448330741b378ee1124bf136fb4478f046f4bf..454ba6b5a6e2ab076c0f23ba55ce62f555a5c2d7 100644 (file)
@@ -8,6 +8,29 @@
 * Do not modify this file unless it is present under src/main directory
 */
 package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.config.openflow.plugin.impl.rev150327;
-public class OpenFlowProviderModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.config.openflow.plugin.impl.rev150327.AbstractOpenFlowProviderModuleFactory {
 
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.osgi.framework.BundleContext;
+
+/**
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
+public class OpenFlowProviderModuleFactory extends AbstractOpenFlowProviderModuleFactory {
+    @Override
+    public OpenFlowProviderModule instantiateModule(String instanceName, DependencyResolver dependencyResolver,
+            OpenFlowProviderModule oldModule, AutoCloseable oldInstance, BundleContext bundleContext) {
+        OpenFlowProviderModule module = super.instantiateModule(instanceName, dependencyResolver, oldModule,
+                oldInstance, bundleContext);
+        module.setBundleContext(bundleContext);
+        return module;
+    }
+
+    @Override
+    public OpenFlowProviderModule instantiateModule(String instanceName, DependencyResolver dependencyResolver,
+            BundleContext bundleContext) {
+        OpenFlowProviderModule module = super.instantiateModule(instanceName, dependencyResolver, bundleContext);
+        module.setBundleContext(bundleContext);
+        return module;
+    }
 }
diff --git a/openflowplugin-impl/src/main/resources/org/opendaylight/blueprint/openflowplugin-impl.xml b/openflowplugin-impl/src/main/resources/org/opendaylight/blueprint/openflowplugin-impl.xml
new file mode 100644 (file)
index 0000000..20b907b
--- /dev/null
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0">
+
+  <bean id="ofPluginProviderFactory" class="org.opendaylight.openflowplugin.impl.OpenFlowPluginProviderFactoryImpl"/>
+
+  <service ref="ofPluginProviderFactory" interface="org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProviderFactory"
+          odl:type="default"/>
+</blueprint>
\ No newline at end of file
diff --git a/openflowplugin/.gitignore b/openflowplugin/.gitignore
deleted file mode 100644 (file)
index ea8c4bf..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/target
index dac95eb86b21ec91473eea8db875f9a43e37aa0c..58754980b056e55a3ea56f20250fa08864831720 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.openflowplugin.openflow.md.core.sal;
 import com.google.common.annotations.VisibleForTesting;
 import java.util.Collection;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
@@ -20,13 +21,12 @@ import org.opendaylight.openflowplugin.extension.api.OpenFlowPluginExtensionRegi
 import org.opendaylight.openflowplugin.extension.api.core.extension.ExtensionConverterManager;
 import org.opendaylight.openflowplugin.openflow.md.core.MDController;
 import org.opendaylight.openflowplugin.openflow.md.core.extension.ExtensionConverterManagerImpl;
+import org.opendaylight.openflowplugin.openflow.md.core.role.OfEntityManager;
 import org.opendaylight.openflowplugin.openflow.md.core.session.OFRoleManager;
 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
-import org.opendaylight.openflowplugin.openflow.md.core.role.OfEntityManager;
 import org.opendaylight.openflowplugin.statistics.MessageSpyCounterImpl;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.common.config.impl.rev140326.OfpRole;
 import org.opendaylight.yangtools.yang.binding.DataContainer;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -37,6 +37,8 @@ public class OpenflowPluginProvider implements AutoCloseable, OpenFlowPluginExte
 
     private static final Logger LOG = LoggerFactory.getLogger(OpenflowPluginProvider.class);
 
+    private static final boolean SKIP_TABLE_FEATURES = false;
+
     private Collection<SwitchConnectionProvider> switchConnectionProviders;
 
     private MDController mdController;
@@ -48,6 +50,7 @@ public class OpenflowPluginProvider implements AutoCloseable, OpenFlowPluginExte
     private ExtensionConverterManager extensionConverterManager;
 
     private OfpRole role;
+    private Boolean skipTableFeatures;
 
     private OFRoleManager roleManager;
     private OfEntityManager entManager;
@@ -58,6 +61,8 @@ public class OpenflowPluginProvider implements AutoCloseable, OpenFlowPluginExte
 
     private OpenflowPluginConfig openflowPluginConfig;
 
+
+
     /**
      * Initialization of services and msgSpy counter
      */
@@ -65,6 +70,7 @@ public class OpenflowPluginProvider implements AutoCloseable, OpenFlowPluginExte
         messageCountProvider = new MessageSpyCounterImpl();
         extensionConverterManager = new ExtensionConverterManagerImpl();
         roleManager = new OFRoleManager(OFSessionUtil.getSessionManager());
+        openflowPluginConfig = readConfig(skipTableFeatures);
         entManager = new OfEntityManager(entityOwnershipService,getOpenflowPluginConfig());
         entManager.setDataBroker(dataBroker);
         entManager.init();
@@ -95,10 +101,16 @@ public class OpenflowPluginProvider implements AutoCloseable, OpenFlowPluginExte
     @Override
     public void close() {
         LOG.debug("close");
-        mdController.stop();
-        mdController = null;
-        registrationManager.close();
-        registrationManager = null;
+
+        if(mdController != null) {
+            mdController.stop();
+            mdController = null;
+        }
+
+        if(registrationManager != null) {
+            registrationManager.close();
+            registrationManager = null;
+        }
     }
 
     public MessageCountDumper getMessageCountDumper() {
@@ -147,6 +159,20 @@ public class OpenflowPluginProvider implements AutoCloseable, OpenFlowPluginExte
         }
     }
 
+    private OpenflowPluginConfig readConfig(Boolean skipTableFeatures){
+
+        final OpenflowPluginConfig.OpenflowPluginConfigBuilder openflowCfgBuilder = OpenflowPluginConfig.builder();
+
+        if(skipTableFeatures !=null){
+            openflowCfgBuilder.setSkipTableFeatures(skipTableFeatures.booleanValue());
+        } else{
+            LOG.warn("Could not load XML configuration file via ConfigSubsystem! Fallback to default config value(s)");
+            openflowCfgBuilder.setSkipTableFeatures(SKIP_TABLE_FEATURES);
+        }
+
+        return openflowCfgBuilder.build();
+    }
+
     public void setDataBroker(DataBroker dataBroker) {
         this.dataBroker = dataBroker;
     }
@@ -163,8 +189,8 @@ public class OpenflowPluginProvider implements AutoCloseable, OpenFlowPluginExte
         this.entityOwnershipService = entityOwnershipService;
     }
 
-    public void setOpenflowPluginConfig(OpenflowPluginConfig openflowPluginConfig) {
-        this.openflowPluginConfig = openflowPluginConfig;
+    public void setSkipTableFeatures(Boolean skipTableFeatures) {
+        this.skipTableFeatures = skipTableFeatures;
     }
 
     @VisibleForTesting
index 0b52d395fd753774f1ecd93bdb3cf8d8cfe51f5d..8b45aba2a2d6ab5980125e8da52e16d1ddc10e81 100644 (file)
@@ -28,6 +28,7 @@ import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeUpdated;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeUpdatedBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
@@ -148,8 +149,9 @@ public class SalRegistrationManager implements SessionListener, AutoCloseable {
         FlowCapableNodeUpdatedBuilder builder2 = new FlowCapableNodeUpdatedBuilder();
         try {
             builder2.setIpAddress(getIpAddressOf(sw));
+            builder2.setPortNumber(getPortNumberOf(sw));
         } catch (Exception e) {
-            LOG.warn("IP address of the node {} cannot be obtained.", sw.getNodeId(), e);
+            LOG.warn("IP address/Port Number of the node {} cannot be obtained.", sw.getNodeId(), e);
         }
         builder2.setSwitchFeatures(swFeaturesUtil.buildSwitchFeatures(features));
         builder.addAugmentation(FlowCapableNodeUpdated.class, builder2.build());
@@ -183,6 +185,27 @@ public class SalRegistrationManager implements SessionListener, AutoCloseable {
         throw new IllegalArgumentException("Unsupported IP address type!");
     }
 
+    private static PortNumber getPortNumberOf(ModelDrivenSwitch sw) {
+        SessionContext sessionContext = sw.getSessionContext();
+
+        Preconditions.checkNotNull(sessionContext.getPrimaryConductor(),
+                "primary conductor must not be NULL -> " + sw.getNodeId());
+        Preconditions.checkNotNull(sessionContext.getPrimaryConductor().getConnectionAdapter(),
+                "connection adapter of primary conductor must not be NULL -> " + sw.getNodeId());
+        InetSocketAddress remoteAddress = sessionContext.getPrimaryConductor().getConnectionAdapter()
+                .getRemoteAddress();
+        if (remoteAddress == null) {
+            LOG.warn("Port Number of the node {} cannot be obtained. No connection with switch.", sw.getNodeId());
+            return null;
+        }
+        return resolvePortNumber(remoteAddress.getPort());
+    }
+
+    private static PortNumber resolvePortNumber(int port) {
+        PortNumber portNo = new PortNumber(port);
+        return portNo;
+    }
+
     private static NodeRemoved nodeRemoved(final NodeRef nodeRef) {
         NodeRemovedBuilder builder = new NodeRemovedBuilder();
         builder.setNodeRef(nodeRef);
index e4cb1c0c85afb33e433384a4f49f9385acad6e2b..fa2b8a8177827c6b6f8f089e15bda6cb957cfeb7 100644 (file)
@@ -11,6 +11,8 @@ import com.google.common.base.Optional;
 import java.math.BigInteger;
 import java.util.List;
 import java.util.concurrent.ExecutionException;
+
+import com.google.common.base.Splitter;
 import org.apache.commons.lang3.StringUtils;
 import org.opendaylight.controller.md.sal.binding.api.ReadTransaction;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
@@ -37,6 +39,7 @@ import org.slf4j.LoggerFactory;
 
 public abstract class InventoryDataServiceUtil {
     public static final  String OF_URI_PREFIX = "openflow:";
+    private static final Splitter COLON_SPLITTER = Splitter.on(":");
     private static final Logger LOG = LoggerFactory.getLogger(InventoryDataServiceUtil.class);
 
     /*
@@ -132,13 +135,14 @@ public abstract class InventoryDataServiceUtil {
     }
 
     public static String portNoStringfromNodeConnectorID(final String ncID) {
-       String[] split = ncID.split(":");
+
+        List<String> splitStringList = COLON_SPLITTER.splitToList(ncID);
 
         // It can happen that token length will be just 1 i.e 2 or CONTROLLER
         // If the length is just one then this cannot be the new MD-SAL style node connector Id which
         // is of the form openflow:1:3.
 
-        return split[split.length - 1];
+        return splitStringList.get(splitStringList.size()-1);
     }
 
     public static Long portNumberfromNodeConnectorId(final OpenflowVersion ofVersion, final String ncId) {
index 1542d5444bacf717e81ed154717b3f9987528975..3fd3e045f0598fd8dacdf1b3e994475d9b9d6718 100644 (file)
@@ -9,24 +9,30 @@
 */
 package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.common.config.impl.rev140326;
 
-import com.google.common.base.MoreObjects;
-import javax.management.ObjectName;
-
-import org.opendaylight.openflowplugin.openflow.md.core.sal.OpenflowPluginConfig;
+import java.util.Collection;
+import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
+import org.opendaylight.openflowplugin.api.openflow.statistics.MessageCountDumper;
+import org.opendaylight.openflowplugin.extension.api.ExtensionConverterRegistrator;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.OpenflowPluginProvider;
+import org.osgi.framework.BundleContext;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
-*
-*/
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
 public final class ConfigurableOpenFlowProviderModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.common.config.impl.rev140326.AbstractConfigurableOpenFlowProviderModule {
 
     private static final Logger LOG = LoggerFactory.getLogger(ConfigurableOpenFlowProviderModule.class);
 
-    private OpenflowPluginProvider pluginProvider;
-
-    private static final boolean SKIP_TABLE_FEATURES = false;
+    private BundleContext bundleContext;
 
     /**
      * @param identifier module identifier
@@ -54,58 +60,84 @@ public final class ConfigurableOpenFlowProviderModule extends org.opendaylight.y
     }
 
     @Override
-    public java.lang.AutoCloseable createInstance() {
-        pluginProvider =  new OpenflowPluginProvider();
-        pluginProvider.setDataBroker(getDataBrokerDependency());
-        pluginProvider.setNotificationService(getNotificationServiceDependency());
-        pluginProvider.setRpcRegistry(getRpcRegistryDependency());
-        pluginProvider.setSwitchConnectionProviders(getOpenflowSwitchConnectionProviderDependency());
-        pluginProvider.setEntityOwnershipService(getOwnershipServiceDependency());
-        pluginProvider.setRole(getRole());
-        pluginProvider.setOpenflowPluginConfig(readConfig());
-        pluginProvider.initialization();
-        return pluginProvider;
+    public AutoCloseable createInstance() {
+        // The service is provided via blueprint so wait for and return it here for backwards compatibility.
+        String typeFilter = String.format("(type=%s)", getIdentifier().getInstanceName());
+        final WaitingServiceTracker<OpenflowPluginProvider> tracker = WaitingServiceTracker.create(
+                OpenflowPluginProvider.class, bundleContext, typeFilter);
+        final OpenflowPluginProvider actualService = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
+
+        return new OpenflowPluginProvider() {
+            @Override
+            public void close() {
+                // Don't close the actual service as its life cycle is controlled by blueprint.
+                tracker.close();
+            }
+
+            @Override
+            public void initialization() {
+                actualService.initialization();
+            }
+
+            @Override
+            public void setSwitchConnectionProviders(Collection<SwitchConnectionProvider> switchConnectionProvider) {
+                actualService.setSwitchConnectionProviders(switchConnectionProvider);
+            }
+
+            @Override
+            public MessageCountDumper getMessageCountDumper() {
+                return actualService.getMessageCountDumper();
+            }
+
+            @Override
+            public ExtensionConverterRegistrator getExtensionConverterRegistrator() {
+                return actualService.getExtensionConverterRegistrator();
+            }
+
+            @Override
+            public void setRole(OfpRole role) {
+                actualService.setRole(role);
+            }
+
+            @Override
+            public void setSkipTableFeatures(Boolean skipTableFeatures) {
+                actualService.setSkipTableFeatures(skipTableFeatures);
+            }
+
+            @Override
+            public void fireRoleChange(OfpRole newRole) {
+                actualService.fireRoleChange(newRole);
+            }
+
+            @Override
+            public void setDataBroker(DataBroker dataBroker) {
+                actualService.setDataBroker(dataBroker);
+            }
+
+            @Override
+            public void setNotificationService(NotificationProviderService notificationService) {
+                actualService.setNotificationService(notificationService);
+            }
+
+            @Override
+            public void setRpcRegistry(RpcProviderRegistry rpcRegistry) {
+                actualService.setRpcRegistry(rpcRegistry);
+            }
+
+            @Override
+            public void setEntityOwnershipService(EntityOwnershipService entityOwnershipService) {
+                actualService.setEntityOwnershipService(entityOwnershipService);
+            }
+        };
     }
 
-    @Override
-    public boolean canReuseInstance(
-            AbstractConfigurableOpenFlowProviderModule oldModule) {
-        // we can reuse if only the role field changed
-        boolean noChangeExceptRole = true;
-        noChangeExceptRole &= dependencyResolver.canReuseDependency(
-                getDataBroker(), dataBrokerJmxAttribute);
-        noChangeExceptRole &= dependencyResolver.canReuseDependency(
-                getNotificationService(), notificationServiceJmxAttribute);
-        noChangeExceptRole &= dependencyResolver.canReuseDependency(
-                getRpcRegistry(), rpcRegistryJmxAttribute);
-
-        for (ObjectName ofSwitchProvider : getOpenflowSwitchConnectionProvider()) {
-            noChangeExceptRole &= dependencyResolver.canReuseDependency(
-                    ofSwitchProvider, openflowSwitchConnectionProviderJmxAttribute);
-        }
-        return noChangeExceptRole;
+    public void setBundleContext(BundleContext bundleContext) {
+        this.bundleContext = bundleContext;
     }
 
     @Override
-    public AutoCloseable reuseInstance(AutoCloseable oldInstance) {
-        OpenflowPluginProvider recycled = (OpenflowPluginProvider) super.reuseInstance(oldInstance);
-        // change role if different
-        recycled.fireRoleChange(MoreObjects.firstNonNull(getRole(), getRole()));
-
-        return recycled;
+    public boolean canReuseInstance(AbstractConfigurableOpenFlowProviderModule oldModule) {
+        return true;
     }
 
-    private OpenflowPluginConfig readConfig(){
-
-        final OpenflowPluginConfig.OpenflowPluginConfigBuilder openflowCfgBuilder = OpenflowPluginConfig.builder();
-
-        if(getSkipTableFeatures()!=null){
-            openflowCfgBuilder.setSkipTableFeatures(getSkipTableFeatures().booleanValue());
-        } else{
-            LOG.warn("Could not load XML configuration file via ConfigSubsystem! Fallback to default config value(s)");
-            openflowCfgBuilder.setSkipTableFeatures(SKIP_TABLE_FEATURES);
-        }
-
-        return openflowCfgBuilder.build();
-    }
 }
index dfa132202d5aa309c13967e47917d412d73bc21f..77f24c93ded99d08a5bc835d8072e529ae10212e 100644 (file)
@@ -9,11 +9,28 @@
 */
 package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.common.config.impl.rev140326;
 
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.osgi.framework.BundleContext;
 
 /**
- * the only purpose of this overwritings is to deliver bundleContext from osgi to module
+ * @deprecated Replaced by blueprint wiring
  */
-public class ConfigurableOpenFlowProviderModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.common.config.impl.rev140326.AbstractConfigurableOpenFlowProviderModuleFactory
-{
-    // nothing to override
+@Deprecated
+public class ConfigurableOpenFlowProviderModuleFactory extends AbstractConfigurableOpenFlowProviderModuleFactory {
+    @Override
+    public ConfigurableOpenFlowProviderModule instantiateModule(String instanceName, DependencyResolver dependencyResolver,
+            ConfigurableOpenFlowProviderModule oldModule, AutoCloseable oldInstance, BundleContext bundleContext) {
+        ConfigurableOpenFlowProviderModule module = super.instantiateModule(instanceName, dependencyResolver, oldModule,
+                oldInstance, bundleContext);
+        module.setBundleContext(bundleContext);
+        return module;
+    }
+
+    @Override
+    public ConfigurableOpenFlowProviderModule instantiateModule(String instanceName, DependencyResolver dependencyResolver,
+            BundleContext bundleContext) {
+        ConfigurableOpenFlowProviderModule module = super.instantiateModule(instanceName, dependencyResolver, bundleContext);
+        module.setBundleContext(bundleContext);
+        return module;
+    }
 }
index 2848c293ca34a812b3a44f9189213a1acc0a3d99..306638f2c1600892163f44af22c5245f720e4826 100644 (file)
@@ -16,5 +16,6 @@ module openflow-provider {
     identity openflow-provider{
         base config:service-type;
         config:java-class "org.opendaylight.openflowplugin.openflow.md.core.sal.OpenflowPluginProvider";
+        config:disable-osgi-service-registration;
     }
 }
\ No newline at end of file
index 55d68f818b8a1bf8d15f87c72aa93cae3cb4d4d0..52abd0da085ef574423c37220d85046f4e0a9b76 100644 (file)
@@ -34,8 +34,8 @@
         <openflowjava.version>0.8.0-SNAPSHOT</openflowjava.version>
         <openflowplugin.version>0.3.0-SNAPSHOT</openflowplugin.version>
         <sal.api.version>0.11.0-SNAPSHOT</sal.api.version>
-        <jmxGeneratorPath>src/main/yang-gen-config</jmxGeneratorPath>
-        <salGeneratorPath>src/main/yang-gen-sal</salGeneratorPath>
+        <jmxGeneratorPath>target/generated-sources/config</jmxGeneratorPath>
+        <salGeneratorPath>target/generated-sources/sal</salGeneratorPath>
         <exi.nagasena.version>0000.0002.0053.0</exi.nagasena.version>
         <controller.distribution.version>0.4.0-SNAPSHOT</controller.distribution.version>
 
                                         <ignore/>
                                     </action>
                                 </pluginExecution>
-                                <pluginExecution>
-                                    <pluginExecutionFilter>
-                                        <groupId>org.opendaylight.yangtools</groupId>
-                                        <artifactId>yang-maven-plugin</artifactId>
-                                        <versionRange>[0.5,)</versionRange>
-                                        <goals>
-                                            <goal>generate-sources</goal>
-                                        </goals>
-                                    </pluginExecutionFilter>
-                                    <action>
-                                        <execute/>
-                                    </action>
-                                </pluginExecution>
                                 <pluginExecution>
                                     <pluginExecutionFilter>
                                         <groupId>org.codehaus.groovy.maven</groupId>
diff --git a/pom.xml b/pom.xml
index bfd108b2d85eaf8850f6af41f31bfe5d0d7d0f20..9547c0502c10ccc36d20c48361f5985d45aa51e0 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -31,6 +31,8 @@
       <module>extension</module>
       <module>distribution/karaf</module>
       <module>openflowplugin-controller-config</module>
+      <module>openflowplugin-blueprint-config-he</module>
+      <module>openflowplugin-blueprint-config</module>
       <!--
       <module>openflowplugin-it</module>
       -->
diff --git a/test-scripts/.gitignore b/test-scripts/.gitignore
deleted file mode 100644 (file)
index 129a6a7..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-*.pyc
-/.pydevproject
-*.log
-.tox/