Get rid of netconf-tcp project 54/79654/6
authorJakub Morvay <jmorvay@frinx.io>
Fri, 18 Jan 2019 11:16:05 +0000 (12:16 +0100)
committerTom Pantelis <tompantelis@gmail.com>
Wed, 23 Jan 2019 02:14:06 +0000 (02:14 +0000)
netconf-tcp includes basic TCP server implementation used in netconf
project. It also contains instantiation logic for tcp server used by
css netconf northbound.

css is no longer in the game. Remove TCP server instantiation logic for
css netconf northbound endpoint. Move NetconfNorthboundTcpServer class
(only class used elsewhere) to mdsal-netconf-tcp projects. This project
is its primary and only user now.

Change-Id: I7dea91f33f3c3f6364d57e5a590505a058fd7957
Signed-off-by: Jakub Morvay <jmorvay@frinx.io>
12 files changed:
features/netconf/odl-netconf-tcp/pom.xml
netconf/mdsal-netconf-connector/pom.xml
netconf/mdsal-netconf-tcp/pom.xml
netconf/mdsal-netconf-tcp/src/main/java/org/opendaylight/netconf/tcp/NetconfNorthboundTcpServer.java [moved from netconf/netconf-tcp/src/main/java/org/opendaylight/netconf/tcp/NetconfNorthboundTcpServer.java with 87% similarity]
netconf/netconf-artifacts/pom.xml
netconf/netconf-tcp/pom.xml [deleted file]
netconf/netconf-tcp/src/main/java/org/opendaylight/netconf/tcp/NetconfTCPProvider.java [deleted file]
netconf/netconf-tcp/src/main/java/org/opendaylight/netconf/tcp/netty/ProxyClientHandler.java [deleted file]
netconf/netconf-tcp/src/main/java/org/opendaylight/netconf/tcp/netty/ProxyServer.java [deleted file]
netconf/netconf-tcp/src/main/java/org/opendaylight/netconf/tcp/netty/ProxyServerHandler.java [deleted file]
netconf/netconf-tcp/src/main/resources/org/opendaylight/blueprint/netconf-tcp-blueprint.xml [deleted file]
netconf/pom.xml

index 3e50d2d0a828f37d6a184fa1aa4a1356cd87ee60..78bae8d15cea2156dc9889b240390374c006567b 100644 (file)
             <type>xml</type>
             <classifier>features</classifier>
         </dependency>
-        <dependency>
-            <groupId>${project.groupId}</groupId>
-            <artifactId>netconf-tcp</artifactId>
-            <version>${project.version}</version>
-        </dependency>
     </dependencies>
 </project>
index 18e5c989d9a9d592c3c4375ce796d59f51688a3e..b2eb312f2e4bcaafc3e7c769377f0a818ed4eae0 100644 (file)
@@ -46,7 +46,7 @@
     </dependency>
     <dependency>
       <groupId>${project.groupId}</groupId>
-      <artifactId>netconf-tcp</artifactId>
+      <artifactId>mdsal-netconf-tcp</artifactId>
     </dependency>
     <dependency>
       <groupId>com.google.guava</groupId>
index 2df2a7f2da633194c90f308fa3d320aa692775eb..4f223c99eac41b29d5e7b4f46c1ec64da5eb9e0b 100644 (file)
@@ -16,7 +16,6 @@
     <relativePath>../netconf-parent</relativePath>
   </parent>
 
-  <groupId>org.opendaylight.netconf</groupId>
   <artifactId>mdsal-netconf-tcp</artifactId>
   <version>1.6.0-SNAPSHOT</version>
   <name>${project.artifactId}</name>
   <dependencies>
     <dependency>
       <groupId>${project.groupId}</groupId>
-      <artifactId>netconf-tcp</artifactId>
+      <artifactId>netconf-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>netconf-util</artifactId>
     </dependency>
   </dependencies>
 
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.felix</groupId>
-        <artifactId>maven-bundle-plugin</artifactId>
-        <extensions>true</extensions>
-        <configuration>
-          <instructions>
-            <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
-            <Embed-Dependency>netconf-tcp</Embed-Dependency>
-          </instructions>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
 </project>
