X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-ssh%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fnetty%2FProxyServer.java;fp=opendaylight%2Fnetconf%2Fnetconf-ssh%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fnetty%2FProxyServer.java;h=0000000000000000000000000000000000000000;hp=8f2c50278de6b40d978bc47b36482e49a9f2caf0;hb=9ba2b4eca79bcc0e78099b133296801c8d45a6c4;hpb=b2e81149739c87f0ecc2ce7f06448d7a5d3162b8 diff --git a/opendaylight/netconf/netconf-ssh/src/test/java/org/opendaylight/controller/netconf/netty/ProxyServer.java b/opendaylight/netconf/netconf-ssh/src/test/java/org/opendaylight/controller/netconf/netty/ProxyServer.java deleted file mode 100644 index 8f2c50278d..0000000000 --- a/opendaylight/netconf/netconf-ssh/src/test/java/org/opendaylight/controller/netconf/netty/ProxyServer.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.netconf.netty; - -import io.netty.bootstrap.ServerBootstrap; -import io.netty.channel.ChannelFuture; -import io.netty.channel.ChannelHandler; -import io.netty.channel.ChannelInitializer; -import io.netty.channel.ChannelOption; -import io.netty.channel.EventLoopGroup; -import io.netty.channel.local.LocalAddress; -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.opendaylight.controller.netconf.util.osgi.NetconfConfigUtil; - -public class ProxyServer implements Runnable { - private final ProxyHandlerFactory proxyHandlerFactory; - - public ProxyServer(ProxyHandlerFactory proxyHandlerFactory) { - this.proxyHandlerFactory = proxyHandlerFactory; - } - - public void run() { - // Configure the server. - final EventLoopGroup bossGroup = new NioEventLoopGroup(); - EventLoopGroup workerGroup = new NioEventLoopGroup(); - try { - final LocalAddress localAddress = NetconfConfigUtil.getNetconfLocalAddress(); - ServerBootstrap serverBootstrap = new ServerBootstrap(); - serverBootstrap.group(bossGroup, workerGroup) - .channel(NioServerSocketChannel.class) - .option(ChannelOption.SO_BACKLOG, 100) - .handler(new LoggingHandler(LogLevel.INFO)) - .childHandler(new ChannelInitializer() { - @Override - public void initChannel(SocketChannel ch) throws Exception { - ch.pipeline().addLast(proxyHandlerFactory.create(bossGroup, localAddress)); - } - }); - - // Start the server. - InetSocketAddress address = new InetSocketAddress("127.0.0.1", 8080); - ChannelFuture f = serverBootstrap.bind(address).sync(); - - // Wait until the server socket is closed. - f.channel().closeFuture().sync(); - } catch (Exception e) { - throw new RuntimeException(e); - } finally { - // Shut down all event loops to terminate all threads. - bossGroup.shutdownGracefully(); - workerGroup.shutdownGracefully(); - } - } - public static interface ProxyHandlerFactory { - ChannelHandler create(EventLoopGroup bossGroup, LocalAddress localAddress); - } - - public static void main(String[] args) { - ProxyHandlerFactory proxyHandlerFactory = new ProxyHandlerFactory() { - @Override - public ChannelHandler create(EventLoopGroup bossGroup, LocalAddress localAddress) { - return new ProxyServerHandler(bossGroup, localAddress); - } - }; - start(proxyHandlerFactory); - } - - public static void start(ProxyHandlerFactory proxyHandlerFactory) { - new Thread(new EchoServer()).start(); - new Thread(new ProxyServer(proxyHandlerFactory)).start(); - } -}