.settings\r
MANIFEST.MF\r
xtend-gen\r
-\r
+.externalToolBuilders\r
+maven-eclipse.xml\r
\r
<exclude>opendaylight/plugins/org.opendaylight.controller.protocol_plugins.openflow-*.jar</exclude>
</excludes>
</fileSet>
+ <fileSet>
+ <directory>
+ src/main/resources/
+ </directory>
+ <excludes>
+ <exclude>version.properties</exclude>
+ <exclude>configuration/config.ini</exclude>
+ </excludes>
+ <outputDirectory>
+ opendaylight/
+ </outputDirectory>
+ </fileSet>
</fileSets>
<dependencySets>
<dependencySet>
--- /dev/null
+<?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>
+ <required-capabilities>
+ <!-- openflowjava -->
+ <capability>urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:provider:impl?module=openflow-switch-connection-provider-impl&revision=2014-03-28</capability>
+ <capability>urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:provider?module=openflow-switch-connection-provider&revision=2014-03-28</capability>
+ <!-- openflowplugin -->
+ <capability>urn:opendaylight:params:xml:ns:yang:openflow:common:config:impl?module=openflow-provider-impl&revision=2014-03-26</capability>
+ <capability>urn:opendaylight:params:xml:ns:yang:openflow:common:config?module=openflow-provider&revision=2014-03-26</capability>
+ <!-- binding-broker-impl - provided -->
+ </required-capabilities>
+
+ <configuration>
+
+ <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+ <!-- default OF-switch-connection-provider (port 6633) -->
+ <module>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:provider:impl">prefix:openflow-switch-connection-provider-impl</type>
+ <name>openflow-switch-connection-provider-default-impl</name>
+ <port>6633</port>
+ <switch-idle-timeout>15000</switch-idle-timeout>
+ </module>
+ <!-- default OF-switch-connection-provider (port 6653) -->
+ <module>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:provider:impl">prefix:openflow-switch-connection-provider-impl</type>
+ <name>openflow-switch-connection-provider-legacy-impl</name>
+ <port>6653</port>
+ <switch-idle-timeout>15000</switch-idle-timeout>
+ </module>
+
+
+ <module>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:openflow:common:config:impl">prefix:openflow-provider-impl</type>
+ <name>openflow-provider-impl</name>
+
+ <openflow-switch-connection-provider>
+ <type xmlns:ofSwitch="urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:provider">ofSwitch:openflow-switch-connection-provider</type>
+ <name>openflow-switch-connection-provider-default</name>
+ </openflow-switch-connection-provider>
+ <openflow-switch-connection-provider>
+ <type xmlns:ofSwitch="urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:provider">ofSwitch:openflow-switch-connection-provider</type>
+ <name>openflow-switch-connection-provider-legacy</name>
+ </openflow-switch-connection-provider>
+
+
+ <binding-aware-broker>
+ <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
+ <name>binding-osgi-broker</name>
+ </binding-aware-broker>
+ </module>
+ </modules>
+
+ <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+ <service>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:provider">prefix:openflow-switch-connection-provider</type>
+ <instance>
+ <name>openflow-switch-connection-provider-default</name>
+ <provider>/modules/module[type='openflow-switch-connection-provider-impl'][name='openflow-switch-connection-provider-default-impl']</provider>
+ </instance>
+ <instance>
+ <name>openflow-switch-connection-provider-legacy</name>
+ <provider>/modules/module[type='openflow-switch-connection-provider-impl'][name='openflow-switch-connection-provider-legacy-impl']</provider>
+ </instance>
+ </service>
+
+ <service>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:openflow:common:config">prefix:openflow-provider</type>
+ <instance>
+ <name>openflow-provider</name>
+ <provider>/modules/module[type='openflow-provider-impl'][name='openflow-provider-impl']</provider>
+ </instance>
+ </service>
+ </services>
+ </data>
+
+ </configuration>
+</snapshot>
package org.opendaylight.openflowplugin.openflow.md.it;
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-
import org.ops4j.pax.exam.CoreOptions;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.options.DefaultCompositeOption;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+
/**
* @author mirehak
*
public static final String OFPLUGIN = "org.opendaylight.openflowplugin";
/** controller.model package */
public static final String CONTROLLER_MODEL = "org.opendaylight.controller.model";
+
/**
* Works only if property -DinspectOsgi is used
baseSalBundles(),
ofLibraryBundles(),
mavenBundle(CONTROLLER_MODEL, "model-flow-statistics").versionAsInProject(),
- mavenBundle(OFPLUGIN, "openflowplugin").versionAsInProject());
+ mavenBundle(OFPLUGIN, "openflowplugin").versionAsInProject(),
+ mavenBundle(CONTROLLER,"config-api").versionAsInProject());
}
/**
import org.opendaylight.openflowjava.protocol.impl.clients.ScenarioHandler;
import org.opendaylight.openflowjava.protocol.impl.clients.SimpleClient;
import org.opendaylight.openflowjava.protocol.impl.clients.SleepEvent;
-import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.OpenflowPluginProvider;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
.getLogger(OFPluginToLibraryTest.class);
@Inject @Filter(timeout=5000)
- SwitchConnectionProvider switchConnectionProvider;
+ OpenflowPluginProvider openflowPluginProvider;
@Inject
BundleContext ctx;
*/
@Before
public void setUp() throws InterruptedException {
- LOG.debug("switchConnectionProvider: "+switchConnectionProvider);
+ LOG.debug("openflowPluginProvider: "+openflowPluginProvider);
//FIXME: plugin should provide service exposing startup result via future
Thread.sleep(5000);
}
@Test
public void handshakeFail2() throws Exception {
LOG.debug("handshakeFail2 integration test");
- LOG.debug("switchConnectionProvider: "+switchConnectionProvider);
+ LOG.debug("openflowPluginProvider: "+openflowPluginProvider);
switchSim = createSimpleClient();
switchSim.setSecuredClient(false);
import org.opendaylight.controller.test.sal.binding.it.TestHelper;
import org.opendaylight.openflowjava.protocol.impl.clients.ScenarioHandler;
import org.opendaylight.openflowjava.protocol.impl.clients.SimpleClient;
-import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.OpenflowPluginProvider;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRemoved;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRemoved;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.util.Filter;
import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final Logger LOG = LoggerFactory.getLogger(SalIntegrationTest.class);
- @Inject
- SwitchConnectionProvider switchConnectionProvider;
-
@Inject
BundleContext ctx;
@Inject
BindingAwareBroker broker;
+
+ @Inject
+ @Filter(timeout=20*1000)
+ OpenflowPluginProvider openflowPluginProvider;
/**
* @return timeout for case of failure
};
ConsumerContext consumerReg = broker.registerConsumer(openflowConsumer, ctx);
assertNotNull(consumerReg);
-
+
LOG.debug("handshake integration test");
- LOG.debug("switchConnectionProvider: " + switchConnectionProvider);
+ LOG.debug("openflowPluginProvider: " + openflowPluginProvider);
SimpleClient switchSim = new SimpleClient("localhost", 6653);
switchSim.setSecuredClient(false);
TestHelper.configMinumumBundles(),
TestHelper.baseModelBundles(),
TestHelper.flowCapableModelBundles(),
-
+ OFPaxOptionsAssistant.ofLibraryBundles(),
OFPaxOptionsAssistant.ofPluginBundles()
);
}
<capability>
urn:opendaylight:params:xml:ns:yang:controller:md:sal:common?module=opendaylight-md-sal-common&revision=2013-10-28
</capability>
-
+
+ <!-- openflowjava -->
+ <capability>urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:provider:impl?module=openflow-switch-connection-provider-impl&revision=2014-03-28</capability>
+ <capability>urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:provider?module=openflow-switch-connection-provider&revision=2014-03-28</capability>
+ <!-- openflowplugin -->
+ <capability>urn:opendaylight:params:xml:ns:yang:openflow:common:config:impl?module=openflow-provider-impl&revision=2014-03-26</capability>
+ <capability>urn:opendaylight:params:xml:ns:yang:openflow:common:config?module=openflow-provider&revision=2014-03-26</capability>
</required-capabilities>
<configuration>
<name>ref_runtime-mapping-singleton</name>
</mapping-service>
</module>
+
+
+
+ <!-- default OF-switch-connection-provider (port 6633) -->
+ <module>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:provider:impl">prefix:openflow-switch-connection-provider-impl</type>
+ <name>openflow-switch-connection-provider-default-impl</name>
+ <port>6633</port>
+ <switch-idle-timeout>15000</switch-idle-timeout>
+ </module>
+ <!-- default OF-switch-connection-provider (port 6653) -->
+ <module>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:provider:impl">prefix:openflow-switch-connection-provider-impl</type>
+ <name>openflow-switch-connection-provider-legacy-impl</name>
+ <port>6653</port>
+ <switch-idle-timeout>15000</switch-idle-timeout>
+ </module>
+
+ <!-- default OF-plugin openflow-provider -->
+ <module>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:openflow:common:config:impl">prefix:openflow-provider-impl</type>
+ <name>openflow-provider-impl</name>
+
+ <openflow-switch-connection-provider>
+ <type xmlns:ofSwitch="urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:provider">ofSwitch:openflow-switch-connection-provider</type>
+ <name>openflow-switch-connection-provider-default</name>
+ </openflow-switch-connection-provider>
+ <openflow-switch-connection-provider>
+ <type xmlns:ofSwitch="urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:provider">ofSwitch:openflow-switch-connection-provider</type>
+ <name>openflow-switch-connection-provider-legacy</name>
+ </openflow-switch-connection-provider>
+
+ <binding-aware-broker>
+ <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
+ <name>ref_binding-broker-impl</name>
+ </binding-aware-broker>
+ </module>
</modules>
<services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
</provider>
</instance>
</service>
+
+ <!-- OFJava instances -->
+ <service>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:provider">prefix:openflow-switch-connection-provider</type>
+ <instance>
+ <name>openflow-switch-connection-provider-default</name>
+ <provider>/modules/module[type='openflow-switch-connection-provider-impl'][name='openflow-switch-connection-provider-default-impl']</provider>
+ </instance>
+ <instance>
+ <name>openflow-switch-connection-provider-legacy</name>
+ <provider>/modules/module[type='openflow-switch-connection-provider-impl'][name='openflow-switch-connection-provider-legacy-impl']</provider>
+ </instance>
+ </service>
+ <!-- OFPlugin instance -->
+ <service>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:openflow:common:config">prefix:openflow-provider</type>
+ <instance>
+ <name>openflow-provider</name>
+ <provider>/modules/module[type='openflow-provider-impl'][name='openflow-provider-impl']</provider>
+ </instance>
+ </service>
</services>
</data>
<artifactId>openflowplugin</artifactId>
<packaging>bundle</packaging>
+ <properties>
+ <yangtools.version>0.6.2-SNAPSHOT</yangtools.version>
+ <yangtools.generator.version>0.6.2-SNAPSHOT</yangtools.generator.version>
+ <yangtools.binding.version>0.6.2-SNAPSHOT</yangtools.binding.version>
+ <jmxGeneratorPath>${project.build.directory}/generated-sources/config</jmxGeneratorPath>
+ <sal-binding-api.version>1.1-SNAPSHOT</sal-binding-api.version>
+ </properties>
+
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
- <version>2.3.6</version>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-Activator>
- org.opendaylight.openflowplugin.openflow.md.Activator
- </Bundle-Activator>
- <Private-Package>
- org.opendaylight.openflowplugin.md.*
- </Private-Package>
- </instructions>
- <manifestLocation>${project.build.directory}/META-INF</manifestLocation>
- </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generate-sources</goal>
+ </goals>
+ <configuration>
+ <codeGenerators>
+ <generator>
+ <codeGeneratorClass>
+ org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+ </codeGeneratorClass>
+ <outputBaseDir>${project.build.directory}/generated-sources/config</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>${project.build.directory}/generated-sources/sal</outputBaseDir>
+ </generator>
+ <generator>
+ <codeGeneratorClass>org.opendaylight.yangtools.yang.unified.doc.generator.maven.DocumentationGeneratorImpl</codeGeneratorClass>
+ <outputBaseDir>${project.build.directory}/site/models</outputBaseDir>
+ </generator>
+ </codeGenerators>
+ <inspectDependencies>true</inspectDependencies>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>yang-jmx-generator-plugin</artifactId>
+ <version>0.2.5-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>maven-sal-api-gen-plugin</artifactId>
+ <version>${yangtools.version}</version>
+ <type>jar</type>
+ </dependency>
+ </dependencies>
</plugin>
</plugins>
</build>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-binding-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-binding-broker-impl</artifactId>
+ <version>${sal-binding-api.version}</version>
+ </dependency>
+
<dependency>
<groupId>org.opendaylight.openflowjava</groupId>
<artifactId>openflow-protocol-api</artifactId>
<groupId>org.opendaylight.openflowjava</groupId>
<artifactId>openflow-protocol-spi</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.openflowjava</groupId>
+ <artifactId>openflow-protocol-impl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>config-api</artifactId>
+ <version>0.2.5-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- <version>3.1</version>
- </dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ <version>3.1</version>
+ </dependency>
<dependency>
<groupId>equinoxSDK381</groupId>
<artifactId>org.eclipse.osgi</artifactId>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.mockito</groupId>
+ <groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>
-
+
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
+++ /dev/null
-/*
- * Copyright (c) 2013 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.openflowplugin.openflow.md;
-
-import org.apache.felix.dm.Component;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
-import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.OpenflowPluginProvider;
-import org.osgi.framework.BundleContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Openflow protocol plugin Activator
- */
-public class Activator extends ComponentActivatorAbstractBase {
- protected static final Logger logger = LoggerFactory.getLogger(Activator.class);
-
- private OpenflowPluginProvider pluginProvider = new OpenflowPluginProvider();
-
- /**
- * Function called when the activator starts just after some initializations
- * are done by the ComponentActivatorAbstractBase.
- *
- */
- @Override
- public void init() {
- super.init();
- }
-
- /**
- * Function called when the activator stops just before the cleanup done by
- * ComponentActivatorAbstractBase
- *
- */
- @Override
- public void destroy() {
- if (pluginProvider != null) {
- pluginProvider.close();
- }
- super.destroy();
- }
-
- @Override
- public void start(BundleContext arg0) {
- logger.debug("start");
- super.start(arg0);
- pluginProvider.setContext(arg0);
- }
-
- /**
- * Function that is used to communicate to dependency manager the list of
- * known implementations for services inside a container
- *
- *
- * @return An array containing all the CLASS objects that will be
- * instantiated in order to get an fully working implementation
- * Object
- */
- @Override
- public Object[] getImplementations() {
- Object[] res = {};
- return res;
- }
-
- /**
- * Function that is called when configuration of the dependencies is
- * required.
- *
- * @param c
- * dependency manager Component object, used for configuring the
- * dependencies exported and imported
- * @param imp
- * Implementation class that is being configured, needed as long
- * as the same routine can configure multiple implementations
- * @param containerName
- * The containerName being configured, this allow also optional
- * per-container different behavior if needed, usually should not
- * be the case though.
- */
- @Override
- public void configureInstance(Component c, Object imp, String containerName) {
- // NOOP
- }
-
- /**
- * Function that is used to communicate to dependency manager the list of
- * known implementations for services that are container independent.
- *
- *
- * @return An array containing all the CLASS objects that will be
- * instantiated in order to get an fully working implementation
- * Object
- */
- @Override
- public Object[] getGlobalImplementations() {
- Object[] res = { pluginProvider };
- return res;
- }
-
- /**
- * Function that is called when configuration of the dependencies is
- * required.
- *
- * @param c
- * dependency manager Component object, used for configuring the
- * dependencies exported and imported
- * @param imp
- * Implementation class that is being configured, needed as long
- * as the same routine can configure multiple implementations
- */
- @Override
- public void configureGlobalInstance(Component c, Object imp) {
- if (pluginProvider == imp) {
- c.add(createServiceDependency().setService(BindingAwareBroker.class)
- .setCallbacks("setBroker", "unsetBroker").setRequired(true));
- c.add(createServiceDependency().setService(SwitchConnectionProvider.class)
- .setCallbacks("setSwitchConnectionProvider", "unsetSwitchConnectionProvider").setRequired(true));
- logger.debug("configuring Binding Aware Provider");
- }
- }
-
-}
Exception error;
try {
error = errorQueue.take();
+ if (error instanceof QueueShutdownItem) {
+ break;
+ }
Throwable cause = error.getCause();
LOG.error(error.getMessage()+" -> "+cause.getMessage(), cause);
} catch (InterruptedException e) {
}
@Override
- public void close() throws Exception {
- //TODO: add special exception to queue and recognize it in run method
+ public void close() {
+ // add special exception to queue and recognize it in run method
+ errorQueue.add(new QueueShutdownItem());
+ }
+
+ static class QueueShutdownItem extends Exception {
+ private static final long serialVersionUID = 1L;
+ // nothing
}
}
package org.opendaylight.openflowplugin.openflow.md.core;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.List;
import org.slf4j.LoggerFactory;
import com.google.common.collect.Lists;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.JdkFutureAdapters;
+import com.google.common.util.concurrent.ListenableFuture;
/**
* @author mirehak
private static final Logger LOG = LoggerFactory.getLogger(MDController.class);
- private SwitchConnectionProvider switchConnectionProvider;
+ private Collection<SwitchConnectionProvider> switchConnectionProviders;
private ConcurrentMap<TranslatorKey, Collection<IMDMessageTranslator<OfHeader, List<DataObject>>>> messageTranslators;
private Map<Class<? extends DataObject>, Collection<PopListener<DataObject>>> popListeners;
final private int OF10 = OFConstants.OFP_VERSION_1_0;
final private int OF13 = OFConstants.OFP_VERSION_1_3;
+ private ErrorHandlerQueueImpl errorHandler;
+
/**
* @return translator mapping
}
/**
- * @param switchConnectionProvider
- * the switchConnectionProvider to set
- */
- public void setSwitchConnectionProvider(SwitchConnectionProvider switchConnectionProvider) {
- this.switchConnectionProvider = switchConnectionProvider;
- }
-
- /**
- * @param switchConnectionProviderToUnset
- * the switchConnectionProvider to unset
+ * @param switchConnectionProviders
+ * the switchConnectionProviders to set
*/
- public void unsetSwitchConnectionProvider(SwitchConnectionProvider switchConnectionProviderToUnset) {
- if (this.switchConnectionProvider == switchConnectionProviderToUnset) {
- this.switchConnectionProvider = null;
- }
+ public void setSwitchConnectionProviders(Collection<SwitchConnectionProvider> switchConnectionProviders) {
+ this.switchConnectionProviders = switchConnectionProviders;
}
/**
*/
public void start() {
LOG.debug("starting ..");
- LOG.debug("switchConnectionProvider: " + switchConnectionProvider);
+ LOG.debug("switchConnectionProvider: " + switchConnectionProviders);
// setup handler
SwitchConnectionHandlerImpl switchConnectionHandler = new SwitchConnectionHandlerImpl();
switchConnectionHandler.setMessageSpy(messageSpyCounter);
- ErrorHandlerQueueImpl errorHandler = new ErrorHandlerQueueImpl();
+ errorHandler = new ErrorHandlerQueueImpl();
new Thread(errorHandler).start();
switchConnectionHandler.setErrorHandler(errorHandler);
switchConnectionHandler.init();
- switchConnectionProvider.setSwitchConnectionHandler(switchConnectionHandler);
-
- // configure and startup library servers
- switchConnectionProvider.configure(getConnectionConfiguration());
- Future<List<Boolean>> srvStarted = switchConnectionProvider.startup();
+ List<ListenableFuture<Boolean>> starterChain = new ArrayList<>();
+ for (SwitchConnectionProvider switchConnectionPrv : switchConnectionProviders) {
+ switchConnectionPrv.setSwitchConnectionHandler(switchConnectionHandler);
+ ListenableFuture<Boolean> isOnlineFuture = switchConnectionPrv.startup();
+ starterChain.add(isOnlineFuture);
+ }
+
+ Future<List<Boolean>> srvStarted = Futures.allAsList(starterChain);
}
/**
*/
public void stop() {
LOG.debug("stopping");
- Future<List<Boolean>> srvStopped = switchConnectionProvider.shutdown();
+ List<ListenableFuture<Boolean>> stopChain = new ArrayList<>();
try {
- srvStopped.get(5000, TimeUnit.MILLISECONDS);
+ for (SwitchConnectionProvider switchConnectionPrv : switchConnectionProviders) {
+ ListenableFuture<Boolean> shutdown = switchConnectionPrv.shutdown();
+ stopChain.add(shutdown);
+ }
+ Futures.allAsList(stopChain).get(5000, TimeUnit.MILLISECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
LOG.error(e.getMessage(), e);
}
messageSpyCounter = null;
messageTranslators = null;
popListeners = null;
- switchConnectionProvider.setSwitchConnectionHandler(null);
- switchConnectionProvider = null;
+ for (SwitchConnectionProvider switchConnectionPrv : switchConnectionProviders) {
+ switchConnectionPrv.setSwitchConnectionHandler(null);
+ }
+ switchConnectionProviders = null;
OFSessionUtil.releaseSessionManager();
+ errorHandler.close();
}
}
private BundleContext ctx;
private MessageCountDumper provider;
- private ServiceRegistration commandRegistration;
+ private ServiceRegistration<?> commandRegistration;
/**
* @param ctx
private BundleContext context;
- private SwitchConnectionProvider switchConnectionProvider;
+ private Collection<SwitchConnectionProvider> switchConnectionProviders;
private MDController mdController;
private SalRegistrationManager registrationManager;
/**
- * dependencymanager requirement
- * @param switchConnectionProviderArg
- */
- public void unsetSwitchConnectionProvider(SwitchConnectionProvider switchConnectionProviderArg) {
- switchConnectionProvider = null;
- }
-
- /**
- * dependencymanager requirement
* @param switchConnectionProvider
*/
- public void setSwitchConnectionProvider(
- SwitchConnectionProvider switchConnectionProvider) {
- this.switchConnectionProvider = switchConnectionProvider;
- registerProvider();
+ public void setSwitchConnectionProviders(Collection<SwitchConnectionProvider> switchConnectionProvider) {
+ this.switchConnectionProviders = switchConnectionProvider;
}
/**
/**
* dependencymanager requirement
* @param context
+ *
+ * @deprecated we should stop relying on osgi to provide cli interface for messageCounter
*/
+ @Deprecated
public void setContext(BundleContext context) {
this.context = context;
}
registrationManager = new SalRegistrationManager();
registrationManager.onSessionInitiated(session);
mdController = new MDController();
- mdController.setSwitchConnectionProvider(switchConnectionProvider);
+ mdController.setSwitchConnectionProviders(switchConnectionProviders);
mdController.setMessageSpyCounter(messageCountProvider);
mdController.init();
mdController.start();
*/
public void setBroker(BindingAwareBroker broker) {
this.broker = broker;
- registerProvider();
}
/**
}
private boolean hasAllDependencies(){
- if(this.broker != null && this.switchConnectionProvider != null) {
+ if(this.broker != null && this.switchConnectionProviders != null) {
return true;
}
return false;
}
- private void registerProvider() {
+
+ /**
+ * register providers for md-sal
+ */
+ public void registerProvider() {
+ //FIXME: is it needed
if(hasAllDependencies()) {
this.broker.registerProvider(this,context);
}
--- /dev/null
+/**
+* Generated file
+
+* Generated from: yang module name: openflow-provider-impl yang module local name: openflow-provider-impl
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Wed Apr 02 16:59:36 PDT 2014
+*
+* 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.openflow.common.config.impl.rev140326;
+
+import org.opendaylight.openflowplugin.openflow.md.core.sal.OpenflowPluginProvider;
+import org.osgi.framework.BundleContext;
+
+/**
+*
+*/
+public final class ConfigurableOpenFlowProviderModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.common.config.impl.rev140326.AbstractConfigurableOpenFlowProviderModule {
+
+ private OpenflowPluginProvider pluginProvider;
+ private BundleContext bundleContext;
+
+ /**
+ * @param identifier
+ * @param dependencyResolver
+ */
+ public ConfigurableOpenFlowProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ super(identifier, dependencyResolver);
+ }
+
+ /**
+ * @param identifier
+ * @param dependencyResolver
+ * @param oldModule
+ * @param oldInstance
+ */
+ public ConfigurableOpenFlowProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+ ConfigurableOpenFlowProviderModule oldModule, java.lang.AutoCloseable oldInstance) {
+
+ super(identifier, dependencyResolver, oldModule, oldInstance);
+ }
+
+ @Override
+ protected void customValidation() {
+ // Add custom validation for module attributes here.
+ }
+
+ @Override
+ public java.lang.AutoCloseable createInstance() {
+ pluginProvider = new OpenflowPluginProvider();
+ pluginProvider.setContext(bundleContext);
+ pluginProvider.setBroker(getBindingAwareBrokerDependency());
+ pluginProvider.setSwitchConnectionProviders(getOpenflowSwitchConnectionProviderDependency());
+ pluginProvider.registerProvider();
+ return pluginProvider;
+ }
+
+ /**
+ * @param bundleContext the bundleContext to set, see {@link OpenflowPluginProvider#setContext(BundleContext)}
+ *
+ * @deprecated we should avoid osgi specific stuff .. once,
+ */
+ @Deprecated
+ public void setBundleContext(BundleContext bundleContext) {
+ this.bundleContext = bundleContext;
+ }
+}
--- /dev/null
+/**
+* Generated file
+
+* Generated from: yang module name: openflow-provider-impl yang module local name: openflow-provider-impl
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Wed Apr 02 16:59:36 PDT 2014
+*
+* 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.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
+ */
+public class ConfigurableOpenFlowProviderModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.common.config.impl.rev140326.AbstractConfigurableOpenFlowProviderModuleFactory
+{
+ @Override
+ public ConfigurableOpenFlowProviderModule instantiateModule(
+ String instanceName, DependencyResolver dependencyResolver,
+ BundleContext bundleContext) {
+ ConfigurableOpenFlowProviderModule module = super.instantiateModule(instanceName, dependencyResolver, bundleContext);
+ module.setBundleContext(bundleContext);
+ return module;
+ }
+
+ @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;
+ }
+}
--- /dev/null
+module openflow-provider-impl {
+ yang-version 1;
+ namespace "urn:opendaylight:params:xml:ns:yang:openflow:common:config:impl";
+ prefix "ofplugin-cfg-impl";
+
+ import config {prefix config; revision-date 2013-04-05;}
+ import openflow-provider {prefix openflow-provider;}
+ import openflow-switch-connection-provider {prefix openflow-switch-connection-provider;revision-date 2014-03-28;}
+ import opendaylight-md-sal-binding { prefix md-sal-binding; revision-date 2013-10-28;}
+
+
+ description
+ "openflow-plugin-custom-config-impl";
+
+ revision "2014-03-26" {
+ description
+ "Initial revision";
+ }
+
+ identity openflow-provider-impl {
+ base config:module-type;
+ config:provided-service openflow-provider:openflow-provider;
+ config:java-name-prefix ConfigurableOpenFlowProvider;
+ }
+
+ augment "/config:modules/config:module/config:configuration" {
+ case openflow-provider-impl {
+ when "/config:modules/config:module/config:type = 'openflow-provider-impl'";
+
+ container binding-aware-broker {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity md-sal-binding:binding-broker-osgi-registry;
+ }
+ }
+ }
+ list openflow-switch-connection-provider {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity openflow-switch-connection-provider:openflow-switch-connection-provider;
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+module openflow-provider {
+ yang-version 1;
+ namespace "urn:opendaylight:params:xml:ns:yang:openflow:common:config";
+ prefix "ofplugin-cfg";
+
+ import config {prefix config; revision-date 2013-04-05; }
+
+ description
+ "openflow-plugin-custom-config";
+
+ revision "2014-03-26" {
+ description
+ "Initial revision";
+ }
+
+ identity openflow-provider{
+ base config:service-type;
+ config:java-class "org.opendaylight.openflowplugin.openflow.md.core.sal.OpenflowPluginProvider";
+ }
+}
\ No newline at end of file
<xtend.dstdir>src/main/xtend-gen</xtend.dstdir>
<jmxGeneratorPath>src/main/yang-gen-config</jmxGeneratorPath>
<salGeneratorPath>src/main/yang-gen-sal</salGeneratorPath>
+ <maven.bundle.version>2.4.0</maven.bundle.version>
</properties>
<dependencyManagement>
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-maven-plugin</artifactId>
+ <version>0.6.2-SNAPSHOT</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>${maven.bundle.version}</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
+ </instructions>
+ <manifestLocation>${project.build.directory}/META-INF</manifestLocation>
+ </configuration>
+ </plugin>
</plugins>
</pluginManagement>
</build>