similarity index 87%
rename from netconf/netconf-tcp/src/main/java/org/opendaylight/netconf/tcp/NetconfNorthboundTcpServer.java
rename to netconf/mdsal-netconf-tcp/src/main/java/org/opendaylight/netconf/tcp/NetconfNorthboundTcpServer.java
index 69090c283f6a93cd3c8136d701f5e6846791f890..f3200c9b3ae5df43110eed896c17da77553b6358 100644 (file)
@@ -26,10 +26,9 @@ public class NetconfNorthboundTcpServer implements AutoCloseable {
 
     private final ChannelFuture tcpServer;
 
-    public NetconfNorthboundTcpServer(final NetconfServerDispatcher netconfServerDispatcher,
-                                      final String address,
-                                      final String port) {
-        InetSocketAddress inetAddress = getInetAddress(address, port);
+    public NetconfNorthboundTcpServer(final NetconfServerDispatcher netconfServerDispatcher, final String address,
+            final String port) {
+        final InetSocketAddress inetAddress = getInetAddress(address, port);
         tcpServer = netconfServerDispatcher.createServer(inetAddress);
         tcpServer.addListener(future -> {
             if (future.isDone() && future.isSuccess()) {
@@ -42,7 +41,7 @@ public class NetconfNorthboundTcpServer implements AutoCloseable {
     }
 
     private static InetSocketAddress getInetAddress(final String bindingAddress, final String portNumber) {
-        IpAddress ipAddress = IpAddressBuilder.getDefaultInstance(bindingAddress);
+        final IpAddress ipAddress = IpAddressBuilder.getDefaultInstance(bindingAddress);
         final InetAddress inetAd = IetfInetUtil.INSTANCE.inetAddressFor(ipAddress);
         return new InetSocketAddress(inetAd, Integer.parseInt(portNumber));
     }
index c8466d6547aeea292bbdf34a5eac7346a72112a6..deb8dd1ca7bf8702ff8776d5025264306a491eb7 100644 (file)
                 <artifactId>netconf-ssh</artifactId>
                 <version>${project.version}</version>
             </dependency>
-            <dependency>
-                <groupId>${project.groupId}</groupId>
-                <artifactId>netconf-tcp</artifactId>
-                <version>${project.version}</version>
-            </dependency>
             <dependency>
                 <groupId>${project.groupId}</groupId>
                 <artifactId>netconf-testtool</artifactId>
diff --git a/netconf/netconf-tcp/pom.xml b/netconf/netconf-tcp/pom.xml
deleted file mode 100644 (file)
index 8d0967f..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
-  ~
-  ~ This program and the accompanying materials are made available under the
-  ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
-  ~ and is available at http://www.eclipse.org/legal/epl-v10.html
-  -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-
-  <parent>
-    <groupId>org.opendaylight.netconf</groupId>
-    <artifactId>netconf-parent</artifactId>
-    <version>1.6.0-SNAPSHOT</version>
-    <relativePath>../netconf-parent</relativePath>
-  </parent>
-
-  <groupId>org.opendaylight.netconf</groupId>
-  <artifactId>netconf-tcp</artifactId>
-  <version>1.6.0-SNAPSHOT</version>
-  <name>${project.artifactId}</name>
-  <packaging>bundle</packaging>
-
-  <dependencies>
-    <dependency>
-      <groupId>${project.groupId}</groupId>
-      <artifactId>netconf-api</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>${project.groupId}</groupId>
-      <artifactId>netconf-util</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-api</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.yangtools</groupId>
-      <artifactId>mockito-configuration</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.osgi</groupId>
-      <artifactId>org.osgi.compendium</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.osgi</groupId>
-      <artifactId>org.osgi.core</artifactId>
-    </dependency>
-  </dependencies>
-</project>
diff --git a/netconf/netconf-tcp/src/main/java/org/opendaylight/netconf/tcp/NetconfTCPProvider.java b/netconf/netconf-tcp/src/main/java/org/opendaylight/netconf/tcp/NetconfTCPProvider.java
deleted file mode 100644 (file)
index 54fb94e..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netconf.tcp;
-
-import java.net.InetSocketAddress;
-import org.opendaylight.netconf.tcp.netty.ProxyServer;
-import org.opendaylight.netconf.util.NetconfConfiguration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Opens TCP port specified in config.ini, creates bridge between this port and local netconf server.
- */
-public class NetconfTCPProvider {
-    private static final Logger LOG = LoggerFactory.getLogger(NetconfTCPProvider.class);
-
-    private final NetconfConfiguration netconfConfiguration;
-    private ProxyServer proxyServer;
-
-    public NetconfTCPProvider(final NetconfConfiguration netconfConfiguration) {
-        this.netconfConfiguration = netconfConfiguration;
-    }
-
-    // Called via blueprint
-    @SuppressWarnings("unused")
-    public void init() {
-        final InetSocketAddress address = netconfConfiguration.getTcpServerAddress();
-
-        if (address.getAddress().isAnyLocalAddress()) {
-            LOG.warn("Unprotected netconf TCP address is configured to ANY "
-                    + "local address. This is a security risk. Consider "
-                    + "changing tcp-address in netconf.cfg to 127.0.0.1");
-        }
-        LOG.info("Starting TCP netconf server at {}", address);
-        proxyServer = new ProxyServer(address, NetconfConfiguration.NETCONF_LOCAL_ADDRESS);
-    }
-
-    // Called via blueprint
-    @SuppressWarnings("unused")
-    public void destroy() {
-        if (proxyServer != null) {
-            proxyServer.close();
-        }
-    }
-}
diff --git a/netconf/netconf-tcp/src/main/java/org/opendaylight/netconf/tcp/netty/ProxyClientHandler.java b/netconf/netconf-tcp/src/main/java/org/opendaylight/netconf/tcp/netty/ProxyClientHandler.java
deleted file mode 100644 (file)
index 2cde077..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2017 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.netconf.tcp.netty;
-
-import static com.google.common.base.Preconditions.checkState;
-
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-class ProxyClientHandler extends ChannelInboundHandlerAdapter {
-    private static final Logger LOG = LoggerFactory.getLogger(ProxyClientHandler.class);
-
-    private final ChannelHandlerContext remoteCtx;
-    private ChannelHandlerContext localCtx;
-
-    ProxyClientHandler(ChannelHandlerContext remoteCtx) {
-        this.remoteCtx = remoteCtx;
-    }
-
-    @Override
-    public void channelActive(ChannelHandlerContext ctx) {
-        checkState(this.localCtx == null);
-        LOG.trace("Client channel active");
-        this.localCtx = ctx;
-    }
-
-    @Override
-    public void channelRead(ChannelHandlerContext ctx, Object msg) {
-        LOG.trace("Forwarding message");
-        remoteCtx.write(msg);
-    }
-
-    @Override
-    public void channelReadComplete(ChannelHandlerContext ctx) {
-        LOG.trace("Flushing remote ctx");
-        remoteCtx.flush();
-    }
-
-    @Override
-    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
-        // Close the connection when an exception is raised.
-        LOG.warn("Unexpected exception from downstream", cause);
-        checkState(this.localCtx.equals(ctx));
-        ctx.close();
-    }
-
-    // called both when local or remote connection dies
-    @Override
-    public void channelInactive(ChannelHandlerContext ctx) {
-        LOG.trace("channelInactive() called, closing remote client ctx");
-        remoteCtx.close();
-    }
-
-}
diff --git a/netconf/netconf-tcp/src/main/java/org/opendaylight/netconf/tcp/netty/ProxyServer.java b/netconf/netconf-tcp/src/main/java/org/opendaylight/netconf/tcp/netty/ProxyServer.java
deleted file mode 100644 (file)
index 9e5e175..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netconf.tcp.netty;
-
-import io.netty.bootstrap.Bootstrap;
-import io.netty.bootstrap.ServerBootstrap;
-import io.netty.channel.ChannelFuture;
-import io.netty.channel.ChannelInitializer;
-import io.netty.channel.EventLoopGroup;
-import io.netty.channel.local.LocalAddress;
-import io.netty.channel.local.LocalChannel;
-import io.netty.channel.nio.NioEventLoopGroup;
-import io.netty.channel.socket.SocketChannel;
-import io.netty.channel.socket.nio.NioServerSocketChannel;
-import io.netty.handler.logging.LogLevel;
-import io.netty.handler.logging.LoggingHandler;
-import java.net.InetSocketAddress;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ProxyServer implements AutoCloseable {
-    private static final Logger LOG = LoggerFactory.getLogger(ProxyServer.class);
-
-    private final EventLoopGroup bossGroup = new NioEventLoopGroup();
-    private final EventLoopGroup workerGroup = new NioEventLoopGroup();
-    private final ChannelFuture channelFuture;
-
-    @SuppressWarnings("checkstyle:IllegalCatch")
-    public ProxyServer(InetSocketAddress address, final LocalAddress localAddress) {
-        // Configure the server.
-        final Bootstrap clientBootstrap = new Bootstrap();
-        clientBootstrap.group(bossGroup).channel(LocalChannel.class);
-
-        ServerBootstrap serverBootstrap = new ServerBootstrap();
-        serverBootstrap.group(bossGroup, workerGroup)
-                .channel(NioServerSocketChannel.class)
-                .handler(new LoggingHandler(LogLevel.DEBUG))
-                .childHandler(new ChannelInitializer<SocketChannel>() {
-                    @Override
-                    public void initChannel(SocketChannel ch) {
-                        ch.pipeline().addLast(new ProxyServerHandler(clientBootstrap, localAddress));
-                    }
-                });
-
-        // Start the server.
-        try {
-            channelFuture = serverBootstrap.bind(address).syncUninterruptibly();
-        } catch (Throwable throwable) {
-            // sync() re-throws exceptions declared as Throwable, so the compiler doesn't see them
-            LOG.error("Error while binding to address {}", address, throwable);
-            throw throwable;
-        }
-    }
-
-    @Override
-    public void close() {
-        channelFuture.channel().close();
-        bossGroup.shutdownGracefully();
-        workerGroup.shutdownGracefully();
-    }
-}
diff --git a/netconf/netconf-tcp/src/main/java/org/opendaylight/netconf/tcp/netty/ProxyServerHandler.java b/netconf/netconf-tcp/src/main/java/org/opendaylight/netconf/tcp/netty/ProxyServerHandler.java
deleted file mode 100644 (file)
index 5843f41..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netconf.tcp.netty;
-
-import io.netty.bootstrap.Bootstrap;
-import io.netty.channel.Channel;
-import io.netty.channel.ChannelFuture;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
-import io.netty.channel.ChannelInitializer;
-import io.netty.channel.local.LocalAddress;
-import io.netty.channel.local.LocalChannel;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ProxyServerHandler extends ChannelInboundHandlerAdapter {
-    private static final Logger LOG = LoggerFactory.getLogger(ProxyServerHandler.class);
-    private final Bootstrap clientBootstrap;
-    private final LocalAddress localAddress;
-
-    private Channel clientChannel;
-
-    public ProxyServerHandler(Bootstrap clientBootstrap, LocalAddress localAddress) {
-        this.clientBootstrap = clientBootstrap;
-        this.localAddress = localAddress;
-    }
-
-    @Override
-    public void channelActive(ChannelHandlerContext remoteCtx) {
-        final ProxyClientHandler clientHandler = new ProxyClientHandler(remoteCtx);
-        clientBootstrap.handler(new ChannelInitializer<LocalChannel>() {
-            @Override
-            public void initChannel(LocalChannel ch) {
-                ch.pipeline().addLast(clientHandler);
-            }
-        });
-        ChannelFuture clientChannelFuture = clientBootstrap.connect(localAddress).awaitUninterruptibly();
-        clientChannel = clientChannelFuture.channel();
-    }
-
-    @Override
-    public void channelInactive(ChannelHandlerContext ctx) {
-        LOG.trace("channelInactive - closing client channel");
-        clientChannel.close();
-    }
-
-    @Override
-    public void channelRead(ChannelHandlerContext ctx, final Object msg) {
-        LOG.trace("Writing to client channel");
-        clientChannel.write(msg);
-    }
-
-    @Override
-    public void channelReadComplete(ChannelHandlerContext ctx) {
-        LOG.trace("Flushing client channel");
-        clientChannel.flush();
-    }
-
-    @Override
-    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
-        // Close the connection when an exception is raised.
-        LOG.warn("Unexpected exception from downstream.", cause);
-        ctx.close();
-    }
-}
-
diff --git a/netconf/netconf-tcp/src/main/resources/org/opendaylight/blueprint/netconf-tcp-blueprint.xml b/netconf/netconf-tcp/src/main/resources/org/opendaylight/blueprint/netconf-tcp-blueprint.xml
deleted file mode 100644 (file)
index 5423731..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (c) 2017 Inocybe Technologies 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
--->
-<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="netconfConfiguration"
-               interface="org.opendaylight.netconf.util.NetconfConfiguration" />
-
-    <bean id="netconfTcpProvider" class="org.opendaylight.netconf.tcp.NetconfTCPProvider"
-          init-method="init" destroy-method="destroy">
-        <argument ref="netconfConfiguration" />
-    </bean>
-
-</blueprint>
index df788c45bff84322bb53d8df35bdac7ec1013963..c534a49b8d965ae23e13013ae5c037b45907daf2 100644 (file)
@@ -44,7 +44,6 @@
     <module>netconf-netty-util</module>
     <module>netconf-mapping-api</module>
     <module>netconf-client</module>
-    <module>netconf-tcp</module>
     <module>netconf-auth</module>
     <module>aaa-authn-odl-plugin</module>
     <module>netconf-notifications-impl</module>