From: Robert Varga Date: Sat, 29 Jul 2017 09:53:35 +0000 (+0200) Subject: Eliminate protocol-framework X-Git-Tag: release/nitrogen~12 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=13f8c99a25932f1b33505dadcbd3fea6608389cb Eliminate protocol-framework This piece of code has been moved to netconf, eliminate it from controller. Change-Id: I1a04ed800d88ab49ef6e1d0782ca722f18e16581 Signed-off-by: Robert Varga --- diff --git a/features/pom.xml b/features/pom.xml index 55f2218f2c..b7586567a9 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -18,7 +18,6 @@ config-persister config-netty mdsal - protocol-framework extras benchmark diff --git a/features/protocol-framework/features-protocol-framework/pom.xml b/features/protocol-framework/features-protocol-framework/pom.xml deleted file mode 100644 index 387aefe96c..0000000000 --- a/features/protocol-framework/features-protocol-framework/pom.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - 4.0.0 - - - org.opendaylight.odlparent - feature-repo-parent - 2.0.4 - - - - org.opendaylight.controller - features-protocol-framework - 0.10.0-SNAPSHOT - feature - - - - org.opendaylight.controller - odl-protocol-framework - 0.10.0-SNAPSHOT - xml - features - - - - diff --git a/features/protocol-framework/odl-protocol-framework/pom.xml b/features/protocol-framework/odl-protocol-framework/pom.xml deleted file mode 100644 index 6ab9c90f38..0000000000 --- a/features/protocol-framework/odl-protocol-framework/pom.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - 4.0.0 - - - org.opendaylight.odlparent - single-feature-parent - 2.0.4 - - - - org.opendaylight.controller - odl-protocol-framework - 0.10.0-SNAPSHOT - feature - - OpenDaylight :: Protocol Framework - - - - org.opendaylight.controller - odl-config-api - 0.7.0-SNAPSHOT - xml - features - - - org.opendaylight.controller - odl-config-netty-config-api - 0.7.0-SNAPSHOT - xml - features - - - org.opendaylight.controller - protocol-framework - ${project.version} - - - - \ No newline at end of file diff --git a/features/protocol-framework/pom.xml b/features/protocol-framework/pom.xml deleted file mode 100644 index 1e4272011f..0000000000 --- a/features/protocol-framework/pom.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - 4.0.0 - - org.opendaylight.odlparent - odlparent-lite - 2.0.4 - - - - org.opendaylight.controller - features-protocol-framework-aggregator - 0.10.0-SNAPSHOT - pom - - - features-protocol-framework - odl-protocol-framework - - - - scm:git:http://git.opendaylight.org/gerrit/controller.git - scm:git:ssh://git.opendaylight.org:29418/controller.git - HEAD - https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL - - diff --git a/opendaylight/commons/protocol-framework/.gitignore b/opendaylight/commons/protocol-framework/.gitignore deleted file mode 100644 index fc1d35eb24..0000000000 --- a/opendaylight/commons/protocol-framework/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -target -.classpath -.settings diff --git a/opendaylight/commons/protocol-framework/pom.xml b/opendaylight/commons/protocol-framework/pom.xml deleted file mode 100644 index 52901199b4..0000000000 --- a/opendaylight/commons/protocol-framework/pom.xml +++ /dev/null @@ -1,87 +0,0 @@ - - - - - 4.0.0 - - - org.opendaylight.odlparent - bundle-parent - 2.0.4 - - - - org.opendaylight.controller - protocol-framework - 0.10.0-SNAPSHOT - bundle - ${project.artifactId} - Common protocol framework - - - - com.google.guava - guava - - - io.netty - netty-buffer - - - io.netty - netty-codec - - - io.netty - netty-common - - - io.netty - netty-transport - - - junit - junit - - - - - org.opendaylight.yangtools - mockito-configuration - 1.2.0-SNAPSHOT - test - - - org.osgi - org.osgi.core - - - org.slf4j - slf4j-api - - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - test-jar - - package - - - - - - - - scm:git:http://git.opendaylight.org/gerrit/controller.git - scm:git:ssh://git.opendaylight.org:29418/controller.git - HEAD - https://wiki.opendaylight.org/view/OpenDaylight_Controller:Main - - diff --git a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/AbstractDispatcher.java b/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/AbstractDispatcher.java deleted file mode 100644 index 80e30dc90c..0000000000 --- a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/AbstractDispatcher.java +++ /dev/null @@ -1,275 +0,0 @@ -/* - * 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.protocol.framework; - -import com.google.common.base.Preconditions; -import io.netty.bootstrap.Bootstrap; -import io.netty.bootstrap.ServerBootstrap; -import io.netty.buffer.PooledByteBufAllocator; -import io.netty.channel.Channel; -import io.netty.channel.ChannelFuture; -import io.netty.channel.ChannelInitializer; -import io.netty.channel.ChannelOption; -import io.netty.channel.EventLoopGroup; -import io.netty.channel.ServerChannel; -import io.netty.channel.local.LocalServerChannel; -import io.netty.channel.socket.SocketChannel; -import io.netty.channel.socket.nio.NioServerSocketChannel; -import io.netty.channel.socket.nio.NioSocketChannel; -import io.netty.util.concurrent.DefaultPromise; -import io.netty.util.concurrent.EventExecutor; -import io.netty.util.concurrent.Future; -import io.netty.util.concurrent.GlobalEventExecutor; -import io.netty.util.concurrent.Promise; -import java.io.Closeable; -import java.net.InetSocketAddress; -import java.net.SocketAddress; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Dispatcher class for creating servers and clients. The idea is to first create servers and clients and the run the - * start method that will handle sockets in different thread. - */ -@Deprecated -public abstract class AbstractDispatcher, L extends SessionListener> implements Closeable { - - - protected interface ChannelPipelineInitializer> { - /** - * Initializes channel by specifying the handlers in its pipeline. Handlers are protocol specific, therefore this - * method needs to be implemented in protocol specific Dispatchers. - * - * @param channel whose pipeline should be defined, also to be passed to {@link SessionNegotiatorFactory} - * @param promise to be passed to {@link SessionNegotiatorFactory} - */ - void initializeChannel(CH channel, Promise promise); - } - - protected interface PipelineInitializer> extends ChannelPipelineInitializer { - - } - - - private static final Logger LOG = LoggerFactory.getLogger(AbstractDispatcher.class); - - private final EventLoopGroup bossGroup; - - private final EventLoopGroup workerGroup; - - private final EventExecutor executor; - - protected AbstractDispatcher(final EventLoopGroup bossGroup, final EventLoopGroup workerGroup) { - this(GlobalEventExecutor.INSTANCE, bossGroup, workerGroup); - } - - protected AbstractDispatcher(final EventExecutor executor, final EventLoopGroup bossGroup, final EventLoopGroup workerGroup) { - this.bossGroup = Preconditions.checkNotNull(bossGroup); - this.workerGroup = Preconditions.checkNotNull(workerGroup); - this.executor = Preconditions.checkNotNull(executor); - } - - - /** - * Creates server. Each server needs factories to pass their instances to client sessions. - * - * @param address address to which the server should be bound - * @param initializer instance of PipelineInitializer used to initialize the channel pipeline - * - * @return ChannelFuture representing the binding process - */ - protected ChannelFuture createServer(final InetSocketAddress address, final PipelineInitializer initializer) { - return createServer(address, NioServerSocketChannel.class, initializer); - } - - /** - * Creates server. Each server needs factories to pass their instances to client sessions. - * - * @param address address to which the server should be bound - * @param channelClass The {@link Class} which is used to create {@link Channel} instances from. - * @param initializer instance of PipelineInitializer used to initialize the channel pipeline - * - * @return ChannelFuture representing the binding process - */ - protected ChannelFuture createServer(final SocketAddress address, final Class channelClass, - final ChannelPipelineInitializer initializer) { - final ServerBootstrap b = new ServerBootstrap(); - b.childHandler(new ChannelInitializer() { - - @Override - protected void initChannel(final CH ch) { - initializer.initializeChannel(ch, new DefaultPromise<>(executor)); - } - }); - - b.option(ChannelOption.SO_BACKLOG, 128); - if (LocalServerChannel.class.equals(channelClass) == false) { - // makes no sense for LocalServer and produces warning - b.childOption(ChannelOption.SO_KEEPALIVE, true); - b.childOption(ChannelOption.TCP_NODELAY , true); - } - b.childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT); - customizeBootstrap(b); - - if (b.group() == null) { - b.group(bossGroup, workerGroup); - } - try { - b.channel(channelClass); - } catch (final IllegalStateException e) { - // FIXME: if this is ok, document why - LOG.trace("Not overriding channelFactory on bootstrap {}", b, e); - } - - // Bind and start to accept incoming connections. - final ChannelFuture f = b.bind(address); - LOG.debug("Initiated server {} at {}.", f, address); - return f; - } - - /** - * Customize a server bootstrap before the server is created. This allows - * subclasses to assign non-default server options before the server is - * created. - * - * @param b Server bootstrap - */ - protected void customizeBootstrap(final ServerBootstrap b) { - // The default is a no-op - } - - /** - * Creates a client. - * - * @param address remote address - * @param strategy Reconnection strategy to be used when initial connection fails - * - * @return Future representing the connection process. Its result represents the combined success of TCP connection - * as well as session negotiation. - */ - protected Future createClient(final InetSocketAddress address, final ReconnectStrategy strategy, final PipelineInitializer initializer) { - final Bootstrap b = new Bootstrap(); - final ProtocolSessionPromise p = new ProtocolSessionPromise<>(executor, address, strategy, b); - b.option(ChannelOption.SO_KEEPALIVE, true).handler( - new ChannelInitializer() { - @Override - protected void initChannel(final SocketChannel ch) { - initializer.initializeChannel(ch, p); - } - }); - - customizeBootstrap(b); - setWorkerGroup(b); - setChannelFactory(b); - - p.connect(); - LOG.debug("Client created."); - return p; - } - - private void setWorkerGroup(final Bootstrap b) { - if (b.group() == null) { - b.group(workerGroup); - } - } - - /** - * Create a client but use a pre-configured bootstrap. - * This method however replaces the ChannelInitializer in the bootstrap. All other configuration is preserved. - * - * @param address remote address - */ - protected Future createClient(final InetSocketAddress address, final ReconnectStrategy strategy, final Bootstrap bootstrap, final PipelineInitializer initializer) { - final ProtocolSessionPromise p = new ProtocolSessionPromise<>(executor, address, strategy, bootstrap); - - bootstrap.handler( - new ChannelInitializer() { - @Override - protected void initChannel(final SocketChannel ch) { - initializer.initializeChannel(ch, p); - } - }); - - p.connect(); - LOG.debug("Client created."); - return p; - } - - /** - * Customize a client bootstrap before the connection is attempted. This - * allows subclasses to assign non-default options before the client is - * created. - * - * @param b Client bootstrap - */ - protected void customizeBootstrap(final Bootstrap b) { - // The default is a no-op - } - - /** - * - * @deprecated use {@link org.opendaylight.protocol.framework.AbstractDispatcher#createReconnectingClient(java.net.InetSocketAddress, ReconnectStrategyFactory, org.opendaylight.protocol.framework.AbstractDispatcher.PipelineInitializer)} with only one reconnectStrategyFactory instead. - * - * Creates a client. - * - * @param address remote address - * @param connectStrategyFactory Factory for creating reconnection strategy to be used when initial connection fails - * @param reestablishStrategy Reconnection strategy to be used when the already-established session fails - * - * @return Future representing the reconnection task. It will report completion based on reestablishStrategy, e.g. - * success if it indicates no further attempts should be made and failure if it reports an error - */ - @Deprecated - protected Future createReconnectingClient(final InetSocketAddress address, final ReconnectStrategyFactory connectStrategyFactory, - final ReconnectStrategy reestablishStrategy, final PipelineInitializer initializer) { - return createReconnectingClient(address, connectStrategyFactory, initializer); - } - - /** - * Creates a reconnecting client. - * - * @param address remote address - * @param connectStrategyFactory Factory for creating reconnection strategy for every reconnect attempt - * - * @return Future representing the reconnection task. It will report completion based on reestablishStrategy, e.g. - * success is never reported, only failure when it runs out of reconnection attempts. - */ - protected Future createReconnectingClient(final InetSocketAddress address, final ReconnectStrategyFactory connectStrategyFactory, - final PipelineInitializer initializer) { - final Bootstrap b = new Bootstrap(); - - final ReconnectPromise p = new ReconnectPromise<>(GlobalEventExecutor.INSTANCE, this, address, connectStrategyFactory, b, initializer); - - b.option(ChannelOption.SO_KEEPALIVE, true); - - customizeBootstrap(b); - setWorkerGroup(b); - setChannelFactory(b); - - p.connect(); - return p; - } - - private void setChannelFactory(final Bootstrap b) { - // There is no way to detect if this was already set by - // customizeBootstrap() - try { - b.channel(NioSocketChannel.class); - } catch (final IllegalStateException e) { - LOG.trace("Not overriding channelFactory on bootstrap {}", b, e); - } - } - - /** - * @deprecated Should only be used with AbstractDispatcher#AbstractDispatcher() - */ - @Deprecated - @Override - public void close() { - } -} diff --git a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/AbstractProtocolSession.java b/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/AbstractProtocolSession.java deleted file mode 100644 index 44afc4e7a1..0000000000 --- a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/AbstractProtocolSession.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.protocol.framework; - -import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.SimpleChannelInboundHandler; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Deprecated -public abstract class AbstractProtocolSession extends SimpleChannelInboundHandler implements ProtocolSession { - private static final Logger LOG = LoggerFactory.getLogger(AbstractProtocolSession.class); - - /** - * Handles incoming message (parsing, reacting if necessary). - * - * @param msg incoming message - */ - protected abstract void handleMessage(final M msg); - - /** - * Called when reached the end of input stream while reading. - */ - protected abstract void endOfInput(); - - /** - * Called when the session is added to the pipeline. - */ - protected abstract void sessionUp(); - - @Override - public final void channelInactive(final ChannelHandlerContext ctx) { - LOG.debug("Channel {} inactive.", ctx.channel()); - endOfInput(); - try { - // Forward channel inactive event, all handlers in pipeline might be interested in the event e.g. close channel handler of reconnect promise - super.channelInactive(ctx); - } catch (final Exception e) { - throw new RuntimeException("Failed to delegate channel inactive event on channel " + ctx.channel(), e); - } - } - - @Override - @SuppressWarnings("unchecked") - protected final void channelRead0(final ChannelHandlerContext ctx, final Object msg) { - LOG.debug("Message was received: {}", msg); - handleMessage((M) msg); - } - - @Override - public final void handlerAdded(final ChannelHandlerContext ctx) { - sessionUp(); - } -} diff --git a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/AbstractSessionNegotiator.java b/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/AbstractSessionNegotiator.java deleted file mode 100644 index a883eaf4ea..0000000000 --- a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/AbstractSessionNegotiator.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * 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.protocol.framework; - -import io.netty.channel.Channel; -import io.netty.channel.ChannelFutureListener; -import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; -import io.netty.util.concurrent.Promise; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.Preconditions; - -/** - * Abstract base class for session negotiators. It implements the basic - * substrate to implement SessionNegotiator API specification, with subclasses - * needing to provide only - * - * @param Protocol message type - * @param Protocol session type, has to extend {@code ProtocolSession} - */ -@Deprecated -public abstract class AbstractSessionNegotiator> extends ChannelInboundHandlerAdapter implements SessionNegotiator { - private final Logger LOG = LoggerFactory.getLogger(AbstractSessionNegotiator.class); - private final Promise promise; - protected final Channel channel; - - public AbstractSessionNegotiator(final Promise promise, final Channel channel) { - this.promise = Preconditions.checkNotNull(promise); - this.channel = Preconditions.checkNotNull(channel); - } - - protected abstract void startNegotiation() throws Exception; - protected abstract void handleMessage(M msg) throws Exception; - - protected final void negotiationSuccessful(final S session) { - LOG.debug("Negotiation on channel {} successful with session {}", channel, session); - channel.pipeline().replace(this, "session", session); - promise.setSuccess(session); - } - - protected void negotiationFailed(final Throwable cause) { - LOG.debug("Negotiation on channel {} failed", channel, cause); - channel.close(); - promise.setFailure(cause); - } - - /** - * Send a message to peer and fail negotiation if it does not reach - * the peer. - * - * @param msg Message which should be sent. - */ - protected final void sendMessage(final M msg) { - this.channel.writeAndFlush(msg).addListener( - (ChannelFutureListener) f -> { - if (!f.isSuccess()) { - LOG.info("Failed to send message {}", msg, f.cause()); - negotiationFailed(f.cause()); - } else { - LOG.trace("Message {} sent to socket", msg); - } - }); - } - - @Override - public final void channelActive(final ChannelHandlerContext ctx) { - LOG.debug("Starting session negotiation on channel {}", channel); - try { - startNegotiation(); - } catch (final Exception e) { - LOG.warn("Unexpected negotiation failure", e); - negotiationFailed(e); - } - } - - @Override - @SuppressWarnings("unchecked") - public final void channelRead(final ChannelHandlerContext ctx, final Object msg) { - LOG.debug("Negotiation read invoked on channel {}", channel); - try { - handleMessage((M)msg); - } catch (final Exception e) { - LOG.debug("Unexpected error while handling negotiation message {}", msg, e); - negotiationFailed(e); - } - } - - @Override - public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) { - LOG.info("Unexpected error during negotiation", cause); - negotiationFailed(cause); - } -} diff --git a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/NeverReconnectStrategy.java b/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/NeverReconnectStrategy.java deleted file mode 100644 index 824242cba6..0000000000 --- a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/NeverReconnectStrategy.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.protocol.framework; - -import io.netty.util.concurrent.EventExecutor; -import io.netty.util.concurrent.Future; - -import javax.annotation.concurrent.ThreadSafe; - -import com.google.common.base.Preconditions; - -/** - * Utility ReconnectStrategy singleton, which will cause the reconnect process - * to always fail. - */ -@Deprecated -@ThreadSafe -public final class NeverReconnectStrategy implements ReconnectStrategy { - private final EventExecutor executor; - private final int timeout; - - public NeverReconnectStrategy(final EventExecutor executor, final int timeout) { - Preconditions.checkArgument(timeout >= 0); - this.executor = Preconditions.checkNotNull(executor); - this.timeout = timeout; - } - - @Override - public Future scheduleReconnect(final Throwable cause) { - return executor.newFailedFuture(new Throwable("Reconnect failed", cause)); - } - - @Override - public void reconnectSuccessful() { - // Nothing to do - } - - @Override - public int getConnectTimeout() { - return timeout; - } -} diff --git a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ProtocolSession.java b/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ProtocolSession.java deleted file mode 100644 index b99844112f..0000000000 --- a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ProtocolSession.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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.protocol.framework; - -import java.io.Closeable; - -/** - * Protocol Session represents the finite state machine in underlying protocol, including timers and its purpose is to - * create a connection between server and client. Session is automatically started, when TCP connection is created, but - * can be stopped manually. If the session is up, it has to redirect messages to/from user. Handles also malformed - * messages and unknown requests. - * - * This interface should be implemented by a final class representing a protocol specific session. - */ -@Deprecated -public interface ProtocolSession extends Closeable { - @Override - void close(); -} diff --git a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ProtocolSessionPromise.java b/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ProtocolSessionPromise.java deleted file mode 100644 index 494ccf8ec4..0000000000 --- a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ProtocolSessionPromise.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * 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.protocol.framework; - -import com.google.common.base.Preconditions; -import io.netty.bootstrap.Bootstrap; -import io.netty.channel.ChannelFuture; -import io.netty.channel.ChannelFutureListener; -import io.netty.channel.ChannelOption; -import io.netty.util.concurrent.DefaultPromise; -import io.netty.util.concurrent.EventExecutor; -import io.netty.util.concurrent.Future; -import io.netty.util.concurrent.FutureListener; -import io.netty.util.concurrent.Promise; -import java.net.InetSocketAddress; -import javax.annotation.concurrent.GuardedBy; -import javax.annotation.concurrent.ThreadSafe; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Deprecated -@ThreadSafe -final class ProtocolSessionPromise> extends DefaultPromise { - private static final Logger LOG = LoggerFactory.getLogger(ProtocolSessionPromise.class); - private final ReconnectStrategy strategy; - private InetSocketAddress address; - private final Bootstrap b; - - @GuardedBy("this") - private Future pending; - - ProtocolSessionPromise(final EventExecutor executor, final InetSocketAddress address, final ReconnectStrategy strategy, - final Bootstrap b) { - super(executor); - this.strategy = Preconditions.checkNotNull(strategy); - this.address = Preconditions.checkNotNull(address); - this.b = Preconditions.checkNotNull(b); - } - - synchronized void connect() { - final Object lock = this; - - try { - final int timeout = this.strategy.getConnectTimeout(); - - LOG.debug("Promise {} attempting connect for {}ms", lock, timeout); - - if(this.address.isUnresolved()) { - this.address = new InetSocketAddress(this.address.getHostName(), this.address.getPort()); - } - this.b.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, timeout); - final ChannelFuture connectFuture = this.b.connect(this.address); - // Add listener that attempts reconnect by invoking this method again. - connectFuture.addListener(new BootstrapConnectListener(lock)); - this.pending = connectFuture; - } catch (final Exception e) { - LOG.info("Failed to connect to {}", address, e); - setFailure(e); - } - } - - @Override - public synchronized boolean cancel(final boolean mayInterruptIfRunning) { - if (super.cancel(mayInterruptIfRunning)) { - this.pending.cancel(mayInterruptIfRunning); - return true; - } - - return false; - } - - @Override - public synchronized Promise setSuccess(final S result) { - LOG.debug("Promise {} completed", this); - this.strategy.reconnectSuccessful(); - return super.setSuccess(result); - } - - private class BootstrapConnectListener implements ChannelFutureListener { - private final Object lock; - - public BootstrapConnectListener(final Object lock) { - this.lock = lock; - } - - @Override - public void operationComplete(final ChannelFuture cf) throws Exception { - synchronized (lock) { - - LOG.debug("Promise {} connection resolved", lock); - - // Triggered when a connection attempt is resolved. - Preconditions.checkState(ProtocolSessionPromise.this.pending.equals(cf)); - - /* - * The promise we gave out could have been cancelled, - * which cascades to the connect getting cancelled, - * but there is a slight race window, where the connect - * is already resolved, but the listener has not yet - * been notified -- cancellation at that point won't - * stop the notification arriving, so we have to close - * the race here. - */ - if (isCancelled()) { - if (cf.isSuccess()) { - LOG.debug("Closing channel for cancelled promise {}", lock); - cf.channel().close(); - } - return; - } - - if(cf.isSuccess()) { - LOG.debug("Promise {} connection successful", lock); - return; - } - - LOG.debug("Attempt to connect to {} failed", ProtocolSessionPromise.this.address, cf.cause()); - - final Future rf = ProtocolSessionPromise.this.strategy.scheduleReconnect(cf.cause()); - rf.addListener(new ReconnectingStrategyListener()); - ProtocolSessionPromise.this.pending = rf; - } - } - - private class ReconnectingStrategyListener implements FutureListener { - @Override - public void operationComplete(final Future sf) { - synchronized (lock) { - // Triggered when a connection attempt is to be made. - Preconditions.checkState(ProtocolSessionPromise.this.pending.equals(sf)); - - /* - * The promise we gave out could have been cancelled, - * which cascades to the reconnect attempt getting - * cancelled, but there is a slight race window, where - * the reconnect attempt is already enqueued, but the - * listener has not yet been notified -- if cancellation - * happens at that point, we need to catch it here. - */ - if (!isCancelled()) { - if (sf.isSuccess()) { - connect(); - } else { - setFailure(sf.cause()); - } - } - } - } - } - - } - -} diff --git a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ReconnectImmediatelyStrategy.java b/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ReconnectImmediatelyStrategy.java deleted file mode 100644 index 56cdcfb0c3..0000000000 --- a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ReconnectImmediatelyStrategy.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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.protocol.framework; - -import io.netty.util.concurrent.EventExecutor; -import io.netty.util.concurrent.Future; - -import javax.annotation.concurrent.ThreadSafe; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.Preconditions; - -/** - * Utility ReconnectStrategy singleton, which will cause the reconnect process - * to immediately schedule a reconnection attempt. - */ -@Deprecated -@ThreadSafe -public final class ReconnectImmediatelyStrategy implements ReconnectStrategy { - private static final Logger LOG = LoggerFactory.getLogger(ReconnectImmediatelyStrategy.class); - private final EventExecutor executor; - private final int timeout; - - public ReconnectImmediatelyStrategy(final EventExecutor executor, final int timeout) { - Preconditions.checkArgument(timeout >= 0); - this.executor = Preconditions.checkNotNull(executor); - this.timeout = timeout; - } - - @Override - public Future scheduleReconnect(final Throwable cause) { - LOG.debug("Connection attempt failed", cause); - return executor.newSucceededFuture(null); - } - - @Override - public void reconnectSuccessful() { - // Nothing to do - } - - @Override - public int getConnectTimeout() { - return timeout; - } -} diff --git a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ReconnectPromise.java b/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ReconnectPromise.java deleted file mode 100644 index f9fadb04b0..0000000000 --- a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ReconnectPromise.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * 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.protocol.framework; - -import com.google.common.base.Preconditions; -import io.netty.bootstrap.Bootstrap; -import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; -import io.netty.util.concurrent.DefaultPromise; -import io.netty.util.concurrent.EventExecutor; -import io.netty.util.concurrent.Future; -import io.netty.util.concurrent.GenericFutureListener; -import java.net.InetSocketAddress; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Deprecated -final class ReconnectPromise, L extends SessionListener> extends DefaultPromise { - private static final Logger LOG = LoggerFactory.getLogger(ReconnectPromise.class); - - private final AbstractDispatcher dispatcher; - private final InetSocketAddress address; - private final ReconnectStrategyFactory strategyFactory; - private final Bootstrap b; - private final AbstractDispatcher.PipelineInitializer initializer; - private Future pending; - - public ReconnectPromise(final EventExecutor executor, final AbstractDispatcher dispatcher, final InetSocketAddress address, - final ReconnectStrategyFactory connectStrategyFactory, final Bootstrap b, final AbstractDispatcher.PipelineInitializer initializer) { - super(executor); - this.b = b; - this.initializer = Preconditions.checkNotNull(initializer); - this.dispatcher = Preconditions.checkNotNull(dispatcher); - this.address = Preconditions.checkNotNull(address); - this.strategyFactory = Preconditions.checkNotNull(connectStrategyFactory); - } - - synchronized void connect() { - final ReconnectStrategy cs = this.strategyFactory.createReconnectStrategy(); - - // Set up a client with pre-configured bootstrap, but add a closed channel handler into the pipeline to support reconnect attempts - pending = this.dispatcher.createClient(this.address, cs, b, (channel, promise) -> { - initializer.initializeChannel(channel, promise); - // add closed channel handler - // This handler has to be added as last channel handler and the channel inactive event has to be caught by it - // Handlers in front of it can react to channelInactive event, but have to forward the event or the reconnect will not work - // This handler is last so all handlers in front of it can handle channel inactive (to e.g. resource cleanup) before a new connection is started - channel.pipeline().addLast(new ClosedChannelHandler(ReconnectPromise.this)); - }); - - pending.addListener((GenericFutureListener>) future -> { - if (!future.isSuccess()) { - ReconnectPromise.this.setFailure(future.cause()); - } - }); - } - - /** - * - * @return true if initial connection was established successfully, false if initial connection failed due to e.g. Connection refused, Negotiation failed - */ - private boolean isInitialConnectFinished() { - Preconditions.checkNotNull(pending); - return pending.isDone() && pending.isSuccess(); - } - - @Override - public synchronized boolean cancel(final boolean mayInterruptIfRunning) { - if (super.cancel(mayInterruptIfRunning)) { - Preconditions.checkNotNull(pending); - this.pending.cancel(mayInterruptIfRunning); - return true; - } - - return false; - } - - /** - * Channel handler that responds to channelInactive event and reconnects the session. - * Only if the promise was not canceled. - */ - private static final class ClosedChannelHandler extends ChannelInboundHandlerAdapter { - private final ReconnectPromise promise; - - public ClosedChannelHandler(final ReconnectPromise promise) { - this.promise = promise; - } - - @Override - public void channelInactive(final ChannelHandlerContext ctx) throws Exception { - // This is the ultimate channel inactive handler, not forwarding - if (promise.isCancelled()) { - return; - } - - if (promise.isInitialConnectFinished() == false) { - LOG.debug("Connection to {} was dropped during negotiation, reattempting", promise.address); - } - - LOG.debug("Reconnecting after connection to {} was dropped", promise.address); - promise.connect(); - } - } - -} diff --git a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ReconnectStrategy.java b/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ReconnectStrategy.java deleted file mode 100644 index a0a9150799..0000000000 --- a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ReconnectStrategy.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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.protocol.framework; - -import io.netty.util.concurrent.Future; - -/** - * Interface exposed by a reconnection strategy provider. A reconnection - * strategy decides whether to attempt reconnection and when to do that. - * - * The proper way of using this API is such that when a connection attempt - * has failed, the user will call scheduleReconnect() to obtain a future, - * which tracks schedule of the next connect attempt. The user should add its - * own listener to be get notified when the future is done. Once the - * the notification fires, user should examine the future to see whether - * it is successful or not. If it is successful, the user should immediately - * initiate a connection attempt. If it is unsuccessful, the user must - * not attempt any more connection attempts and should abort the reconnection - * process. - */ -@Deprecated -public interface ReconnectStrategy { - /** - * Query the strategy for the connect timeout. - * - * @return connect try timeout in milliseconds, or - * 0 for infinite (or system-default) timeout - * @throws Exception if the connection should not be attempted - */ - int getConnectTimeout() throws Exception; - - /** - * Schedule a connection attempt. The precise time when the connection - * should be attempted is signaled by successful completion of returned - * future. - * - * @param cause Cause of previous failure - * @return a future tracking the schedule, may not be null - * @throws IllegalStateException when a connection attempt is currently - * scheduled. - */ - Future scheduleReconnect(Throwable cause); - - /** - * Reset the strategy state. Users call this method once the reconnection - * process succeeds. - */ - void reconnectSuccessful(); -} diff --git a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ReconnectStrategyFactory.java b/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ReconnectStrategyFactory.java deleted file mode 100644 index a71fa677c8..0000000000 --- a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ReconnectStrategyFactory.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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.protocol.framework; - -/** - * Factory interface for creating new ReconnectStrategy instances. This is - * primarily useful for allowing injection of a specific type of strategy for - * on-demand use, pretty much like you would use a ThreadFactory. - */ -@Deprecated -public interface ReconnectStrategyFactory { - /** - * Create a new ReconnectStrategy. - * - * @return a new reconnecty strategy - */ - ReconnectStrategy createReconnectStrategy(); -} - diff --git a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/SessionListener.java b/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/SessionListener.java deleted file mode 100644 index 06b2730730..0000000000 --- a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/SessionListener.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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.protocol.framework; - -import java.util.EventListener; - -/** - * Listener that receives session state information. This interface should be - * implemented by a protocol specific abstract class, that is extended by - * a final class that implements the methods. - */ -@Deprecated -public interface SessionListener, T extends TerminationReason> extends EventListener { - /** - * Fired when the session was established successfully. - * - * @param session New session - */ - void onSessionUp(S session); - - /** - * Fired when the session went down because of an IO error. Implementation should take care of closing underlying - * session. - * - * @param session that went down - * @param e Exception that was thrown as the cause of session being down - */ - void onSessionDown(S session, Exception e); - - /** - * Fired when the session is terminated locally. The session has already been closed and transitioned to IDLE state. - * Any outstanding queued messages were not sent. The user should not attempt to make any use of the session. - * - * @param reason the cause why the session went down - */ - void onSessionTerminated(S session, T reason); - - /** - * Fired when a normal protocol message is received. - * - * @param message Protocol message - */ - void onMessage(S session, M message); -} diff --git a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/SessionListenerFactory.java b/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/SessionListenerFactory.java deleted file mode 100644 index 99087a5434..0000000000 --- a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/SessionListenerFactory.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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.protocol.framework; - - -/** - * Factory for generating Session Listeners. Used by a server. This interface should be - * implemented by a protocol specific abstract class, that is extended by - * a final class that implements the methods. - */ -@Deprecated -public interface SessionListenerFactory> { - /** - * Returns one session listener - * @return specific session listener - */ - T getSessionListener(); -} diff --git a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/SessionNegotiator.java b/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/SessionNegotiator.java deleted file mode 100644 index c2abf50716..0000000000 --- a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/SessionNegotiator.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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.protocol.framework; - -import io.netty.channel.ChannelInboundHandler; - -/** - * Session negotiator concepts. A negotiator is responsible for message - * handling while the exact session parameters are not known. Once the - * session parameters are finalized, the negotiator replaces itself in - * the channel pipeline with the session. - * - * @param Protocol session type. - */ -@Deprecated -public interface SessionNegotiator> extends ChannelInboundHandler { - -} diff --git a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/SessionNegotiatorFactory.java b/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/SessionNegotiatorFactory.java deleted file mode 100644 index 66293f368f..0000000000 --- a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/SessionNegotiatorFactory.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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.protocol.framework; - -import io.netty.channel.Channel; -import io.netty.util.concurrent.Promise; - -/** - * A factory class creating SessionNegotiators. - * - * @param session type - */ -@Deprecated -public interface SessionNegotiatorFactory, L extends SessionListener> { - /** - * Create a new negotiator attached to a channel, which will notify - * a promise once the negotiation completes. - * - * @param channel Underlying channel - * @param promise Promise to be notified - * @return new negotiator instance - */ - SessionNegotiator getSessionNegotiator(SessionListenerFactory factory, Channel channel, Promise promise); -} diff --git a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/TerminationReason.java b/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/TerminationReason.java deleted file mode 100644 index 19d11125e5..0000000000 --- a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/TerminationReason.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * 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.protocol.framework; - -/** - * Marker interface for grouping session termination cause. - */ -@Deprecated -public interface TerminationReason { - - /** - * Get cause of session termination. - * @return human-readable cause. - */ - String getErrorMessage(); -} - diff --git a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/TimedReconnectStrategy.java b/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/TimedReconnectStrategy.java deleted file mode 100644 index 6a1607803b..0000000000 --- a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/TimedReconnectStrategy.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * 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.protocol.framework; - -import io.netty.util.concurrent.EventExecutor; -import io.netty.util.concurrent.Future; - -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - -import javax.annotation.concurrent.GuardedBy; -import javax.annotation.concurrent.ThreadSafe; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.Preconditions; - -/** - * Swiss army knife equivalent for reconnect strategies. - * - * This strategy continues to schedule reconnect attempts, each having to complete in a fixed time (connectTime). - * - * Initial sleep time is specified as minSleep. Each subsequent unsuccessful attempt multiplies this time by a constant - * factor (sleepFactor) -- this allows for either constant reconnect times (sleepFactor = 1), or various degrees of - * exponential back-off (sleepFactor > 1). Maximum sleep time between attempts can be capped to a specific value - * (maxSleep). - * - * The strategy can optionally give up based on two criteria: - * - * A preset number of connection retries (maxAttempts) has been reached, or - * - * A preset absolute deadline is reached (deadline nanoseconds, as reported by System.nanoTime(). In this specific case, - * both connectTime and maxSleep will be controlled such that the connection attempt is resolved as closely to the - * deadline as possible. - * - * Both these caps can be combined, with the strategy giving up as soon as the first one is reached. - */ -@Deprecated -@ThreadSafe -public final class TimedReconnectStrategy implements ReconnectStrategy { - private static final Logger LOG = LoggerFactory.getLogger(TimedReconnectStrategy.class); - private final EventExecutor executor; - private final Long deadline, maxAttempts, maxSleep; - private final double sleepFactor; - private final int connectTime; - private final long minSleep; - - @GuardedBy("this") - private long attempts; - - @GuardedBy("this") - private long lastSleep; - - @GuardedBy("this") - private boolean scheduled; - - public TimedReconnectStrategy(final EventExecutor executor, final int connectTime, final long minSleep, final double sleepFactor, - final Long maxSleep, final Long maxAttempts, final Long deadline) { - Preconditions.checkArgument(maxSleep == null || minSleep <= maxSleep); - Preconditions.checkArgument(sleepFactor >= 1); - Preconditions.checkArgument(connectTime >= 0); - this.executor = Preconditions.checkNotNull(executor); - this.deadline = deadline; - this.maxAttempts = maxAttempts; - this.minSleep = minSleep; - this.maxSleep = maxSleep; - this.sleepFactor = sleepFactor; - this.connectTime = connectTime; - } - - @Override - public synchronized Future scheduleReconnect(final Throwable cause) { - LOG.debug("Connection attempt failed", cause); - - // Check if a reconnect attempt is scheduled - Preconditions.checkState(!this.scheduled); - - // Get a stable 'now' time for deadline calculations - final long now = System.nanoTime(); - - // Obvious stop conditions - if (this.maxAttempts != null && this.attempts >= this.maxAttempts) { - return this.executor.newFailedFuture(new Throwable("Maximum reconnection attempts reached")); - } - if (this.deadline != null && this.deadline <= now) { - return this.executor.newFailedFuture(new TimeoutException("Reconnect deadline reached")); - } - - /* - * First connection attempt gets initialized to minimum sleep, - * each subsequent is exponentially backed off by sleepFactor. - */ - if (this.attempts != 0) { - this.lastSleep *= this.sleepFactor; - } else { - this.lastSleep = this.minSleep; - } - - // Cap the sleep time to maxSleep - if (this.maxSleep != null && this.lastSleep > this.maxSleep) { - LOG.debug("Capped sleep time from {} to {}", this.lastSleep, this.maxSleep); - this.lastSleep = this.maxSleep; - } - - this.attempts++; - - // Check if the reconnect attempt is within the deadline - if (this.deadline != null && this.deadline <= now + TimeUnit.MILLISECONDS.toNanos(this.lastSleep)) { - return this.executor.newFailedFuture(new TimeoutException("Next reconnect would happen after deadline")); - } - - LOG.debug("Connection attempt {} sleeping for {} milliseconds", this.attempts, this.lastSleep); - - // If we are not sleeping at all, return an already-succeeded future - if (this.lastSleep == 0) { - return this.executor.newSucceededFuture(null); - } - - // Need to retain a final reference to this for locking purposes, - // also set the scheduled flag. - final Object lock = this; - this.scheduled = true; - - // Schedule a task for the right time. It will also clear the flag. - return this.executor.schedule(() -> { - synchronized (lock) { - Preconditions.checkState(TimedReconnectStrategy.this.scheduled); - TimedReconnectStrategy.this.scheduled = false; - } - - return null; - }, this.lastSleep, TimeUnit.MILLISECONDS); - } - - @Override - public synchronized void reconnectSuccessful() { - Preconditions.checkState(!this.scheduled); - this.attempts = 0; - } - - @Override - public int getConnectTimeout() throws TimeoutException { - int timeout = this.connectTime; - - if (this.deadline != null) { - - // If there is a deadline, we may need to cap the connect - // timeout to meet the deadline. - final long now = System.nanoTime(); - if (now >= this.deadline) { - throw new TimeoutException("Reconnect deadline already passed"); - } - - final long left = TimeUnit.NANOSECONDS.toMillis(this.deadline - now); - if (left < 1) { - throw new TimeoutException("Connect timeout too close to deadline"); - } - - /* - * A bit of magic: - * - if time left is less than the timeout, set it directly - * - if there is no timeout, and time left is: - * - less than maximum integer, set timeout to time left - * - more than maximum integer, set timeout Integer.MAX_VALUE - */ - if (timeout > left) { - timeout = (int) left; - } else if (timeout == 0) { - timeout = left <= Integer.MAX_VALUE ? (int) left : Integer.MAX_VALUE; - } - } - return timeout; - } -} diff --git a/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/ServerTest.java b/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/ServerTest.java deleted file mode 100644 index ce82096cfe..0000000000 --- a/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/ServerTest.java +++ /dev/null @@ -1,250 +0,0 @@ -/* - * 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.protocol.framework; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -import io.netty.channel.ChannelFuture; -import io.netty.channel.nio.NioEventLoopGroup; -import io.netty.util.concurrent.DefaultPromise; -import io.netty.util.concurrent.Future; -import io.netty.util.concurrent.GlobalEventExecutor; -import io.netty.util.concurrent.Promise; -import io.netty.util.concurrent.SucceededFuture; -import java.io.IOException; -import java.net.InetSocketAddress; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; - -public class ServerTest { - SimpleDispatcher clientDispatcher, dispatcher; - - SimpleSession session = null; - - ChannelFuture server = null; - - InetSocketAddress serverAddress; - private NioEventLoopGroup eventLoopGroup; - // Dedicated loop group for server, needed for testing reconnection client - // With dedicated server group we can simulate session drop by shutting only the server group down - private NioEventLoopGroup serverLoopGroup; - - @Before - public void setUp() { - final int port = 10000 + (int)(10000 * Math.random()); - serverAddress = new InetSocketAddress("127.0.0.1", port); - eventLoopGroup = new NioEventLoopGroup(); - serverLoopGroup = new NioEventLoopGroup(); - } - - @After - public void tearDown() throws IOException, InterruptedException, ExecutionException { - if(server != null) { - this.server.channel().close(); - } - this.eventLoopGroup.shutdownGracefully().get(); - this.serverLoopGroup.shutdownGracefully().get(); - try { - Thread.sleep(500); - } catch (final InterruptedException e) { - throw new RuntimeException(e); - } - } - - @Test - public void testConnectionRefused() throws Exception { - this.clientDispatcher = getClientDispatcher(); - - final ReconnectStrategy mockReconnectStrategy = getMockedReconnectStrategy(); - - this.clientDispatcher.createClient(this.serverAddress, mockReconnectStrategy, SimpleSessionListener::new); - - Mockito.verify(mockReconnectStrategy, timeout(5000).atLeast(2)).scheduleReconnect(any(Throwable.class)); - } - - @Test - public void testConnectionReestablishInitial() throws Exception { - this.clientDispatcher = getClientDispatcher(); - - final ReconnectStrategy mockReconnectStrategy = getMockedReconnectStrategy(); - - this.clientDispatcher.createClient(this.serverAddress, mockReconnectStrategy, SimpleSessionListener::new); - - Mockito.verify(mockReconnectStrategy, timeout(5000).atLeast(2)).scheduleReconnect(any(Throwable.class)); - - final Promise p = new DefaultPromise<>(GlobalEventExecutor.INSTANCE); - this.dispatcher = getServerDispatcher(p); - - this.server = this.dispatcher.createServer(this.serverAddress, SimpleSessionListener::new); - - this.server.get(); - - assertEquals(true, p.get(3, TimeUnit.SECONDS)); - } - - @Test - public void testConnectionDrop() throws Exception { - final Promise p = new DefaultPromise<>(GlobalEventExecutor.INSTANCE); - - this.dispatcher = getServerDispatcher(p); - - this.server = this.dispatcher.createServer(this.serverAddress, SimpleSessionListener::new); - - this.server.get(); - - this.clientDispatcher = getClientDispatcher(); - - final ReconnectStrategy reconnectStrategy = getMockedReconnectStrategy(); - this.session = this.clientDispatcher.createClient(this.serverAddress, - reconnectStrategy, SimpleSessionListener::new).get(6, TimeUnit.SECONDS); - - assertEquals(true, p.get(3, TimeUnit.SECONDS)); - - shutdownServer(); - - // No reconnect should be scheduled after server drops connection with not-reconnecting client - verify(reconnectStrategy, times(0)).scheduleReconnect(any(Throwable.class)); - } - - @Test - public void testConnectionReestablishAfterDrop() throws Exception { - final Promise p = new DefaultPromise<>(GlobalEventExecutor.INSTANCE); - - this.dispatcher = getServerDispatcher(p); - - this.server = this.dispatcher.createServer(this.serverAddress, SimpleSessionListener::new); - - this.server.get(); - - this.clientDispatcher = getClientDispatcher(); - - final ReconnectStrategyFactory reconnectStrategyFactory = mock(ReconnectStrategyFactory.class); - final ReconnectStrategy reconnectStrategy = getMockedReconnectStrategy(); - doReturn(reconnectStrategy).when(reconnectStrategyFactory).createReconnectStrategy(); - - this.clientDispatcher.createReconnectingClient(this.serverAddress, - reconnectStrategyFactory, SimpleSessionListener::new); - - assertEquals(true, p.get(3, TimeUnit.SECONDS)); - shutdownServer(); - - verify(reconnectStrategyFactory, timeout(20000).atLeast(2)).createReconnectStrategy(); - } - - @Test - public void testConnectionEstablished() throws Exception { - final Promise p = new DefaultPromise<>(GlobalEventExecutor.INSTANCE); - - this.dispatcher = getServerDispatcher(p); - - this.server = this.dispatcher.createServer(this.serverAddress, SimpleSessionListener::new); - - this.server.get(); - - this.clientDispatcher = getClientDispatcher(); - - this.session = this.clientDispatcher.createClient(this.serverAddress, - new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, 5000), SimpleSessionListener::new).get(6, - TimeUnit.SECONDS); - - assertEquals(true, p.get(3, TimeUnit.SECONDS)); - } - - @Test - public void testConnectionFailed() throws IOException, InterruptedException, ExecutionException, TimeoutException { - final Promise p = new DefaultPromise<>(GlobalEventExecutor.INSTANCE); - - this.dispatcher = getServerDispatcher(p); - - this.server = this.dispatcher.createServer(this.serverAddress, SimpleSessionListener::new); - - this.server.get(); - - this.clientDispatcher = getClientDispatcher(); - - this.session = this.clientDispatcher.createClient(this.serverAddress, - new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, 5000), SimpleSessionListener::new).get(6, - TimeUnit.SECONDS); - - final Future session = this.clientDispatcher.createClient(this.serverAddress, - new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, 5000), SimpleSessionListener::new); - assertFalse(session.isSuccess()); - } - - @Test - public void testNegotiationFailedReconnect() throws Exception { - final Promise p = new DefaultPromise<>(GlobalEventExecutor.INSTANCE); - - this.dispatcher = getServerDispatcher(p); - - this.server = this.dispatcher.createServer(this.serverAddress, SimpleSessionListener::new); - - this.server.get(); - - this.clientDispatcher = new SimpleDispatcher( - (factory, channel, promise) -> new SimpleSessionNegotiator(promise, channel) { - @Override - protected void startNegotiation() throws Exception { - negotiationFailed(new IllegalStateException("Negotiation failed")); - } - }, new DefaultPromise<>(GlobalEventExecutor.INSTANCE), eventLoopGroup); - - final ReconnectStrategyFactory reconnectStrategyFactory = mock(ReconnectStrategyFactory.class); - final ReconnectStrategy reconnectStrategy = getMockedReconnectStrategy(); - doReturn(reconnectStrategy).when(reconnectStrategyFactory).createReconnectStrategy(); - - this.clientDispatcher.createReconnectingClient(this.serverAddress, - reconnectStrategyFactory, SimpleSessionListener::new); - - - // Reconnect strategy should be consulted at least twice, for initial connect and reconnect attempts after drop - verify(reconnectStrategyFactory, timeout((int) TimeUnit.MINUTES.toMillis(3)).atLeast(2)).createReconnectStrategy(); - } - - private SimpleDispatcher getClientDispatcher() { - return new SimpleDispatcher((factory, channel, promise) -> new SimpleSessionNegotiator(promise, channel), new DefaultPromise<>(GlobalEventExecutor.INSTANCE), eventLoopGroup); - } - - private ReconnectStrategy getMockedReconnectStrategy() throws Exception { - final ReconnectStrategy mockReconnectStrategy = mock(ReconnectStrategy.class); - final Future future = new SucceededFuture<>(GlobalEventExecutor.INSTANCE, null); - doReturn(future).when(mockReconnectStrategy).scheduleReconnect(any(Throwable.class)); - doReturn(5000).when(mockReconnectStrategy).getConnectTimeout(); - doNothing().when(mockReconnectStrategy).reconnectSuccessful(); - return mockReconnectStrategy; - } - - - private void shutdownServer() throws InterruptedException, ExecutionException { - // Shutdown server - server.channel().close().get(); - // Closing server channel does not close established connections, eventLoop has to be closed as well to simulate dropped session - serverLoopGroup.shutdownGracefully().get(); - } - - private SimpleDispatcher getServerDispatcher(final Promise p) { - return new SimpleDispatcher((factory, channel, promise) -> { - p.setSuccess(true); - return new SimpleSessionNegotiator(promise, channel); - }, null, serverLoopGroup); - } - -} diff --git a/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/Session.java b/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/Session.java deleted file mode 100644 index b1defd25cb..0000000000 --- a/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/Session.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.protocol.framework; - -import java.util.List; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.collect.Lists; - -public class Session extends AbstractProtocolSession { - - private static final Logger LOG = LoggerFactory.getLogger(Session.class); - - public final List msgs = Lists.newArrayList(); - - public boolean up = false; - - @Override - public void close() { - - } - - @Override - public void handleMessage(final SimpleMessage msg) { - LOG.debug("Message received: {}", msg.getMessage()); - this.up = true; - this.msgs.add(msg); - LOG.debug(this.msgs.size() + ""); - } - - @Override - public void endOfInput() { - LOG.debug("End of input reported."); - } - - @Override - protected void sessionUp() { - LOG.debug("Session up reported."); - } -} diff --git a/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleByteToMessageDecoder.java b/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleByteToMessageDecoder.java deleted file mode 100644 index 36bf4a1740..0000000000 --- a/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleByteToMessageDecoder.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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.protocol.framework; - -import io.netty.buffer.ByteBuf; -import io.netty.channel.ChannelHandlerContext; -import io.netty.handler.codec.ByteToMessageDecoder; -import java.nio.charset.StandardCharsets; -import java.util.List; - -/** - * - */ -public class SimpleByteToMessageDecoder extends ByteToMessageDecoder { - @Override - protected void decode(final ChannelHandlerContext ctx, final ByteBuf in, final List out) { - out.add(new SimpleMessage(StandardCharsets.UTF_8.decode(in.nioBuffer()).toString())); - } -} diff --git a/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleDispatcher.java b/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleDispatcher.java deleted file mode 100644 index 314fd42c7d..0000000000 --- a/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleDispatcher.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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.protocol.framework; - -import io.netty.channel.ChannelFuture; -import io.netty.channel.ChannelOutboundHandler; -import io.netty.channel.EventLoopGroup; -import io.netty.channel.socket.SocketChannel; -import io.netty.util.concurrent.Future; -import io.netty.util.concurrent.Promise; - -import java.net.InetSocketAddress; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.Preconditions; - -public class SimpleDispatcher extends AbstractDispatcher { - private static final Logger LOG = LoggerFactory.getLogger(SimpleDispatcher.class); - - private final SessionNegotiatorFactory negotiatorFactory; - private final ChannelOutboundHandler encoder = new SimpleMessageToByteEncoder(); - - private final class SimplePipelineInitializer implements PipelineInitializer { - final SessionListenerFactory listenerFactory; - - SimplePipelineInitializer(final SessionListenerFactory listenerFactory) { - this.listenerFactory = Preconditions.checkNotNull(listenerFactory); - } - - @Override - public void initializeChannel(final SocketChannel channel, final Promise promise) { - channel.pipeline().addLast(new SimpleByteToMessageDecoder()); - channel.pipeline().addLast("negotiator", negotiatorFactory.getSessionNegotiator(listenerFactory, channel, promise)); - channel.pipeline().addLast(encoder); - LOG.debug("initialization completed for channel {}", channel); - } - - } - - public SimpleDispatcher(final SessionNegotiatorFactory negotiatorFactory, - final Promise promise, final EventLoopGroup eventLoopGroup) { - super(eventLoopGroup, eventLoopGroup); - this.negotiatorFactory = Preconditions.checkNotNull(negotiatorFactory); - } - - public Future createClient(final InetSocketAddress address, final ReconnectStrategy strategy, final SessionListenerFactory listenerFactory) { - return super.createClient(address, strategy, new SimplePipelineInitializer(listenerFactory)); - } - - public Future createReconnectingClient(final InetSocketAddress address, final ReconnectStrategyFactory strategy, final SessionListenerFactory listenerFactory) { - return super.createReconnectingClient(address, strategy, new SimplePipelineInitializer(listenerFactory)); - } - - public ChannelFuture createServer(final InetSocketAddress address, final SessionListenerFactory listenerFactory) { - return super.createServer(address, new SimplePipelineInitializer(listenerFactory)); - } - - @Override - public void close() { - } -} diff --git a/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleMessage.java b/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleMessage.java deleted file mode 100644 index 551d657c34..0000000000 --- a/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleMessage.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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.protocol.framework; - -public class SimpleMessage { - - private final String s; - - public SimpleMessage(final String s) { - this.s = s; - } - - public String getMessage() { - return this.s; - } -} diff --git a/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleMessageToByteEncoder.java b/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleMessageToByteEncoder.java deleted file mode 100644 index b3ed3b7c04..0000000000 --- a/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleMessageToByteEncoder.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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.protocol.framework; - -import io.netty.buffer.ByteBuf; -import io.netty.channel.ChannelHandler.Sharable; -import io.netty.channel.ChannelHandlerContext; -import io.netty.handler.codec.MessageToByteEncoder; - -/** - * - */ -@Sharable -public class SimpleMessageToByteEncoder extends MessageToByteEncoder { - @Override - protected void encode(final ChannelHandlerContext ctx, final SimpleMessage msg, final ByteBuf out) { - out.writeBytes(msg.getMessage().getBytes()); - } -} diff --git a/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleSession.java b/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleSession.java deleted file mode 100644 index 9056f8d341..0000000000 --- a/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleSession.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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.protocol.framework; - -public final class SimpleSession extends AbstractProtocolSession { - - public SimpleSession() { - } - - @Override - public void close() { - } - - @Override - public void handleMessage(final SimpleMessage msg) { - } - - @Override - public void endOfInput() { - } - - @Override - protected void sessionUp() { - } -} diff --git a/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleSessionListener.java b/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleSessionListener.java deleted file mode 100644 index 8db14f7f5a..0000000000 --- a/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleSessionListener.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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.protocol.framework; - -import java.util.ArrayList; -import java.util.List; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Simple Session Listener that is notified about messages and changes in the session. - */ -public class SimpleSessionListener implements SessionListener { - private static final Logger LOG = LoggerFactory.getLogger(SimpleSessionListener.class); - - public List messages = new ArrayList<>(); - - public boolean up = false; - - public boolean failed = false; - - @Override - public void onMessage(final SimpleSession session, final SimpleMessage message) { - LOG.debug("Received message: " + message.getClass() + " " + message); - this.messages.add(message); - } - - @Override - public void onSessionUp(final SimpleSession session) { - this.up = true; - } - - @Override - public void onSessionDown(final SimpleSession session, final Exception e) { - this.failed = true; - this.notifyAll(); - } - - @Override - public void onSessionTerminated(final SimpleSession session, final TerminationReason reason) { - this.failed = true; - this.notifyAll(); - } -} diff --git a/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleSessionListenerFactory.java b/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleSessionListenerFactory.java deleted file mode 100644 index 3fabe3cc8f..0000000000 --- a/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleSessionListenerFactory.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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.protocol.framework; - -public class SimpleSessionListenerFactory implements SessionListenerFactory { - - @Override - public SimpleSessionListener getSessionListener() { - return new SimpleSessionListener(); - } -} diff --git a/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleSessionNegotiator.java b/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleSessionNegotiator.java deleted file mode 100644 index e78f2f7fa6..0000000000 --- a/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleSessionNegotiator.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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.protocol.framework; - -import io.netty.channel.Channel; -import io.netty.util.concurrent.Promise; - -public class SimpleSessionNegotiator extends AbstractSessionNegotiator { - - public SimpleSessionNegotiator(final Promise promise, final Channel channel) { - super(promise, channel); - } - - @Override - protected void startNegotiation() throws Exception { - negotiationSuccessful(new SimpleSession()); - } - - @Override - protected void handleMessage(final SimpleMessage msg) throws Exception { - throw new IllegalStateException("This method should never be invoked"); - } -} diff --git a/pom.xml b/pom.xml index 295d7a0485..4051762b44 100644 --- a/pom.xml +++ b/pom.xml @@ -26,7 +26,6 @@ opendaylight/blueprint - opendaylight/commons/protocol-framework opendaylight/commons/liblldp benchmark opendaylight/commons/jolokia