Use Future.cause() for completion checking
[netconf.git] / netconf / netconf-netty-util / src / main / java / org / opendaylight / netconf / nettyutil / AbstractNetconfDispatcher.java
index 7997095850c9a2890420e46bb972fa00440bde23..79d6ca3f2d939656c28802ebf5997737b8512248 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.netconf.nettyutil;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import io.netty.bootstrap.Bootstrap;
 import io.netty.bootstrap.ServerBootstrap;
 import io.netty.buffer.PooledByteBufAllocator;
@@ -26,7 +27,6 @@ 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.opendaylight.netconf.api.NetconfSession;
@@ -39,9 +39,7 @@ import org.slf4j.LoggerFactory;
  * start method that will handle sockets in different thread.
  */
 @Deprecated
-public abstract class AbstractNetconfDispatcher<S extends NetconfSession, L extends NetconfSessionListener<? super S>>
-        implements Closeable {
-
+public abstract class AbstractNetconfDispatcher<S extends NetconfSession, L extends NetconfSessionListener<? super S>> {
     protected interface ChannelPipelineInitializer<C extends Channel, S extends NetconfSession> {
         /**
          * Initializes channel by specifying the handlers in its pipeline. Handlers are protocol specific, therefore
@@ -58,7 +56,6 @@ public abstract class AbstractNetconfDispatcher<S extends NetconfSession, L exte
 
     }
 
-
     private static final Logger LOG = LoggerFactory.getLogger(AbstractNetconfDispatcher.class);
 
     private final EventLoopGroup bossGroup;
@@ -73,9 +70,9 @@ public abstract class AbstractNetconfDispatcher<S extends NetconfSession, L exte
 
     protected AbstractNetconfDispatcher(final EventExecutor executor, final EventLoopGroup bossGroup,
             final EventLoopGroup workerGroup) {
-        this.bossGroup = Preconditions.checkNotNull(bossGroup);
-        this.workerGroup = Preconditions.checkNotNull(workerGroup);
-        this.executor = Preconditions.checkNotNull(executor);
+        this.bossGroup = requireNonNull(bossGroup);
+        this.workerGroup = requireNonNull(workerGroup);
+        this.executor = requireNonNull(executor);
     }
 
 
@@ -211,25 +208,6 @@ public abstract class AbstractNetconfDispatcher<S extends NetconfSession, L exte
         return p;
     }
 
-    /**
-     * 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 Use
-     *             {@link #createReconnectingClient(InetSocketAddress, ReconnectStrategyFactory, PipelineInitializer)}
-     *             instead.
-     */
-    @Deprecated
-    protected Future<Void> createReconnectingClient(final InetSocketAddress address,
-            final ReconnectStrategyFactory connectStrategyFactory, final ReconnectStrategy reestablishStrategy,
-            final PipelineInitializer<S> initializer) {
-        return createReconnectingClient(address, connectStrategyFactory, initializer);
-    }
-
     /**
      * Creates a reconnecting client.
      *
@@ -238,7 +216,7 @@ public abstract class AbstractNetconfDispatcher<S extends NetconfSession, L exte
      * @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<Void> createReconnectingClient(final InetSocketAddress address,
+    protected ReconnectFuture createReconnectingClient(final InetSocketAddress address,
             final ReconnectStrategyFactory connectStrategyFactory, final PipelineInitializer<S> initializer) {
         final Bootstrap b = new Bootstrap();
 
@@ -270,9 +248,4 @@ public abstract class AbstractNetconfDispatcher<S extends NetconfSession, L exte
             bootstrap.group(workerGroup);
         }
     }
-
-    @Deprecated
-    @Override
-    public void close() {
-    }
 }