changes for config subsystem - BUG 754 18/6218/1
authorMichal Rehak <mirehak@cisco.com>
Mon, 14 Apr 2014 16:35:03 +0000 (18:35 +0200)
committerMichal Polkorab <michal.polkorab@pantheon.sk>
Tue, 15 Apr 2014 15:55:58 +0000 (15:55 +0000)
integration - issue with initialization pending
added sal generator
changed SPI - SwitchConnectionProvider has 1:1 bound with ServerFacade
extended yang model of SwitchConnectionProvider configuration
restored exported packages for osgi
restored documentation generator
changed API in order to use ListenableFuture instead of plain Future

Change-Id: Ic21e3a0c1fd64584d98485567c26095674291548
Signed-off-by: Basheeruddin Ahmed <syedbahm@cisco.com>
Signed-off-by: Michal Rehak <mirehak@cisco.com>
(cherry picked from commit cbe4871cddf78adab335b5270269b6e704eb8bf9)

openflow-protocol-api/pom.xml
openflow-protocol-impl/pom.xml
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/Activator.java [deleted file]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java
openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModuleFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang [new file with mode: 0644]
openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider.yang [new file with mode: 0644]
openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/impl/integration/IntegrationTest.java
openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java
pom.xml

index 3cb45dfaf4144a671a01225662df33408d6fa0c8..eac0aee7fb7a3c70a67030bf784c8fae0d329837 100644 (file)
@@ -14,8 +14,6 @@
   </scm>
 
     <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>
     </properties>
 
@@ -24,7 +22,6 @@
             <plugin>
                 <groupId>org.opendaylight.yangtools</groupId>
                 <artifactId>yang-maven-plugin</artifactId>
-                <version>${yangtools.version}</version>
                 <executions>
                     <execution>
                         <goals>
index e897f83129279f444099750f9f5f34344d452495..69fe7280a5ae942b7fdc701a55644041163716e6 100644 (file)
         <url>https://wiki.opendaylight.org/view/Openflow_Protocol_Library:Main</url>
       <tag>HEAD</tag>
   </scm>
+
+    <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>
+    </properties>
     
     <build>
         <plugins>
             <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-bundle-plugin</artifactId>
-                <configuration>
-                    <instructions>
-                        <Bundle-Activator>
-                          org.opendaylight.openflowjava.protocol.impl.connection.Activator
-                        </Bundle-Activator>
-                        <Export-Package>org.opendaylight.openflowjava.protocol.impl.*</Export-Package>
-                    </instructions>
-                </configuration>
+              <groupId>org.apache.felix</groupId>
+              <artifactId>maven-bundle-plugin</artifactId>
+              <extensions>true</extensions>
+              <configuration>
+                <instructions>
+                    <Export-Package>
+                      org.opendaylight.openflowjava.protocol.impl.*,
+                      org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.provider.*
+                    </Export-Package>
+                </instructions>
+              </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>${config.version}</version>
+                    </dependency>
+                    <dependency>
+                        <groupId>org.opendaylight.yangtools</groupId>
+                        <artifactId>maven-sal-api-gen-plugin</artifactId>
+                        <version>${yangtools.generator.version}</version>
+                        <type>jar</type>
+                    </dependency>
+                </dependencies>
             </plugin>
         </plugins>
     </build>
             <groupId>org.mockito</groupId>
             <artifactId>mockito-all</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>config-api</artifactId>
+            <version>0.2.5-SNAPSHOT</version>
+        </dependency>
     </dependencies>
 </project>
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/Activator.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/Activator.java
deleted file mode 100644 (file)
index f028d78..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2013 Pantheon Technologies s.r.o. 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.openflowjava.protocol.impl.connection;
-
-import java.util.Hashtable;
-
-import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * Activates library bundle, exposes provided implementations:
- * <ul>
- *  <li>{@link SwitchConnectionProviderImpl}</li>
- * </ul>
- * 
- * @author mirehak
- */
-public class Activator implements BundleActivator {
-    
-    private static final Logger LOG = LoggerFactory.getLogger(Activator.class);
-
-    @Override
-    public void start(BundleContext context) throws Exception {
-        LOG.debug("starting OF Library");
-        Hashtable<String, String> props = new Hashtable<>();
-        props.put("type", "default");
-        context.registerService(
-                SwitchConnectionProvider.class.getName(), 
-                new SwitchConnectionProviderImpl(), props);
-        LOG.debug("started OF Library");
-    }
-
-    @Override
-    public void stop(BundleContext context) throws Exception {
-        LOG.debug("stopping OF Library");
-        //TODO:: add teardown activities (check, if servers are running, stop if necessary..)
-    }
-}
index d9e9f64ef7abad9cf751e243cf62b36e402b43a3..3e45b174623e7e2cbf3ec183fda1bc99f649db63 100644 (file)
@@ -9,11 +9,6 @@
 
 package org.opendaylight.openflowjava.protocol.impl.connection;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
 import java.util.concurrent.Future;
 
 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration;
@@ -24,7 +19,6 @@ import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionPro
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.SettableFuture;
 
@@ -38,22 +32,12 @@ public class SwitchConnectionProviderImpl implements SwitchConnectionProvider {
     private static final Logger LOGGER = LoggerFactory
             .getLogger(SwitchConnectionProviderImpl.class);
     private SwitchConnectionHandler switchConnectionHandler;
-    private Set<ServerFacade> serverLot;
+    private ServerFacade serverFacade;
+    private ConnectionConfiguration connConfig;
 
     @Override
-    public void configure(Collection<ConnectionConfiguration> connConfigs) {
-        LOGGER.debug("Configuring ..");
-
-        //TODO - configure servers according to configuration
-        serverLot = new HashSet<>();
-        for (ConnectionConfiguration connConfig : connConfigs) {
-            TcpHandler server = new TcpHandler(connConfig.getAddress(), connConfig.getPort());
-            server.setSwitchConnectionHandler(switchConnectionHandler);
-            server.setSwitchIdleTimeout(connConfig.getSwitchIdleTimeout());
-            boolean tlsSupported = FEATURE_SUPPORT.REQUIRED.equals(connConfig.getTlsSupport());
-            server.setEncryption(tlsSupported);
-            serverLot.add(server);
-        }
+    public void setConfiguration(ConnectionConfiguration connConfig) {
+        this.connConfig = connConfig;
     }
 
     @Override
@@ -63,68 +47,63 @@ public class SwitchConnectionProviderImpl implements SwitchConnectionProvider {
     }
 
     @Override
-    public Future<List<Boolean>> shutdown() {
+    public ListenableFuture<Boolean> shutdown() {
         LOGGER.debug("Shutdown summoned");
-        ListenableFuture<List<Boolean>> result = SettableFuture.create();
-        try {
-            List<ListenableFuture<Boolean>> shutdownChain = new ArrayList<>();
-            for (ServerFacade server : serverLot) {
-                ListenableFuture<Boolean> shutdownFuture = server.shutdown();
-                shutdownChain.add(shutdownFuture);
-            }
-            if (!shutdownChain.isEmpty()) {
-                result = Futures.allAsList(shutdownChain);
-            } else {
-                throw new IllegalStateException("No servers configured");
-            }
-        } catch (Exception e) {
-            SettableFuture<List<Boolean>> exFuture = SettableFuture.create();
-            exFuture.setException(e);
-            result = exFuture;
-        }
+        //TODO: provide exception in case of: not started, not configured (already stopped)
+        ListenableFuture<Boolean> result = serverFacade.shutdown();
         return result;
     }
 
     @Override
-    public Future<List<Boolean>> startup() {
-        LOGGER.debug("startup summoned");
-        ListenableFuture<List<Boolean>> result = SettableFuture.create();
+    public ListenableFuture<Boolean> startup() {
+        LOGGER.debug("Startup summoned");
+        serverFacade = createAndConfigureServer();
+        
+        LOGGER.debug("Starting ..");
+        ListenableFuture<Boolean> result = null;
         try {
-            if (serverLot.isEmpty()) {
-                throw new IllegalStateException("No servers configured");
+            if (serverFacade == null) {
+                throw new IllegalStateException("No server configured");
             }
-            for (ServerFacade server : serverLot) {
-                if (server.getIsOnlineFuture().isDone()) {
-                    throw new IllegalStateException("Servers already running");
-                }
+            if (serverFacade.getIsOnlineFuture().isDone()) {
+                throw new IllegalStateException("Server already running");
             }
             if (switchConnectionHandler == null) {
                 throw new IllegalStateException("switchConnectionHandler is not set");
             }
-            List<ListenableFuture<Boolean>> starterChain = new ArrayList<>();
-            for (ServerFacade server : serverLot) {
-                new Thread(server).start();
-                ListenableFuture<Boolean> isOnlineFuture = server.getIsOnlineFuture();
-                starterChain.add(isOnlineFuture);
-            }
-            if (!starterChain.isEmpty()) {
-                result = Futures.allAsList(starterChain);
-            } else {
-                throw new IllegalStateException("No servers configured");
-            }
+            new Thread(serverFacade).start();
+            result = serverFacade.getIsOnlineFuture();
         } catch (Exception e) {
-            SettableFuture<List<Boolean>> exFuture = SettableFuture.create();
-            exFuture.setException(e);
-            result = exFuture;
+            SettableFuture<Boolean> exResult = SettableFuture.create();
+            exResult.setException(e);
+            result = exResult;
         }
         return result;
     }
 
+    /**
+     * @return
+     */
+    private TcpHandler createAndConfigureServer() {
+        LOGGER.debug("Configuring ..");
+        TcpHandler server = new TcpHandler(connConfig.getAddress(), connConfig.getPort());
+        server.setSwitchConnectionHandler(switchConnectionHandler);
+        server.setSwitchIdleTimeout(connConfig.getSwitchIdleTimeout());
+        boolean tlsSupported = FEATURE_SUPPORT.REQUIRED.equals(connConfig.getTlsSupport());
+        server.setEncryption(tlsSupported);
+        
+        return server;
+    }
+
     /**
      * @return servers
      */
-    public Set<ServerFacade> getServerLot() {
-        return serverLot;
+    public ServerFacade getServerFacade() {
+        return serverFacade;
     }
 
+    @Override
+    public void close() throws Exception {
+        shutdown();
+    }
 }
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java b/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java
new file mode 100644 (file)
index 0000000..6dbdef0
--- /dev/null
@@ -0,0 +1,137 @@
+/**
+* Generated file
+
+* Generated from: yang module name: openflow-switch-connection-provider-impl  yang module local name: openflow-switch-connection-provider-impl
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Fri Mar 28 17:50:58 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._switch.connection.provider.impl.rev140328;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration;
+import org.opendaylight.openflowjava.protocol.impl.connection.SwitchConnectionProviderImpl;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+*
+*/
+public final class SwitchConnectionProviderModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.provider.impl.rev140328.AbstractSwitchConnectionProviderModule
+ {
+    
+    private static Logger LOG = LoggerFactory
+            .getLogger(SwitchConnectionProviderModule.class);
+
+    /**
+     * @param identifier
+     * @param dependencyResolver
+     */
+    public SwitchConnectionProviderModule(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 SwitchConnectionProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+            SwitchConnectionProviderModule 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() {
+        LOG.info("SwitchConnectionProvider started.");
+        SwitchConnectionProviderImpl switchConnectionProviderImpl = new SwitchConnectionProviderImpl();
+        try {
+            ConnectionConfiguration connConfiguration = createConnectionConfiguration();
+            switchConnectionProviderImpl.setConfiguration(connConfiguration);
+        } catch (UnknownHostException e) {
+            throw new IllegalArgumentException(e.getMessage(), e);
+        }
+        return switchConnectionProviderImpl;
+    }
+
+    /**
+     * @return
+     * @throws UnknownHostException 
+     */
+    private ConnectionConfiguration createConnectionConfiguration() throws UnknownHostException {
+        final InetAddress address = extractIpAddressBin(getAddress());
+        final Integer port = getPort();
+        final long switchIdleTimeout = getSwitchIdleTimeout();
+        
+        return new ConnectionConfiguration() {
+            @Override
+            public InetAddress getAddress() {
+                return address;
+            }
+            @Override
+            public int getPort() {
+                return port;
+            }
+            @Override
+            public Object getTransferProtocol() {
+                // TODO Auto-generated method stub
+                return null;
+            }
+            @Override
+            public FEATURE_SUPPORT getTlsSupport() {
+                // TODO Auto-generated method stub
+                return null;
+            }
+            @Override
+            public long getSwitchIdleTimeout() {
+                return switchIdleTimeout;
+            }
+            @Override
+            public Object getSslContext() {
+                // TODO Auto-generated method stub
+                return null;
+            }
+        };
+    }
+
+    /**
+     * @param address
+     * @return
+     * @throws UnknownHostException 
+     */
+    private static InetAddress extractIpAddressBin(IpAddress address) throws UnknownHostException {
+        byte[] addressBin = null;
+        if (address != null) {
+            if (address.getIpv4Address() != null) {
+                addressBin = address2bin(address.getIpv4Address().getValue());
+            } else if (address.getIpv6Address() != null) {
+                addressBin = address2bin(address.getIpv6Address().getValue());
+            }
+        }
+        
+        if (addressBin == null) {
+            return null;
+        } else {
+            return InetAddress.getByAddress(addressBin);
+        }
+    }
+
+    /**
+     * @param value
+     * @return
+     */
+    private static byte[] address2bin(String value) {
+        //TODO: translate ipv4 or ipv6 into byte[]
+        return null;
+    }
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModuleFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModuleFactory.java
new file mode 100644 (file)
index 0000000..6bf1423
--- /dev/null
@@ -0,0 +1,19 @@
+/**
+* Generated file
+
+* Generated from: yang module name: openflow-switch-connection-provider-impl  yang module local name: openflow-switch-connection-provider-impl
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Fri Mar 28 17:50:58 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._switch.connection.provider.impl.rev140328;
+
+/**
+*
+*/
+public class SwitchConnectionProviderModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.provider.impl.rev140328.AbstractSwitchConnectionProviderModuleFactory
+{
+
+
+}
diff --git a/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang b/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang
new file mode 100644 (file)
index 0000000..ddd6ebd
--- /dev/null
@@ -0,0 +1,50 @@
+module openflow-switch-connection-provider-impl {
+       yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:provider:impl";
+    prefix "openflow-switch-connection-provider-impl";
+
+    import config {prefix config; revision-date 2013-04-05; }
+    import openflow-switch-connection-provider {prefix openflow-switch-connection-provider; revision-date 2014-03-28; }
+    import ietf-inet-types {prefix ietf-inet; revision-date 2010-09-24; }
+
+    description
+        "openflow-switch-connection-provider";
+
+    revision "2014-03-28" {
+        description
+            "Initial revision";
+    }
+
+    identity openflow-switch-connection-provider-impl {
+        base "config:module-type";
+        config:provided-service openflow-switch-connection-provider:openflow-switch-connection-provider;
+        config:java-name-prefix SwitchConnectionProvider;
+    }
+
+
+    augment "/config:modules/config:module/config:configuration" {
+        case openflow-switch-connection-provider-impl {
+            when "/config:modules/config:module/config:type = 'openflow-switch-connection-provider-impl'";
+
+            leaf port {
+                description "local listening port";
+                type uint16;
+                mandatory true;
+            }
+            leaf address {
+                description "address of local listening interface";
+                type ietf-inet:ip-address;
+            }
+            leaf switch-idle-timeout {
+                description "idle timeout in [ms]";
+                type uint32;
+                mandatory true;
+            }
+            leaf tls-support {
+                description "tls support enabled (requires SSL-context / keystore)";
+                type boolean;
+                default false;
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider.yang b/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider.yang
new file mode 100644 (file)
index 0000000..88d2427
--- /dev/null
@@ -0,0 +1,20 @@
+module openflow-switch-connection-provider {
+       yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:provider";
+    prefix "openflow-switch-connection-provider";
+
+    import config {prefix config; revision-date 2013-04-05; }
+
+    description
+        "openflow-switch-connection-provider service definitions";
+
+    revision "2014-03-28" {
+        description
+            "Initial revision";
+    }
+
+    identity openflow-switch-connection-provider {
+         base "config:service-type";
+         config:java-class "org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider";
+    }
+}
\ No newline at end of file
index 2627d61fbe760870b475a3f9cd74cc43dea0a641..2a7a89768c7cfc9ce4bcc937c6cd2da3b610976c 100644 (file)
@@ -48,7 +48,7 @@ public class IntegrationTest {
     private InetAddress startupAddress;
     private MockPlugin mockPlugin;
     private SwitchConnectionProviderImpl scpimpl;
-    private List<ConnectionConfiguration> configs;
+    private TestingConnConfigImpl configs;
 
     /**
      * @throws Exception
@@ -60,11 +60,10 @@ public class IntegrationTest {
         mockPlugin = new MockPlugin();
         scpimpl = new SwitchConnectionProviderImpl();
         scpimpl.setSwitchConnectionHandler(mockPlugin);
-        configs = new ArrayList<>();
-        configs.add(new TestingConnConfigImpl(startupAddress, 0, DEFAULT_TLS_SUPPORT, SWITCH_IDLE_TIMEOUT));
-        scpimpl.configure(configs);
+        configs = new TestingConnConfigImpl(startupAddress, 0, DEFAULT_TLS_SUPPORT, SWITCH_IDLE_TIMEOUT);
+        scpimpl.setConfiguration(configs);
         scpimpl.startup().get(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS);
-        TcpHandler server = (TcpHandler) scpimpl.getServerLot().iterator().next();
+        TcpHandler server = (TcpHandler) scpimpl.getServerFacade();
         port = server.getPort();
     }
 
index 0465ab4ebbfa64a38dd90155e533574db6bf4aa2..56766a7bfd2258ab6fb5ef4ffea289e60399f8cc 100644 (file)
@@ -9,41 +9,39 @@
 
 package org.opendaylight.openflowjava.protocol.spi.connection;
 
-import java.util.Collection;
-import java.util.List;
-import java.util.concurrent.Future;
-
 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration;
 import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler;
 
+import com.google.common.util.concurrent.ListenableFuture;
+
 /**
  * @author mirehak
  * @author michal.polkorab
  *
  */
-public interface SwitchConnectionProvider {
+public interface SwitchConnectionProvider extends AutoCloseable {
 
     /**
-     * @param configurations list of [protocol, port, address and supported features]
+     * @param configuration [protocol, port, address and supported features]
      */
-    public void configure(Collection<ConnectionConfiguration> configurations);
+    void setConfiguration(ConnectionConfiguration configuration);
     
     /**
      * start listening to switches, but please don't forget to do
      * {@link #setSwitchConnectionHandler(SwitchConnectionHandler)} first
-     * @return future, triggered to true, when all listening channels are up and running
+     * @return future, triggered to true, when listening channel is up and running
      */
-    public Future<List<Boolean>> startup();
+    ListenableFuture<Boolean> startup();
     
     /**
      * stop listening to switches
      * @return future, triggered to true, when all listening channels are down
      */
-    public Future<List<Boolean>> shutdown();
+    ListenableFuture<Boolean> shutdown();
     
     /**
      * @param switchConHandler instance being informed when new switch connects
      */
-    public void setSwitchConnectionHandler(SwitchConnectionHandler switchConHandler);
+    void setSwitchConnectionHandler(SwitchConnectionHandler switchConHandler);
     
 }
diff --git a/pom.xml b/pom.xml
index 841d03603844cb2edf91ca5b8e34db71e8ee4e78..4a2cd0f1257529b6ae83c8f0150a273d3ed5f02e 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -16,7 +16,7 @@
         <developerConnection>scm:git:ssh://git.opendaylight.org:29418/openflowjava.git</developerConnection>
         <url>https://wiki.opendaylight.org/view/Openflow_Protocol_Library:Main</url>
       <tag>HEAD</tag>
-  </scm>
+    </scm>
 
     <properties>
         <sonar.host.url>https://sonar.opendaylight.org/</sonar.host.url>
@@ -40,6 +40,9 @@
         <guava.version>14.0.1</guava.version> 
         <netty.version>4.0.17.Final</netty.version>
         <releaseplugin.version>2.3.2</releaseplugin.version>
+        <yangtools.version>0.6.2-SNAPSHOT</yangtools.version>
+        <yangtools.generator.version>0.6.2-SNAPSHOT</yangtools.generator.version>
+        <config.version>0.2.5-SNAPSHOT</config.version>
     </properties>
 
     <pluginRepositories>
                     <artifactId>maven-release-plugin</artifactId>
                     <version>${releaseplugin.version}</version>
                 </plugin>
+                <plugin>
+                    <groupId>org.opendaylight.yangtools</groupId>
+                    <artifactId>yang-maven-plugin</artifactId>
+                    <version>${yangtools.version}</version>
+                </plugin>
+                <plugin>
+                    <groupId>org.apache.felix</groupId>
+                    <artifactId>maven-bundle-plugin</artifactId>
+                    <version>${maven.bundle.version}</version>
+                </plugin>
             </plugins>
         </pluginManagement>
     </build>