Specialize protocol-framework to netconf 37/79237/6
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 4 Jan 2019 14:24:23 +0000 (15:24 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 4 Jan 2019 17:07:27 +0000 (18:07 +0100)
As a first step towards sanity, we eliminate protocol-framwork
by moving it into netconf-api, but specialized to deal with
NETCONF protocol only.

This eliminates one level of abstraction, allowing us to reduce
the number of classes and artifacts involved. We also sacrifice
tests, as most of the mechanics should be covered by netconf-level
tests.

JIRA: NETCONF-554
Change-Id: Iba41c5ad72a0148d4e1d768d3122ddebce18f4c2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
66 files changed:
features/netconf/odl-netconf-api/pom.xml
features/pom.xml
features/protocol-framework/features-protocol-framework/pom.xml [deleted file]
features/protocol-framework/odl-protocol-framework/pom.xml [deleted file]
features/protocol-framework/pom.xml [deleted file]
netconf/callhome-protocol/src/main/java/org/opendaylight/netconf/callhome/protocol/ReverseSshChannelInitializer.java
netconf/callhome-provider/src/test/java/org/opendaylight/netconf/callhome/mount/CallHomeMountDispatcherTest.java
netconf/netconf-api/pom.xml
netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/NetconfSession.java
netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/NetconfSessionListener.java
netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/NetconfSessionListenerFactory.java [moved from protocol-framework/src/main/java/org/opendaylight/protocol/framework/SessionListenerFactory.java with 78% similarity]
netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/NetconfTerminationReason.java
netconf/netconf-artifacts/pom.xml
netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/NetconfClientDispatcherImpl.java
netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/NetconfClientSessionNegotiatorFactory.java
netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/conf/NetconfClientConfiguration.java
netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/conf/NetconfClientConfigurationBuilder.java
netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/conf/NetconfReconnectingClientConfiguration.java
netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/conf/NetconfReconnectingClientConfigurationBuilder.java
netconf/netconf-client/src/test/java/org/opendaylight/netconf/client/NetconfClientConfigurationTest.java
netconf/netconf-client/src/test/java/org/opendaylight/netconf/client/NetconfClientDispatcherImplTest.java
netconf/netconf-client/src/test/java/org/opendaylight/netconf/client/NetconfClientSessionNegotiatorFactoryTest.java
netconf/netconf-client/src/test/java/org/opendaylight/netconf/client/NetconfReconnectingClientConfigurationTest.java
netconf/netconf-client/src/test/java/org/opendaylight/netconf/client/SshClientChannelInitializerTest.java
netconf/netconf-client/src/test/java/org/opendaylight/netconf/client/TcpClientChannelInitializerTest.java
netconf/netconf-client/src/test/java/org/opendaylight/netconf/client/TestingNetconfClient.java
netconf/netconf-client/src/test/java/org/opendaylight/netconf/client/TlsClientChannelInitializerTest.java
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/NetconfServerDispatcherImpl.java
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/NetconfServerSessionNegotiatorFactory.java
netconf/netconf-impl/src/test/java/org/opendaylight/netconf/impl/ConcurrentClientsTest.java
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractNetconfDispatcher.java [moved from protocol-framework/src/main/java/org/opendaylight/protocol/framework/AbstractDispatcher.java with 73% similarity]
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSession.java
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSessionNegotiator.java
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/NetconfSessionNegotiator.java [moved from protocol-framework/src/main/java/org/opendaylight/protocol/framework/SessionNegotiator.java with 77% similarity]
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/NetconfSessionNegotiatorFactory.java [moved from protocol-framework/src/main/java/org/opendaylight/protocol/framework/SessionNegotiatorFactory.java with 60% similarity]
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/NetconfSessionPromise.java [moved from protocol-framework/src/main/java/org/opendaylight/protocol/framework/ProtocolSessionPromise.java with 74% similarity]
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/NeverReconnectStrategy.java [moved from protocol-framework/src/main/java/org/opendaylight/protocol/framework/NeverReconnectStrategy.java with 96% similarity]
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/ReconnectImmediatelyStrategy.java [moved from protocol-framework/src/main/java/org/opendaylight/protocol/framework/ReconnectImmediatelyStrategy.java with 97% similarity]
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/ReconnectPromise.java [moved from protocol-framework/src/main/java/org/opendaylight/protocol/framework/ReconnectPromise.java with 70% similarity]
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/ReconnectStrategy.java [moved from protocol-framework/src/main/java/org/opendaylight/protocol/framework/ReconnectStrategy.java with 97% similarity]
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/ReconnectStrategyFactory.java [moved from protocol-framework/src/main/java/org/opendaylight/protocol/framework/ReconnectStrategyFactory.java with 94% similarity]
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/TimedReconnectStrategy.java [moved from protocol-framework/src/main/java/org/opendaylight/protocol/framework/TimedReconnectStrategy.java with 93% similarity]
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/TimedReconnectStrategyFactory.java [moved from protocol-framework/src/main/java/org/opendaylight/protocol/framework/TimedReconnectStrategyFactory.java with 96% similarity]
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/RemoteDeviceConnectorImpl.java
netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/AbstractNetconfTopology.java
netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/listener/NetconfDeviceCommunicatorTest.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/client/stress/StressClientCallable.java
pom.xml
protocol-framework/.gitignore [deleted file]
protocol-framework/pom.xml [deleted file]
protocol-framework/src/main/java/org/opendaylight/protocol/framework/AbstractProtocolSession.java [deleted file]
protocol-framework/src/main/java/org/opendaylight/protocol/framework/AbstractSessionNegotiator.java [deleted file]
protocol-framework/src/main/java/org/opendaylight/protocol/framework/ProtocolSession.java [deleted file]
protocol-framework/src/main/java/org/opendaylight/protocol/framework/SessionListener.java [deleted file]
protocol-framework/src/main/java/org/opendaylight/protocol/framework/TerminationReason.java [deleted file]
protocol-framework/src/test/java/org/opendaylight/protocol/framework/ServerTest.java [deleted file]
protocol-framework/src/test/java/org/opendaylight/protocol/framework/Session.java [deleted file]
protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleByteToMessageDecoder.java [deleted file]
protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleDispatcher.java [deleted file]
protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleMessage.java [deleted file]
protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleMessageToByteEncoder.java [deleted file]
protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleSession.java [deleted file]
protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleSessionListener.java [deleted file]
protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleSessionListenerFactory.java [deleted file]
protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleSessionNegotiator.java [deleted file]
protocol-framework/src/test/resources/logback-test.xml [deleted file]

index f08cf2bbe09c6244a4f7a22dbb67d4b2d2030cf6..500bdb2292cc59636c790aad651beeeb4baf1c5b 100644 (file)
             <type>xml</type>
             <classifier>features</classifier>
         </dependency>
-        <dependency>
-            <groupId>org.opendaylight.netconf</groupId>
-            <artifactId>odl-protocol-framework</artifactId>
-            <type>xml</type>
-            <classifier>features</classifier>
-        </dependency>
         <dependency>
             <groupId>org.opendaylight.mdsal.model</groupId>
             <artifactId>odl-mdsal-model-rfc7895</artifactId>
@@ -69,7 +63,6 @@
             <classifier>features</classifier>
         </dependency>
 
-
         <dependency>
             <groupId>org.opendaylight.netconf</groupId>
             <artifactId>netconf-api</artifactId>
index 1ca1efdc6cfce410c5c8bf5dddb408c29c41e7ac..c37a6f36dbcc9a224b1cef67b4783963ff0e67f6 100644 (file)
@@ -28,7 +28,6 @@
   <modules>
     <module>netconf</module>
     <module>netconf-connector</module>
-    <module>protocol-framework</module>
     <module>restconf</module>
     <module>yanglib</module>
   </modules>
diff --git a/features/protocol-framework/features-protocol-framework/pom.xml b/features/protocol-framework/features-protocol-framework/pom.xml
deleted file mode 100644 (file)
index f1bb507..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright Â© 2016, 2017 Red Hat, Inc. and others.
-
- 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.odlparent</groupId>
-        <artifactId>feature-repo-parent</artifactId>
-        <version>4.0.7</version>
-        <relativePath/>
-    </parent>
-
-    <groupId>org.opendaylight.netconf</groupId>
-    <artifactId>features-protocol-framework</artifactId>
-    <version>1.3.0-SNAPSHOT</version>
-    <packaging>feature</packaging>
-
-    <dependencies>
-        <dependency>
-            <groupId>org.opendaylight.netconf</groupId>
-            <artifactId>odl-protocol-framework</artifactId>
-            <version>1.3.0-SNAPSHOT</version>
-            <type>xml</type>
-            <classifier>features</classifier>
-        </dependency>
-    </dependencies>
-
-</project>
diff --git a/features/protocol-framework/odl-protocol-framework/pom.xml b/features/protocol-framework/odl-protocol-framework/pom.xml
deleted file mode 100644 (file)
index 9226824..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright Â© 2016, 2017 Red Hat, Inc. and others.
-
- 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.odlparent</groupId>
-        <artifactId>single-feature-parent</artifactId>
-        <version>4.0.7</version>
-        <relativePath/>
-    </parent>
-
-    <groupId>org.opendaylight.netconf</groupId>
-    <artifactId>odl-protocol-framework</artifactId>
-    <version>1.3.0-SNAPSHOT</version>
-    <packaging>feature</packaging>
-
-    <name>OpenDaylight :: Protocol Framework</name>
-
-    <dependencies>
-        <dependency>
-            <groupId>org.opendaylight.odlparent</groupId>
-            <artifactId>odl-netty-4</artifactId>
-            <type>xml</type>
-            <classifier>features</classifier>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.odlparent</groupId>
-            <artifactId>odl-guava</artifactId>
-            <type>xml</type>
-            <classifier>features</classifier>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.netconf</groupId>
-            <artifactId>protocol-framework</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-    </dependencies>
-
-</project>
diff --git a/features/protocol-framework/pom.xml b/features/protocol-framework/pom.xml
deleted file mode 100644 (file)
index 83c1c8e..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright Â© 2016, 2017 Red Hat, Inc. and others.
-
- 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.odlparent</groupId>
-        <artifactId>odlparent-lite</artifactId>
-        <version>4.0.7</version>
-        <relativePath/>
-    </parent>
-
-    <groupId>org.opendaylight.netconf</groupId>
-    <artifactId>features-protocol-framework-aggregator</artifactId>
-    <version>1.3.0-SNAPSHOT</version>
-    <packaging>pom</packaging>
-
-    <properties>
-        <maven.deploy.skip>true</maven.deploy.skip>
-        <maven.install.skip>true</maven.install.skip>
-    </properties>
-
-    <modules>
-        <module>features-protocol-framework</module>
-        <module>odl-protocol-framework</module>
-    </modules>
-
-    <scm>
-        <connection>scm:git:ssh://git.opendaylight.org:29418/netconf.git</connection>
-        <developerConnection>scm:git:ssh://git.opendaylight.org:29418/netconf.git</developerConnection>
-        <tag>HEAD</tag>
-        <url>https://git.opendaylight.org/gerrit/gitweb?p=netconf.git;a=summary</url>
-    </scm>
-</project>
index 09b88a944aeac94facb049bea235d0ed1c78ac87..9a5e10f506b139cbbafe0981dc8c31773c71a39b 100644 (file)
@@ -5,19 +5,18 @@
  * 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.callhome.protocol;
 
 import io.netty.channel.Channel;
 import io.netty.util.concurrent.Promise;
+import org.opendaylight.netconf.api.NetconfSessionListenerFactory;
 import org.opendaylight.netconf.client.NetconfClientSession;
 import org.opendaylight.netconf.client.NetconfClientSessionListener;
 import org.opendaylight.netconf.client.NetconfClientSessionNegotiatorFactory;
 import org.opendaylight.netconf.nettyutil.AbstractChannelInitializer;
-import org.opendaylight.protocol.framework.SessionListenerFactory;
 
 final class ReverseSshChannelInitializer extends AbstractChannelInitializer<NetconfClientSession>
-        implements SessionListenerFactory<NetconfClientSessionListener> {
+        implements NetconfSessionListenerFactory<NetconfClientSessionListener> {
 
     private final NetconfClientSessionNegotiatorFactory negotiatorFactory;
     private final NetconfClientSessionListener sessionListener;
index b9e5e3f7c56c71b65bd3e15052967fea55feae8c..ecac3cc607db4b666054d4396539ab4d65ff636c 100644 (file)
@@ -5,7 +5,6 @@
  * 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.callhome.mount;
 
 import static org.junit.Assert.assertFalse;
@@ -34,9 +33,9 @@ import org.opendaylight.netconf.client.NetconfClientSession;
 import org.opendaylight.netconf.client.NetconfClientSessionListener;
 import org.opendaylight.netconf.client.conf.NetconfClientConfiguration;
 import org.opendaylight.netconf.client.conf.NetconfClientConfigurationBuilder;
+import org.opendaylight.netconf.nettyutil.ReconnectStrategy;
 import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler;
 import org.opendaylight.netconf.topology.api.SchemaRepositoryProvider;
-import org.opendaylight.protocol.framework.ReconnectStrategy;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
 
index 51d2063d2ef9dc64e397d36d8f6dfb8486bebe29..5c54f5b93eb9dfa23fd1016fb16e89f29f572d3f 100644 (file)
 
   <dependencies>
     <dependency>
-      <groupId>${project.groupId}</groupId>
-      <artifactId>ietf-netconf-monitoring</artifactId>
+      <groupId>io.netty</groupId>
+      <artifactId>netty-transport</artifactId>
     </dependency>
+
     <dependency>
       <groupId>${project.groupId}</groupId>
-      <artifactId>ietf-netconf-monitoring-extension</artifactId>
+      <artifactId>ietf-netconf-monitoring</artifactId>
     </dependency>
     <dependency>
       <groupId>${project.groupId}</groupId>
-      <artifactId>protocol-framework</artifactId>
+      <artifactId>ietf-netconf-monitoring-extension</artifactId>
     </dependency>
     <dependency>
       <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
index bfa8bfeb667bba3880411ce38a8367fbbc19168e..182740b699c30e07658d03a39e2fbbe08da873d6 100644 (file)
@@ -8,10 +8,21 @@
 package org.opendaylight.netconf.api;
 
 import io.netty.channel.ChannelFuture;
-import org.opendaylight.protocol.framework.ProtocolSession;
+import java.io.Closeable;
 
-public interface NetconfSession extends ProtocolSession<NetconfMessage> {
+/**
+ * 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.
+ *
+ * <p>
+ * This interface should be implemented by a final class representing a protocol specific session.
+ */
+public interface NetconfSession extends Closeable {
 
     ChannelFuture sendMessage(NetconfMessage message);
 
+    @Override
+    void close();
 }
index bfd1dbf0af210457e7baf357dc279aa5ccd8346d..6f64fc5b73c4caf828db91922823a4caf558f972 100644 (file)
@@ -5,11 +5,38 @@
  * 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.api;
 
-import org.opendaylight.protocol.framework.SessionListener;
+// FIXME: NETCONF-554: rework this interface
+public interface NetconfSessionListener<S extends NetconfSession> {
+    /**
+     * 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 cause Exception that was thrown as the cause of session being down
+     */
+    void onSessionDown(S session, Exception cause);
+
+    /**
+     * 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, NetconfTerminationReason reason);
 
-public interface NetconfSessionListener
-        <S extends NetconfSession> extends SessionListener<NetconfMessage, S, NetconfTerminationReason> {
+    /**
+     * Fired when a normal protocol message is received.
+     *
+     * @param message Protocol message
+     */
+    void onMessage(S session, NetconfMessage message);
 }
similarity index 78%
rename from protocol-framework/src/main/java/org/opendaylight/protocol/framework/SessionListenerFactory.java
rename to netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/NetconfSessionListenerFactory.java
index 99087a5434538461f28887866c4fe2bf0c30a6f1..a0699680525c1f624ce7384cdc2276f75a2eea91 100644 (file)
@@ -5,8 +5,7 @@
  * 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;
-
+package org.opendaylight.netconf.api;
 
 /**
  * Factory for generating Session Listeners. Used by a server. This interface should be
@@ -14,9 +13,10 @@ package org.opendaylight.protocol.framework;
  * a final class that implements the methods.
  */
 @Deprecated
-public interface SessionListenerFactory<T extends SessionListener<?, ?, ?>> {
+public interface NetconfSessionListenerFactory<T extends NetconfSessionListener<?>> {
     /**
-     * Returns one session listener
+     * Returns one session listener.
+     *
      * @return specific session listener
      */
     T getSessionListener();
index 697acdf694d2b7c31ab24d90ce3d65144ab8dd27..62024fa1b1756f7bf3d1ef5d1dd84fa74da5b741 100644 (file)
@@ -5,12 +5,9 @@
  * 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.api;
 
-import org.opendaylight.protocol.framework.TerminationReason;
-
-public class NetconfTerminationReason implements TerminationReason {
+public class NetconfTerminationReason {
 
     private final String reason;
 
@@ -18,7 +15,10 @@ public class NetconfTerminationReason implements TerminationReason {
         this.reason = reason;
     }
 
-    @Override
+    /**
+     * Get cause of session termination.
+     * @return human-readable cause.
+     */
     public String getErrorMessage() {
         return reason;
     }
index 259d497355f1d4acfe2900238e0e55345b8f8c32..2e558438f505d6b9deb545a3697721afc5ebdb77 100644 (file)
                 <artifactId>netconf-topology-singleton</artifactId>
                 <version>${project.version}</version>
             </dependency>
-            <dependency>
-                <groupId>${project.groupId}</groupId>
-                <artifactId>protocol-framework</artifactId>
-                <version>1.3.0-SNAPSHOT</version>
-            </dependency>
 
             <!-- netconf features -->
-            <dependency>
-                <groupId>${project.groupId}</groupId>
-                <artifactId>features-protocol-framework</artifactId>
-                <version>1.3.0-SNAPSHOT</version>
-                <type>xml</type>
-                <classifier>features</classifier>
-            </dependency>
-            <dependency>
-                <groupId>${project.groupId}</groupId>
-                <artifactId>odl-protocol-framework</artifactId>
-                <version>1.3.0-SNAPSHOT</version>
-                <type>xml</type>
-                <classifier>features</classifier>
-            </dependency>
             <dependency>
                 <groupId>${project.groupId}</groupId>
                 <artifactId>features-netconf</artifactId>
index b8fdee2054e2aa53024a3df07d18bfa7a9a26f15..2f76f2b8b7ee4ae0815c1a633b536b8b2dcfe4ae 100644 (file)
@@ -5,7 +5,6 @@
  * 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.client;
 
 import io.netty.channel.EventLoopGroup;
@@ -16,12 +15,13 @@ import java.util.List;
 import java.util.Set;
 import org.opendaylight.netconf.client.conf.NetconfClientConfiguration;
 import org.opendaylight.netconf.client.conf.NetconfReconnectingClientConfiguration;
-import org.opendaylight.protocol.framework.AbstractDispatcher;
+import org.opendaylight.netconf.nettyutil.AbstractNetconfDispatcher;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class NetconfClientDispatcherImpl extends AbstractDispatcher<NetconfClientSession, NetconfClientSessionListener>
+public class NetconfClientDispatcherImpl
+        extends AbstractNetconfDispatcher<NetconfClientSession, NetconfClientSessionListener>
         implements NetconfClientDispatcher {
 
     private static final Logger LOG = LoggerFactory.getLogger(NetconfClientDispatcherImpl.class);
index d6cc5b18c75518eb152aa77a578987f337b2d199..2e8a90719fc8dd0abaad287513989e0516b2fa31 100644 (file)
@@ -20,19 +20,18 @@ import io.netty.util.concurrent.Promise;
 import java.util.Set;
 import org.opendaylight.netconf.api.NetconfClientSessionPreferences;
 import org.opendaylight.netconf.api.NetconfMessage;
+import org.opendaylight.netconf.api.NetconfSessionListenerFactory;
 import org.opendaylight.netconf.api.messages.NetconfHelloMessage;
 import org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.nettyutil.NetconfSessionNegotiatorFactory;
 import org.opendaylight.netconf.nettyutil.handler.exi.EXIParameters;
 import org.opendaylight.netconf.nettyutil.handler.exi.NetconfStartExiMessage;
-import org.opendaylight.protocol.framework.SessionListenerFactory;
-import org.opendaylight.protocol.framework.SessionNegotiator;
-import org.opendaylight.protocol.framework.SessionNegotiatorFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class NetconfClientSessionNegotiatorFactory implements SessionNegotiatorFactory<NetconfMessage,
-        NetconfClientSession, NetconfClientSessionListener> {
+public class NetconfClientSessionNegotiatorFactory
+        implements NetconfSessionNegotiatorFactory<NetconfClientSession, NetconfClientSessionListener> {
 
     public static final Set<String> EXI_CLIENT_CAPABILITIES = ImmutableSet.of(
             XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_BASE_1_0,
@@ -104,8 +103,8 @@ public class NetconfClientSessionNegotiatorFactory implements SessionNegotiatorF
     }
 
     @Override
-    public SessionNegotiator<NetconfClientSession> getSessionNegotiator(
-            final SessionListenerFactory<NetconfClientSessionListener> sessionListenerFactory,
+    public NetconfClientSessionNegotiator getSessionNegotiator(
+            final NetconfSessionListenerFactory<NetconfClientSessionListener> sessionListenerFactory,
             final Channel channel, final Promise<NetconfClientSession> promise) {
 
         NetconfMessage startExiMessage = NetconfStartExiMessage.create(options, START_EXI_MESSAGE_ID);
index b14d152e2561c1ad131c2567f76f8793fab4a4de..756789a8e0256ca36103416999bc05e0045dda06 100644 (file)
@@ -16,8 +16,8 @@ import java.util.List;
 import org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader;
 import org.opendaylight.netconf.client.NetconfClientSessionListener;
 import org.opendaylight.netconf.client.SslHandlerFactory;
+import org.opendaylight.netconf.nettyutil.ReconnectStrategy;
 import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler;
-import org.opendaylight.protocol.framework.ReconnectStrategy;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
index 9e86c9c4b27756642c12ac515cb9245729f69fd2..d79d5d5cc9b76d429c61fb7af09b08f14e192ac3 100644 (file)
@@ -12,8 +12,8 @@ import java.util.List;
 import org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader;
 import org.opendaylight.netconf.client.NetconfClientSessionListener;
 import org.opendaylight.netconf.client.SslHandlerFactory;
+import org.opendaylight.netconf.nettyutil.ReconnectStrategy;
 import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler;
-import org.opendaylight.protocol.framework.ReconnectStrategy;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
 
 public class NetconfClientConfigurationBuilder {
index c6885349232bdf054eff8950f7d732228246896e..c43cd2d2b96d1454f5bbbd237221865f21b5547d 100644 (file)
@@ -14,9 +14,9 @@ import java.util.List;
 import org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader;
 import org.opendaylight.netconf.client.NetconfClientSessionListener;
 import org.opendaylight.netconf.client.SslHandlerFactory;
+import org.opendaylight.netconf.nettyutil.ReconnectStrategy;
+import org.opendaylight.netconf.nettyutil.ReconnectStrategyFactory;
 import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler;
-import org.opendaylight.protocol.framework.ReconnectStrategy;
-import org.opendaylight.protocol.framework.ReconnectStrategyFactory;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
 
 public final class NetconfReconnectingClientConfiguration extends NetconfClientConfiguration {
index 670c893a00b174602c677126d64e97f107efb5ae..a23996c95568e91a674f3e4298f98672f8c6ae4a 100644 (file)
@@ -12,9 +12,9 @@ import java.util.List;
 import org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader;
 import org.opendaylight.netconf.client.NetconfClientSessionListener;
 import org.opendaylight.netconf.client.SslHandlerFactory;
+import org.opendaylight.netconf.nettyutil.ReconnectStrategy;
+import org.opendaylight.netconf.nettyutil.ReconnectStrategyFactory;
 import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler;
-import org.opendaylight.protocol.framework.ReconnectStrategy;
-import org.opendaylight.protocol.framework.ReconnectStrategyFactory;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
 
 public final class NetconfReconnectingClientConfigurationBuilder extends NetconfClientConfigurationBuilder {
index f7e63bb896e752e2cb87939f0f71e2feceb75ae6..2e2f7203cb9101e479da91db6cf7c6c99e3aa49d 100644 (file)
@@ -16,8 +16,8 @@ import org.mockito.Mockito;
 import org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader;
 import org.opendaylight.netconf.client.conf.NetconfClientConfiguration;
 import org.opendaylight.netconf.client.conf.NetconfClientConfigurationBuilder;
+import org.opendaylight.netconf.nettyutil.ReconnectStrategy;
 import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler;
-import org.opendaylight.protocol.framework.ReconnectStrategy;
 
 public class NetconfClientConfigurationTest {
     @Test
index 3a1e0d702468e73bc383368ed5e2bcee68a878c8..172871a5660385a9dcd062bd324bdf7d9690cb4b 100644 (file)
@@ -27,9 +27,9 @@ import org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader
 import org.opendaylight.netconf.client.conf.NetconfClientConfiguration;
 import org.opendaylight.netconf.client.conf.NetconfReconnectingClientConfiguration;
 import org.opendaylight.netconf.client.conf.NetconfReconnectingClientConfigurationBuilder;
+import org.opendaylight.netconf.nettyutil.ReconnectStrategy;
+import org.opendaylight.netconf.nettyutil.ReconnectStrategyFactory;
 import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler;
-import org.opendaylight.protocol.framework.ReconnectStrategy;
-import org.opendaylight.protocol.framework.ReconnectStrategyFactory;
 
 public class NetconfClientDispatcherImplTest {
     @Test
index ca9eb2cefe38558209839386acc7e8058adf073c..a033ea5c4bf8e8ed2d73106814e8895c241ba309 100644 (file)
@@ -18,15 +18,15 @@ import io.netty.util.HashedWheelTimer;
 import io.netty.util.Timer;
 import io.netty.util.concurrent.Promise;
 import org.junit.Test;
-import org.opendaylight.protocol.framework.SessionListenerFactory;
-import org.opendaylight.protocol.framework.SessionNegotiator;
+import org.opendaylight.netconf.api.NetconfSessionListenerFactory;
 
 public class NetconfClientSessionNegotiatorFactoryTest {
     @Test
     public void testGetSessionNegotiator() throws Exception {
         NetconfClientSessionListener sessionListener = mock(NetconfClientSessionListener.class);
         Timer timer = new HashedWheelTimer();
-        SessionListenerFactory<NetconfClientSessionListener> listenerFactory = mock(SessionListenerFactory.class);
+        NetconfSessionListenerFactory<NetconfClientSessionListener> listenerFactory =
+                mock(NetconfSessionListenerFactory.class);
         doReturn(sessionListener).when(listenerFactory).getSessionListener();
 
         Channel channel = mock(Channel.class);
@@ -34,8 +34,8 @@ public class NetconfClientSessionNegotiatorFactoryTest {
         NetconfClientSessionNegotiatorFactory negotiatorFactory = new NetconfClientSessionNegotiatorFactory(timer,
                 Optional.absent(), 200L);
 
-        SessionNegotiator<?> sessionNegotiator = negotiatorFactory.getSessionNegotiator(listenerFactory, channel,
-                promise);
+        NetconfClientSessionNegotiator sessionNegotiator = negotiatorFactory.getSessionNegotiator(listenerFactory,
+            channel, promise);
         assertNotNull(sessionNegotiator);
     }
 }
index 406c19a8c3539fc6da385d77c87798d9c9d593dd..be654a340ce3c98fc84d81c84b2c67423b5b9529 100644 (file)
@@ -17,9 +17,9 @@ import org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader
 import org.opendaylight.netconf.client.conf.NetconfClientConfiguration;
 import org.opendaylight.netconf.client.conf.NetconfReconnectingClientConfiguration;
 import org.opendaylight.netconf.client.conf.NetconfReconnectingClientConfigurationBuilder;
+import org.opendaylight.netconf.nettyutil.ReconnectStrategy;
+import org.opendaylight.netconf.nettyutil.ReconnectStrategyFactory;
 import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler;
-import org.opendaylight.protocol.framework.ReconnectStrategy;
-import org.opendaylight.protocol.framework.ReconnectStrategyFactory;
 
 public class NetconfReconnectingClientConfigurationTest {
     @Test
index 80e6d0450e209c33235ba2fee6a37882ceb2e56d..a13abada420ee9926735c9b6ce813ea8e925e31b 100644 (file)
@@ -5,7 +5,6 @@
  * 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.client;
 
 import static org.mockito.ArgumentMatchers.any;
@@ -20,9 +19,8 @@ import io.netty.channel.ChannelHandler;
 import io.netty.channel.ChannelPipeline;
 import io.netty.util.concurrent.Promise;
 import org.junit.Test;
+import org.opendaylight.netconf.api.NetconfSessionListenerFactory;
 import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler;
-import org.opendaylight.protocol.framework.SessionListenerFactory;
-import org.opendaylight.protocol.framework.SessionNegotiator;
 
 public class SshClientChannelInitializerTest {
     @Test
@@ -32,10 +30,10 @@ public class SshClientChannelInitializerTest {
         NetconfClientSessionNegotiatorFactory negotiatorFactory = mock(NetconfClientSessionNegotiatorFactory.class);
         NetconfClientSessionListener sessionListener = mock(NetconfClientSessionListener.class);
 
-        SessionNegotiator<?> sessionNegotiator = mock(SessionNegotiator.class);
+        NetconfClientSessionNegotiator sessionNegotiator = mock(NetconfClientSessionNegotiator.class);
         doReturn("").when(sessionNegotiator).toString();
-        doReturn(sessionNegotiator).when(negotiatorFactory).getSessionNegotiator(any(SessionListenerFactory.class),
-                any(Channel.class), any(Promise.class));
+        doReturn(sessionNegotiator).when(negotiatorFactory).getSessionNegotiator(
+            any(NetconfSessionListenerFactory.class), any(Channel.class), any(Promise.class));
         ChannelPipeline pipeline = mock(ChannelPipeline.class);
         doReturn(pipeline).when(pipeline).addAfter(anyString(), anyString(), any(ChannelHandler.class));
         Channel channel = mock(Channel.class);
index 7ff2f174739261f415749dd9105e30e5d9e5cb4c..000cfbef3d039a643125ca032f93178c027576b2 100644 (file)
@@ -5,11 +5,10 @@
  * 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.client;
 
-import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.anyString;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
@@ -20,16 +19,15 @@ import io.netty.channel.ChannelHandler;
 import io.netty.channel.ChannelPipeline;
 import io.netty.util.concurrent.Promise;
 import org.junit.Test;
-import org.opendaylight.protocol.framework.SessionListenerFactory;
-import org.opendaylight.protocol.framework.SessionNegotiator;
+import org.opendaylight.netconf.api.NetconfSessionListenerFactory;
 
 public class TcpClientChannelInitializerTest {
     @Test
     public void testInitializeSessionNegotiator() throws Exception {
         NetconfClientSessionNegotiatorFactory factory = mock(NetconfClientSessionNegotiatorFactory.class);
-        SessionNegotiator<?> sessionNegotiator = mock(SessionNegotiator.class);
+        NetconfClientSessionNegotiator sessionNegotiator = mock(NetconfClientSessionNegotiator.class);
         doReturn("").when(sessionNegotiator).toString();
-        doReturn(sessionNegotiator).when(factory).getSessionNegotiator(any(SessionListenerFactory.class),
+        doReturn(sessionNegotiator).when(factory).getSessionNegotiator(any(NetconfSessionListenerFactory.class),
                 any(Channel.class), any(Promise.class));
         NetconfClientSessionListener listener = mock(NetconfClientSessionListener.class);
         final TcpClientChannelInitializer initializer = new TcpClientChannelInitializer(factory, listener);
index 094b570700880263300ed45e69cf5f191713ebd9..4a3a38edf8882f4732189e42a468a68530529df3 100644 (file)
@@ -29,9 +29,9 @@ import org.opendaylight.netconf.api.NetconfMessage;
 import org.opendaylight.netconf.client.conf.NetconfClientConfiguration;
 import org.opendaylight.netconf.client.conf.NetconfClientConfiguration.NetconfClientProtocol;
 import org.opendaylight.netconf.client.conf.NetconfClientConfigurationBuilder;
+import org.opendaylight.netconf.nettyutil.NeverReconnectStrategy;
 import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler;
 import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.LoginPasswordHandler;
-import org.opendaylight.protocol.framework.NeverReconnectStrategy;
 
 
 /**
index da238bf90ddbf3d10cf875ccaa29e56ff0154226..e6a518e4cbcf29977ab69aab052ae9b2477924a0 100644 (file)
@@ -18,13 +18,13 @@ import io.netty.channel.Channel;
 import io.netty.channel.ChannelHandler;
 import io.netty.channel.ChannelPipeline;
 import io.netty.util.concurrent.Promise;
-import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.opendaylight.protocol.framework.SessionListenerFactory;
-import org.opendaylight.protocol.framework.SessionNegotiator;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.opendaylight.netconf.api.NetconfSessionListenerFactory;
 
+@RunWith(MockitoJUnitRunner.class)
 public class TlsClientChannelInitializerTest {
     @Mock
     private SslHandlerFactory sslHandlerFactory;
@@ -33,17 +33,12 @@ public class TlsClientChannelInitializerTest {
     @Mock
     private NetconfClientSessionListener sessionListener;
 
-    @Before
-    public void setUp() {
-        MockitoAnnotations.initMocks(this);
-    }
-
     @SuppressWarnings("unchecked")
     @Test
     public void testInitialize() throws Exception {
-        SessionNegotiator<?> sessionNegotiator = mock(SessionNegotiator.class);
-        doReturn(sessionNegotiator).when(negotiatorFactory).getSessionNegotiator(any(SessionListenerFactory.class),
-                any(Channel.class), any(Promise.class));
+        NetconfClientSessionNegotiator sessionNegotiator = mock(NetconfClientSessionNegotiator.class);
+        doReturn(sessionNegotiator).when(negotiatorFactory).getSessionNegotiator(
+            any(NetconfSessionListenerFactory.class), any(Channel.class), any(Promise.class));
         ChannelPipeline pipeline = mock(ChannelPipeline.class);
         doReturn(pipeline).when(pipeline).addAfter(anyString(), anyString(), any(ChannelHandler.class));
         Channel channel = mock(Channel.class);
index 394771b122691f54f1d93648074bc3cf57820709..67fd0208f8f6c87e72d3bfc3fac1dc47973d826d 100644 (file)
@@ -5,7 +5,6 @@
  * 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.impl;
 
 import io.netty.channel.Channel;
@@ -18,9 +17,9 @@ import java.net.InetSocketAddress;
 import org.opendaylight.netconf.api.NetconfServerDispatcher;
 import org.opendaylight.netconf.impl.util.DeserializerExceptionHandler;
 import org.opendaylight.netconf.nettyutil.AbstractChannelInitializer;
-import org.opendaylight.protocol.framework.AbstractDispatcher;
+import org.opendaylight.netconf.nettyutil.AbstractNetconfDispatcher;
 
-public class NetconfServerDispatcherImpl extends AbstractDispatcher<NetconfServerSession,
+public class NetconfServerDispatcherImpl extends AbstractNetconfDispatcher<NetconfServerSession,
         NetconfServerSessionListener> implements NetconfServerDispatcher {
 
     private final ServerChannelInitializer initializer;
index dbe9c0b7eec61114cb47e8319979f8bd34361926..619f97a6d4c3c5dd3942a03c4eb96a5199c3381f 100644 (file)
@@ -5,7 +5,6 @@
  * 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.impl;
 
 import com.google.common.base.Preconditions;
@@ -18,6 +17,7 @@ import io.netty.util.concurrent.Promise;
 import java.net.SocketAddress;
 import java.util.Set;
 import org.opendaylight.netconf.api.NetconfServerSessionPreferences;
+import org.opendaylight.netconf.api.NetconfSessionListenerFactory;
 import org.opendaylight.netconf.api.messages.NetconfHelloMessage;
 import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
@@ -25,14 +25,12 @@ import org.opendaylight.netconf.impl.osgi.NetconfOperationRouter;
 import org.opendaylight.netconf.impl.osgi.NetconfOperationRouterImpl;
 import org.opendaylight.netconf.mapping.api.NetconfOperationService;
 import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory;
-import org.opendaylight.protocol.framework.SessionListenerFactory;
-import org.opendaylight.protocol.framework.SessionNegotiator;
-import org.opendaylight.protocol.framework.SessionNegotiatorFactory;
+import org.opendaylight.netconf.nettyutil.NetconfSessionNegotiatorFactory;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.Capabilities;
 
-public class NetconfServerSessionNegotiatorFactory implements SessionNegotiatorFactory<NetconfHelloMessage,
-        NetconfServerSession, NetconfServerSessionListener> {
+public class NetconfServerSessionNegotiatorFactory
+    implements NetconfSessionNegotiatorFactory<NetconfServerSession, NetconfServerSessionListener> {
 
     public static final Set<String> DEFAULT_BASE_CAPABILITIES = ImmutableSet.of(
             XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_BASE_1_0,
@@ -95,8 +93,8 @@ public class NetconfServerSessionNegotiatorFactory implements SessionNegotiatorF
      * @return session negotiator
      */
     @Override
-    public SessionNegotiator<NetconfServerSession> getSessionNegotiator(
-            final SessionListenerFactory<NetconfServerSessionListener> defunctSessionListenerFactory,
+    public NetconfServerSessionNegotiator getSessionNegotiator(
+            final NetconfSessionListenerFactory<NetconfServerSessionListener> defunctSessionListenerFactory,
             final Channel channel, final Promise<NetconfServerSession> promise) {
         final long sessionId = idProvider.getNextSessionId();
 
index a9fcf4731f44afb551a914e068fc1e82a8bda772..bd9eb070d122b1734920dbfbdafda1a372243678 100644 (file)
@@ -69,10 +69,10 @@ import org.opendaylight.netconf.mapping.api.NetconfOperation;
 import org.opendaylight.netconf.mapping.api.NetconfOperationChainedExecution;
 import org.opendaylight.netconf.mapping.api.NetconfOperationService;
 import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory;
+import org.opendaylight.netconf.nettyutil.NeverReconnectStrategy;
 import org.opendaylight.netconf.nettyutil.handler.exi.NetconfStartExiMessage;
 import org.opendaylight.netconf.util.messages.NetconfMessageUtil;
 import org.opendaylight.netconf.util.test.XmlFileLoader;
-import org.opendaylight.protocol.framework.NeverReconnectStrategy;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.CapabilitiesBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
similarity index 73%
rename from protocol-framework/src/main/java/org/opendaylight/protocol/framework/AbstractDispatcher.java
rename to netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractNetconfDispatcher.java
index 80e30dc90c61e914dcc32a089197eff16f2886ee..7997095850c9a2890420e46bb972fa00440bde23 100644 (file)
@@ -5,7 +5,7 @@
  * 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;
+package org.opendaylight.netconf.nettyutil;
 
 import com.google.common.base.Preconditions;
 import io.netty.bootstrap.Bootstrap;
@@ -29,6 +29,8 @@ import io.netty.util.concurrent.Promise;
 import java.io.Closeable;
 import java.net.InetSocketAddress;
 import java.net.SocketAddress;
+import org.opendaylight.netconf.api.NetconfSession;
+import org.opendaylight.netconf.api.NetconfSessionListener;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -37,26 +39,27 @@ import org.slf4j.LoggerFactory;
  * start method that will handle sockets in different thread.
  */
 @Deprecated
-public abstract class AbstractDispatcher<S extends ProtocolSession<?>, L extends SessionListener<?, ?, ?>> implements Closeable {
+public abstract class AbstractNetconfDispatcher<S extends NetconfSession, L extends NetconfSessionListener<? super S>>
+        implements Closeable {
 
-
-    protected interface ChannelPipelineInitializer<CH extends Channel, S extends ProtocolSession<?>> {
+    protected interface ChannelPipelineInitializer<C extends Channel, S extends NetconfSession> {
         /**
-         * Initializes channel by specifying the handlers in its pipeline. Handlers are protocol specific, therefore this
-         * method needs to be implemented in protocol specific Dispatchers.
+         * 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}
+         * @param channel whose pipeline should be defined, also to be passed to {@link NetconfSessionNegotiatorFactory}
+         * @param promise to be passed to {@link NetconfSessionNegotiatorFactory}
          */
-        void initializeChannel(CH channel, Promise<S> promise);
+        void initializeChannel(C channel, Promise<S> promise);
     }
 
-    protected interface PipelineInitializer<S extends ProtocolSession<?>> extends ChannelPipelineInitializer<SocketChannel, S> {
+    protected interface PipelineInitializer<S extends NetconfSession>
+        extends ChannelPipelineInitializer<SocketChannel, S> {
 
     }
 
 
-    private static final Logger LOG = LoggerFactory.getLogger(AbstractDispatcher.class);
+    private static final Logger LOG = LoggerFactory.getLogger(AbstractNetconfDispatcher.class);
 
     private final EventLoopGroup bossGroup;
 
@@ -64,11 +67,12 @@ public abstract class AbstractDispatcher<S extends ProtocolSession<?>, L extends
 
     private final EventExecutor executor;
 
-    protected AbstractDispatcher(final EventLoopGroup bossGroup, final EventLoopGroup workerGroup) {
+    protected AbstractNetconfDispatcher(final EventLoopGroup bossGroup, final EventLoopGroup workerGroup) {
         this(GlobalEventExecutor.INSTANCE, bossGroup, workerGroup);
     }
 
-    protected AbstractDispatcher(final EventExecutor executor, final EventLoopGroup bossGroup, final EventLoopGroup workerGroup) {
+    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);
@@ -96,13 +100,13 @@ public abstract class AbstractDispatcher<S extends ProtocolSession<?>, L extends
      *
      * @return ChannelFuture representing the binding process
      */
-    protected <CH extends Channel> ChannelFuture createServer(final SocketAddress address, final Class<? extends ServerChannel> channelClass,
-            final ChannelPipelineInitializer<CH, S> initializer) {
+    protected <C extends Channel> ChannelFuture createServer(final SocketAddress address,
+            final Class<? extends ServerChannel> channelClass, final ChannelPipelineInitializer<C, S> initializer) {
         final ServerBootstrap b = new ServerBootstrap();
-        b.childHandler(new ChannelInitializer<CH>() {
+        b.childHandler(new ChannelInitializer<C>() {
 
             @Override
-            protected void initChannel(final CH ch) {
+            protected void initChannel(final C ch) {
                 initializer.initializeChannel(ch, new DefaultPromise<>(executor));
             }
         });
@@ -137,9 +141,20 @@ public abstract class AbstractDispatcher<S extends ProtocolSession<?>, L extends
      * subclasses to assign non-default server options before the server is
      * created.
      *
-     * @param b Server bootstrap
+     * @param bootstrap Server bootstrap
+     */
+    protected void customizeBootstrap(final ServerBootstrap bootstrap) {
+        // The default is a no-op
+    }
+
+    /**
+     * Customize a client bootstrap before the connection is attempted. This
+     * allows subclasses to assign non-default options before the client is
+     * created.
+     *
+     * @param bootstrap Client bootstrap
      */
-    protected void customizeBootstrap(final ServerBootstrap b) {
+    protected void customizeBootstrap(final Bootstrap bootstrap) {
         // The default is a no-op
     }
 
@@ -152,9 +167,10 @@ public abstract class AbstractDispatcher<S extends ProtocolSession<?>, L extends
      * @return Future representing the connection process. Its result represents the combined success of TCP connection
      *         as well as session negotiation.
      */
-    protected Future<S> createClient(final InetSocketAddress address, final ReconnectStrategy strategy, final PipelineInitializer<S> initializer) {
+    protected Future<S> createClient(final InetSocketAddress address, final ReconnectStrategy strategy,
+            final PipelineInitializer<S> initializer) {
         final Bootstrap b = new Bootstrap();
-        final ProtocolSessionPromise<S> p = new ProtocolSessionPromise<>(executor, address, strategy, b);
+        final NetconfSessionPromise<S> p = new NetconfSessionPromise<>(executor, address, strategy, b);
         b.option(ChannelOption.SO_KEEPALIVE, true).handler(
                 new ChannelInitializer<SocketChannel>() {
                     @Override
@@ -172,20 +188,15 @@ public abstract class AbstractDispatcher<S extends ProtocolSession<?>, L extends
         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<S> createClient(final InetSocketAddress address, final ReconnectStrategy strategy, final Bootstrap bootstrap, final PipelineInitializer<S> initializer) {
-        final ProtocolSessionPromise<S> p = new ProtocolSessionPromise<>(executor, address, strategy, bootstrap);
+    protected Future<S> createClient(final InetSocketAddress address, final ReconnectStrategy strategy,
+            final Bootstrap bootstrap, final PipelineInitializer<S> initializer) {
+        final NetconfSessionPromise<S> p = new NetconfSessionPromise<>(executor, address, strategy, bootstrap);
 
         bootstrap.handler(
                 new ChannelInitializer<SocketChannel>() {
@@ -201,32 +212,21 @@ public abstract class AbstractDispatcher<S extends ProtocolSession<?>, L extends
     }
 
     /**
-     * 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 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) {
+    protected Future<Void> createReconnectingClient(final InetSocketAddress address,
+            final ReconnectStrategyFactory connectStrategyFactory, final ReconnectStrategy reestablishStrategy,
+            final PipelineInitializer<S> initializer) {
         return createReconnectingClient(address, connectStrategyFactory, initializer);
     }
 
@@ -235,15 +235,15 @@ public abstract class AbstractDispatcher<S extends ProtocolSession<?>, L extends
      *
      * @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<Void> createReconnectingClient(final InetSocketAddress address, final ReconnectStrategyFactory connectStrategyFactory,
-            final PipelineInitializer<S> initializer) {
+    protected Future<Void> createReconnectingClient(final InetSocketAddress address,
+            final ReconnectStrategyFactory connectStrategyFactory, final PipelineInitializer<S> initializer) {
         final Bootstrap b = new Bootstrap();
 
-        final ReconnectPromise<S, L> p = new ReconnectPromise<>(GlobalEventExecutor.INSTANCE, this, address, connectStrategyFactory, b, initializer);
+        final ReconnectPromise<S, L> p = new ReconnectPromise<>(GlobalEventExecutor.INSTANCE, this, address,
+                connectStrategyFactory, b, initializer);
 
         b.option(ChannelOption.SO_KEEPALIVE, true);
 
@@ -255,19 +255,22 @@ public abstract class AbstractDispatcher<S extends ProtocolSession<?>, L extends
         return p;
     }
 
-    private void setChannelFactory(final Bootstrap b) {
+    private static void setChannelFactory(final Bootstrap bootstrap) {
         // There is no way to detect if this was already set by
         // customizeBootstrap()
         try {
-            b.channel(NioSocketChannel.class);
+            bootstrap.channel(NioSocketChannel.class);
         } catch (final IllegalStateException e) {
-            LOG.trace("Not overriding channelFactory on bootstrap {}", b, e);
+            LOG.trace("Not overriding channelFactory on bootstrap {}", bootstrap, e);
+        }
+    }
+
+    private void setWorkerGroup(final Bootstrap bootstrap) {
+        if (bootstrap.group() == null) {
+            bootstrap.group(workerGroup);
         }
     }
 
-    /**
-     * @deprecated Should only be used with AbstractDispatcher#AbstractDispatcher()
-     */
     @Deprecated
     @Override
     public void close() {
index e74a9a10386c2c72be55737cff66d6c7f41647e6..f187122fdb1564da096ba3aafe1c1299d1d37594 100644 (file)
@@ -12,7 +12,9 @@ import com.siemens.ct.exi.core.exceptions.UnsupportedOption;
 import io.netty.channel.Channel;
 import io.netty.channel.ChannelFuture;
 import io.netty.channel.ChannelHandler;
+import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.ChannelPromise;
+import io.netty.channel.SimpleChannelInboundHandler;
 import io.netty.handler.codec.ByteToMessageDecoder;
 import io.netty.handler.codec.MessageToByteEncoder;
 import java.io.IOException;
@@ -26,12 +28,12 @@ import org.opendaylight.netconf.nettyutil.handler.NetconfEXICodec;
 import org.opendaylight.netconf.nettyutil.handler.NetconfEXIToMessageDecoder;
 import org.opendaylight.netconf.nettyutil.handler.NetconfMessageToEXIEncoder;
 import org.opendaylight.netconf.nettyutil.handler.exi.EXIParameters;
-import org.opendaylight.protocol.framework.AbstractProtocolSession;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public abstract class AbstractNetconfSession<S extends NetconfSession,L extends NetconfSessionListener<S>>
-        extends AbstractProtocolSession<NetconfMessage> implements NetconfSession, NetconfExiSession {
+        extends SimpleChannelInboundHandler<Object> implements NetconfSession, NetconfExiSession {
+
     private static final Logger LOG = LoggerFactory.getLogger(AbstractNetconfSession.class);
     private final L sessionListener;
     private final long sessionId;
@@ -57,7 +59,6 @@ public abstract class AbstractNetconfSession<S extends NetconfSession,L extends
         sessionListener.onSessionTerminated(thisInstance(), new NetconfTerminationReason("Session closed"));
     }
 
-    @Override
     protected void handleMessage(final NetconfMessage netconfMessage) {
         LOG.debug("handling incoming message");
         sessionListener.onMessage(thisInstance(), netconfMessage);
@@ -86,7 +87,6 @@ public abstract class AbstractNetconfSession<S extends NetconfSession,L extends
         return promise;
     }
 
-    @Override
     protected void endOfInput() {
         LOG.debug("Session {} end of input detected while session was in state {}", toString(), isUp() ? "up"
                 : "initialized");
@@ -96,7 +96,6 @@ public abstract class AbstractNetconfSession<S extends NetconfSession,L extends
         }
     }
 
-    @Override
     protected void sessionUp() {
         LOG.debug("Session {} up", toString());
         sessionListener.onSessionUp(thisInstance());
@@ -167,4 +166,29 @@ public abstract class AbstractNetconfSession<S extends NetconfSession,L extends
     public final long getSessionId() {
         return sessionId;
     }
+
+    @Override
+    @SuppressWarnings("checkstyle:illegalCatch")
+    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
+    protected final void channelRead0(final ChannelHandlerContext ctx, final Object msg) {
+        LOG.debug("Message was received: {}", msg);
+        handleMessage((NetconfMessage) msg);
+    }
+
+    @Override
+    public final void handlerAdded(final ChannelHandlerContext ctx) {
+        sessionUp();
+    }
 }
index d9c15ae03578052a079bc157d44d2e7e9dcb6e1e..9b457109bd5d47f3ff17a3a1dd01d73fb142fdff 100644 (file)
@@ -5,11 +5,12 @@
  * 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.nettyutil;
 
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
 import io.netty.channel.Channel;
 import io.netty.channel.ChannelFuture;
 import io.netty.channel.ChannelHandler;
@@ -34,7 +35,6 @@ import org.opendaylight.netconf.nettyutil.handler.NetconfMessageToXMLEncoder;
 import org.opendaylight.netconf.nettyutil.handler.NetconfXMLToHelloMessageDecoder;
 import org.opendaylight.netconf.nettyutil.handler.NetconfXMLToMessageDecoder;
 import org.opendaylight.netconf.util.messages.FramingMechanism;
-import org.opendaylight.protocol.framework.AbstractSessionNegotiator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
@@ -42,14 +42,16 @@ import org.w3c.dom.NodeList;
 
 public abstract class AbstractNetconfSessionNegotiator<P extends NetconfSessionPreferences,
         S extends AbstractNetconfSession<S, L>, L extends NetconfSessionListener<S>>
-    extends AbstractSessionNegotiator<NetconfHelloMessage, S> {
+            extends ChannelInboundHandlerAdapter implements NetconfSessionNegotiator<S> {
 
     private static final Logger LOG = LoggerFactory.getLogger(AbstractNetconfSessionNegotiator.class);
 
     public static final String NAME_OF_EXCEPTION_HANDLER = "lastExceptionHandler";
 
     protected final P sessionPreferences;
+    protected final Channel channel;
 
+    private final Promise<S> promise;
     private final L sessionListener;
     private Timeout timeout;
 
@@ -61,22 +63,20 @@ public abstract class AbstractNetconfSessionNegotiator<P extends NetconfSessionP
     }
 
     private State state = State.IDLE;
-    private final Promise<S> promise;
     private final Timer timer;
     private final long connectionTimeoutMillis;
 
     protected AbstractNetconfSessionNegotiator(final P sessionPreferences, final Promise<S> promise,
                                                final Channel channel, final Timer timer,
                                                final L sessionListener, final long connectionTimeoutMillis) {
-        super(promise, channel);
+        this.channel = requireNonNull(channel);
+        this.promise = requireNonNull(promise);
         this.sessionPreferences = sessionPreferences;
-        this.promise = promise;
         this.timer = timer;
         this.sessionListener = sessionListener;
         this.connectionTimeoutMillis = connectionTimeoutMillis;
     }
 
-    @Override
     protected final void startNegotiation() {
         if (ifNegotiatedAlready()) {
             LOG.debug("Negotiation on channel {} already started", channel);
@@ -84,7 +84,7 @@ public abstract class AbstractNetconfSessionNegotiator<P extends NetconfSessionP
             final Optional<SslHandler> sslHandler = getSslHandler(channel);
             if (sslHandler.isPresent()) {
                 sslHandler.get().handshakeFuture().addListener(future -> {
-                    Preconditions.checkState(future.isSuccess(), "Ssl handshake was not successful");
+                    checkState(future.isSuccess(), "Ssl handshake was not successful");
                     LOG.debug("Ssl handshake complete");
                     start();
                 });
@@ -163,8 +163,6 @@ public abstract class AbstractNetconfSessionNegotiator<P extends NetconfSessionP
 
     protected final S getSessionForHelloMessage(final NetconfHelloMessage netconfMessage)
             throws NetconfDocumentedException {
-        Preconditions.checkNotNull(netconfMessage, "netconfMessage");
-
         final Document doc = netconfMessage.getDocument();
 
         if (shouldUseChunkFraming(doc)) {
@@ -201,7 +199,7 @@ public abstract class AbstractNetconfSessionNegotiator<P extends NetconfSessionP
         ChannelHandler helloMessageHandler = replaceChannelHandler(channel,
                 AbstractChannelInitializer.NETCONF_MESSAGE_DECODER, new NetconfXMLToMessageDecoder());
 
-        Preconditions.checkState(helloMessageHandler instanceof NetconfXMLToHelloMessageDecoder,
+        checkState(helloMessageHandler instanceof NetconfXMLToHelloMessageDecoder,
                 "Pipeline handlers misplaced on session: %s, pipeline: %s", session, channel.pipeline());
         Iterable<NetconfMessage> netconfMessagesFromNegotiation =
                 ((NetconfXMLToHelloMessageDecoder) helloMessageHandler).getPostHelloNetconfMessages();
@@ -234,7 +232,7 @@ public abstract class AbstractNetconfSessionNegotiator<P extends NetconfSessionP
 
     private synchronized void changeState(final State newState) {
         LOG.debug("Changing state from : {} to : {} for channel: {}", state, newState, channel);
-        Preconditions.checkState(isStateChangePermitted(state, newState),
+        checkState(isStateChangePermitted(state, newState),
                 "Cannot change state from %s to %s for chanel %s", state, newState, channel);
         this.state = newState;
     }
@@ -277,4 +275,65 @@ public abstract class AbstractNetconfSessionNegotiator<P extends NetconfSessionP
             changeState(State.FAILED);
         }
     }
+
+    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 NetconfMessage msg) {
+        this.channel.writeAndFlush(msg).addListener(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
+    @SuppressWarnings("checkstyle:illegalCatch")
+    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("checkstyle:illegalCatch")
+    public final void channelRead(final ChannelHandlerContext ctx, final Object msg) {
+        LOG.debug("Negotiation read invoked on channel {}", channel);
+        try {
+            handleMessage((NetconfHelloMessage) 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);
+    }
+
+    protected abstract void handleMessage(NetconfHelloMessage msg) throws Exception;
 }
similarity index 77%
rename from protocol-framework/src/main/java/org/opendaylight/protocol/framework/SessionNegotiator.java
rename to netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/NetconfSessionNegotiator.java
index c2abf50716648b87405c338cf809dfb8a31c55fb..38978ced3d5cd65af5bfb143961931aea9908c12 100644 (file)
@@ -5,9 +5,10 @@
  * 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;
+package org.opendaylight.netconf.nettyutil;
 
 import io.netty.channel.ChannelInboundHandler;
+import org.opendaylight.netconf.api.NetconfSession;
 
 /**
  * Session negotiator concepts. A negotiator is responsible for message
@@ -18,6 +19,6 @@ import io.netty.channel.ChannelInboundHandler;
  * @param <T> Protocol session type.
  */
 @Deprecated
-public interface SessionNegotiator<T extends ProtocolSession<?>> extends ChannelInboundHandler {
+public interface NetconfSessionNegotiator<T extends NetconfSession> extends ChannelInboundHandler {
 
 }
similarity index 60%
rename from protocol-framework/src/main/java/org/opendaylight/protocol/framework/SessionNegotiatorFactory.java
rename to netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/NetconfSessionNegotiatorFactory.java
index 66293f368fa66f2a46cfdcd03b806c7ab9df7328..93997e536b39ba8e14d1e4493bc30dc738d6e6a2 100644 (file)
@@ -5,10 +5,13 @@
  * 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;
+package org.opendaylight.netconf.nettyutil;
 
 import io.netty.channel.Channel;
 import io.netty.util.concurrent.Promise;
+import org.opendaylight.netconf.api.NetconfSession;
+import org.opendaylight.netconf.api.NetconfSessionListener;
+import org.opendaylight.netconf.api.NetconfSessionListenerFactory;
 
 /**
  * A factory class creating SessionNegotiators.
@@ -16,7 +19,8 @@ import io.netty.util.concurrent.Promise;
  * @param <S> session type
  */
 @Deprecated
-public interface SessionNegotiatorFactory<M, S extends ProtocolSession<?>, L extends SessionListener<?, ?, ?>> {
+public interface NetconfSessionNegotiatorFactory<S extends NetconfSession,
+        L extends NetconfSessionListener<? super S>> {
     /**
      * Create a new negotiator attached to a channel, which will notify
      * a promise once the negotiation completes.
@@ -25,5 +29,6 @@ public interface SessionNegotiatorFactory<M, S extends ProtocolSession<?>, L ext
      * @param promise Promise to be notified
      * @return new negotiator instance
      */
-    SessionNegotiator<S> getSessionNegotiator(SessionListenerFactory<L> factory, Channel channel, Promise<S> promise);
+    NetconfSessionNegotiator<S> getSessionNegotiator(NetconfSessionListenerFactory<L> factory, Channel channel,
+            Promise<S> promise);
 }
similarity index 74%
rename from protocol-framework/src/main/java/org/opendaylight/protocol/framework/ProtocolSessionPromise.java
rename to netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/NetconfSessionPromise.java
index 2ee8419f8f223f2de26baf1d806f78fee87557cd..fec85ae871714e275dbc201f20eafd23a7dfb681 100644 (file)
@@ -5,7 +5,7 @@
  * 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;
+package org.opendaylight.netconf.nettyutil;
 
 import com.google.common.base.Preconditions;
 import io.netty.bootstrap.Bootstrap;
@@ -20,43 +20,43 @@ import io.netty.util.concurrent.Promise;
 import java.net.InetSocketAddress;
 import javax.annotation.concurrent.GuardedBy;
 import javax.annotation.concurrent.ThreadSafe;
+import org.opendaylight.netconf.api.NetconfSession;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 @Deprecated
 @ThreadSafe
-final class ProtocolSessionPromise<S extends ProtocolSession<?>> extends DefaultPromise<S> {
-    private static final Logger LOG = LoggerFactory.getLogger(ProtocolSessionPromise.class);
+final class NetconfSessionPromise<S extends NetconfSession> extends DefaultPromise<S> {
+    private static final Logger LOG = LoggerFactory.getLogger(NetconfSessionPromise.class);
     private final ReconnectStrategy strategy;
     private InetSocketAddress address;
-    private final Bootstrap b;
+    private final Bootstrap bootstrap;
 
     @GuardedBy("this")
     private Future<?> pending;
 
-    ProtocolSessionPromise(final EventExecutor executor, final InetSocketAddress address, final ReconnectStrategy strategy,
-            final Bootstrap b) {
+    NetconfSessionPromise(final EventExecutor executor, final InetSocketAddress address,
+            final ReconnectStrategy strategy, final Bootstrap bootstrap) {
         super(executor);
         this.strategy = Preconditions.checkNotNull(strategy);
         this.address = Preconditions.checkNotNull(address);
-        this.b = Preconditions.checkNotNull(b);
+        this.bootstrap = Preconditions.checkNotNull(bootstrap);
     }
 
+    @SuppressWarnings("checkstyle:illegalCatch")
     synchronized void connect() {
-        final Object lock = this;
-
         try {
             final int timeout = this.strategy.getConnectTimeout();
 
-            LOG.debug("Promise {} attempting connect for {}ms", lock, timeout);
+            LOG.debug("Promise {} attempting connect for {}ms", this, timeout);
 
-            if(this.address.isUnresolved()) {
+            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);
+            this.bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, timeout);
+            final ChannelFuture connectFuture = this.bootstrap.connect(this.address);
             // Add listener that attempts reconnect by invoking this method again.
-            connectFuture.addListener(new BootstrapConnectListener(lock));
+            connectFuture.addListener(new BootstrapConnectListener());
             this.pending = connectFuture;
         } catch (final Exception e) {
             LOG.info("Failed to connect to {}", address, e);
@@ -82,20 +82,14 @@ final class ProtocolSessionPromise<S extends ProtocolSession<?>> extends Default
     }
 
     private class BootstrapConnectListener implements ChannelFutureListener {
-        private final Object lock;
-
-        public BootstrapConnectListener(final Object lock) {
-            this.lock = lock;
-        }
-
         @Override
         public void operationComplete(final ChannelFuture cf) {
-            synchronized (lock) {
+            synchronized (NetconfSessionPromise.this) {
 
-                LOG.debug("Promise {} connection resolved", lock);
+                LOG.debug("Promise {} connection resolved", NetconfSessionPromise.this);
 
                 // Triggered when a connection attempt is resolved.
-                Preconditions.checkState(ProtocolSessionPromise.this.pending.equals(cf));
+                Preconditions.checkState(NetconfSessionPromise.this.pending.equals(cf));
 
                 /*
                  * The promise we gave out could have been cancelled,
@@ -108,31 +102,31 @@ final class ProtocolSessionPromise<S extends ProtocolSession<?>> extends Default
                  */
                 if (isCancelled()) {
                     if (cf.isSuccess()) {
-                        LOG.debug("Closing channel for cancelled promise {}", lock);
+                        LOG.debug("Closing channel for cancelled promise {}", NetconfSessionPromise.this);
                         cf.channel().close();
                     }
                     return;
                 }
 
-                if(cf.isSuccess()) {
-                    LOG.debug("Promise {} connection successful", lock);
+                if (cf.isSuccess()) {
+                    LOG.debug("Promise {} connection successful", NetconfSessionPromise.this);
                     return;
                 }
 
-                LOG.debug("Attempt to connect to {} failed", ProtocolSessionPromise.this.address, cf.cause());
+                LOG.debug("Attempt to connect to {} failed", NetconfSessionPromise.this.address, cf.cause());
 
-                final Future<Void> rf = ProtocolSessionPromise.this.strategy.scheduleReconnect(cf.cause());
+                final Future<Void> rf = NetconfSessionPromise.this.strategy.scheduleReconnect(cf.cause());
                 rf.addListener(new ReconnectingStrategyListener());
-                ProtocolSessionPromise.this.pending = rf;
+                NetconfSessionPromise.this.pending = rf;
             }
         }
 
         private class ReconnectingStrategyListener implements FutureListener<Void> {
             @Override
             public void operationComplete(final Future<Void> sf) {
-                synchronized (lock) {
+                synchronized (NetconfSessionPromise.this) {
                     // Triggered when a connection attempt is to be made.
-                    Preconditions.checkState(ProtocolSessionPromise.this.pending.equals(sf));
+                    Preconditions.checkState(NetconfSessionPromise.this.pending.equals(sf));
 
                     /*
                      * The promise we gave out could have been cancelled,
@@ -152,7 +146,5 @@ final class ProtocolSessionPromise<S extends ProtocolSession<?>> extends Default
                 }
             }
         }
-
     }
-
 }
similarity index 96%
rename from protocol-framework/src/main/java/org/opendaylight/protocol/framework/NeverReconnectStrategy.java
rename to netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/NeverReconnectStrategy.java
index 824242cba6eccbe228cc0d7c271de7b703443c82..dc501eab736526ead34b24fe3d22538055a7717c 100644 (file)
@@ -5,15 +5,13 @@
  * 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;
+package org.opendaylight.netconf.nettyutil;
 
+import com.google.common.base.Preconditions;
 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.
similarity index 97%
rename from protocol-framework/src/main/java/org/opendaylight/protocol/framework/ReconnectImmediatelyStrategy.java
rename to netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/ReconnectImmediatelyStrategy.java
index 56cdcfb0c35b09e673984d7846d379395a1e0c1a..dd1f851acd38b29354416640997566b129a79a0b 100644 (file)
@@ -5,18 +5,15 @@
  * 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;
+package org.opendaylight.netconf.nettyutil;
 
+import com.google.common.base.Preconditions;
 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.
similarity index 70%
rename from protocol-framework/src/main/java/org/opendaylight/protocol/framework/ReconnectPromise.java
rename to netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/ReconnectPromise.java
index a0728514ed1a4a568938e7595903b808f5185917..696d9f7ad02587e934ba19c95c2c72c12d1d149e 100644 (file)
@@ -5,7 +5,7 @@
  * 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;
+package org.opendaylight.netconf.nettyutil;
 
 import com.google.common.base.Preconditions;
 import io.netty.bootstrap.Bootstrap;
@@ -15,24 +15,28 @@ import io.netty.util.concurrent.DefaultPromise;
 import io.netty.util.concurrent.EventExecutor;
 import io.netty.util.concurrent.Future;
 import java.net.InetSocketAddress;
+import org.opendaylight.netconf.api.NetconfSession;
+import org.opendaylight.netconf.api.NetconfSessionListener;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 @Deprecated
-final class ReconnectPromise<S extends ProtocolSession<?>, L extends SessionListener<?, ?, ?>> extends DefaultPromise<Void> {
+final class ReconnectPromise<S extends NetconfSession, L extends NetconfSessionListener<? super S>>
+        extends DefaultPromise<Void> {
     private static final Logger LOG = LoggerFactory.getLogger(ReconnectPromise.class);
 
-    private final AbstractDispatcher<S, L> dispatcher;
+    private final AbstractNetconfDispatcher<S, L> dispatcher;
     private final InetSocketAddress address;
     private final ReconnectStrategyFactory strategyFactory;
-    private final Bootstrap b;
-    private final AbstractDispatcher.PipelineInitializer<S> initializer;
+    private final Bootstrap bootstrap;
+    private final AbstractNetconfDispatcher.PipelineInitializer<S> initializer;
     private Future<?> pending;
 
-    public ReconnectPromise(final EventExecutor executor, final AbstractDispatcher<S, L> dispatcher, final InetSocketAddress address,
-                            final ReconnectStrategyFactory connectStrategyFactory, final Bootstrap b, final AbstractDispatcher.PipelineInitializer<S> initializer) {
+    ReconnectPromise(final EventExecutor executor, final AbstractNetconfDispatcher<S, L> dispatcher,
+            final InetSocketAddress address, final ReconnectStrategyFactory connectStrategyFactory,
+            final Bootstrap bootstrap, final AbstractNetconfDispatcher.PipelineInitializer<S> initializer) {
         super(executor);
-        this.b = b;
+        this.bootstrap = bootstrap;
         this.initializer = Preconditions.checkNotNull(initializer);
         this.dispatcher = Preconditions.checkNotNull(dispatcher);
         this.address = Preconditions.checkNotNull(address);
@@ -42,13 +46,17 @@ final class ReconnectPromise<S extends ProtocolSession<?>, L extends SessionList
     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) -> {
+        // 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, bootstrap, (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
+            // 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));
         });
 
@@ -60,10 +68,12 @@ final class ReconnectPromise<S extends ProtocolSession<?>, L extends SessionList
     }
 
     /**
+     * Indicate if the initial connection succeeded.
      *
-     * @return true if initial connection was established successfully, false if initial connection failed due to e.g. Connection refused, Negotiation failed
+     * @return true if initial connection was established successfully, false if initial connection failed due to e.g.
+     *         Connection refused, Negotiation failed
      */
-    private boolean isInitialConnectFinished() {
+    private synchronized boolean isInitialConnectFinished() {
         Preconditions.checkNotNull(pending);
         return pending.isDone() && pending.isSuccess();
     }
@@ -86,7 +96,7 @@ final class ReconnectPromise<S extends ProtocolSession<?>, L extends SessionList
     private static final class ClosedChannelHandler extends ChannelInboundHandlerAdapter {
         private final ReconnectPromise<?, ?> promise;
 
-        public ClosedChannelHandler(final ReconnectPromise<?, ?> promise) {
+        ClosedChannelHandler(final ReconnectPromise<?, ?> promise) {
             this.promise = promise;
         }
 
@@ -105,5 +115,4 @@ final class ReconnectPromise<S extends ProtocolSession<?>, L extends SessionList
             promise.connect();
         }
     }
-
 }
similarity index 97%
rename from protocol-framework/src/main/java/org/opendaylight/protocol/framework/ReconnectStrategy.java
rename to netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/ReconnectStrategy.java
index a0a91507997fa34bc5518de9cf18a5266e59d818..55e6b038282d68213f9cb8728cdf829613f1310a 100644 (file)
@@ -5,7 +5,7 @@
  * 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;
+package org.opendaylight.netconf.nettyutil;
 
 import io.netty.util.concurrent.Future;
 
@@ -13,6 +13,7 @@ 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.
  *
+ * <p>
  * 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
similarity index 94%
rename from protocol-framework/src/main/java/org/opendaylight/protocol/framework/ReconnectStrategyFactory.java
rename to netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/ReconnectStrategyFactory.java
index a71fa677c82539b2426452d8cda827d4d80084d8..275e9b926e00288e9246659049b33fd50e41ff32 100644 (file)
@@ -5,7 +5,7 @@
  * 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;
+package org.opendaylight.netconf.nettyutil;
 
 /**
  * Factory interface for creating new ReconnectStrategy instances. This is
similarity index 93%
rename from protocol-framework/src/main/java/org/opendaylight/protocol/framework/TimedReconnectStrategy.java
rename to netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/TimedReconnectStrategy.java
index 6a1607803b9310c1a1a5a43013ff2906b38b7290..2547049254f67687f5a37baec1604e02f56ac5e1 100644 (file)
@@ -5,40 +5,42 @@
  * 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;
+package org.opendaylight.netconf.nettyutil;
 
+import com.google.common.base.Preconditions;
 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.
  *
+ * <p>
  * This strategy continues to schedule reconnect attempts, each having to complete in a fixed time (connectTime).
  *
+ * <p>
  * 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 &gt; 1). Maximum sleep time between attempts can be capped to a specific value
  * (maxSleep).
  *
+ * <p>
  * The strategy can optionally give up based on two criteria:
  *
+ * <p>
  * A preset number of connection retries (maxAttempts) has been reached, or
  *
+ * <p>
  * 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.
  *
+ * <p>
  * Both these caps can be combined, with the strategy giving up as soon as the first one is reached.
  */
 @Deprecated
@@ -46,7 +48,9 @@ import com.google.common.base.Preconditions;
 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 Long deadline;
+    private final Long maxAttempts;
+    private final Long maxSleep;
     private final double sleepFactor;
     private final int connectTime;
     private final long minSleep;
@@ -60,8 +64,8 @@ public final class TimedReconnectStrategy implements ReconnectStrategy {
     @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) {
+    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);
@@ -122,14 +126,12 @@ public final class TimedReconnectStrategy implements ReconnectStrategy {
             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;
+        // Set the scheduled flag.
         this.scheduled = true;
 
         // Schedule a task for the right time. It will also clear the flag.
         return this.executor.schedule(() -> {
-            synchronized (lock) {
+            synchronized (TimedReconnectStrategy.this) {
                 Preconditions.checkState(TimedReconnectStrategy.this.scheduled);
                 TimedReconnectStrategy.this.scheduled = false;
             }
similarity index 96%
rename from protocol-framework/src/main/java/org/opendaylight/protocol/framework/TimedReconnectStrategyFactory.java
rename to netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/TimedReconnectStrategyFactory.java
index 8ea14f83d0d4c97e4461d3965b86bb95d22230c8..bf26187e12454f2523f1fa1f4236dd91a00015e8 100644 (file)
@@ -5,7 +5,7 @@
  * 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;
+package org.opendaylight.netconf.nettyutil;
 
 import io.netty.util.concurrent.EventExecutor;
 import java.math.BigDecimal;
index 443094a991660da5a95e918b65abf46c57adf74f..da2831a6f4b2bf51ce111e054f7e9eb4206493bc 100644 (file)
@@ -30,6 +30,8 @@ import org.opendaylight.netconf.client.NetconfClientSessionListener;
 import org.opendaylight.netconf.client.conf.NetconfClientConfiguration;
 import org.opendaylight.netconf.client.conf.NetconfReconnectingClientConfiguration;
 import org.opendaylight.netconf.client.conf.NetconfReconnectingClientConfigurationBuilder;
+import org.opendaylight.netconf.nettyutil.ReconnectStrategyFactory;
+import org.opendaylight.netconf.nettyutil.TimedReconnectStrategyFactory;
 import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler;
 import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.LoginPasswordHandler;
 import org.opendaylight.netconf.sal.connect.api.RemoteDevice;
@@ -51,8 +53,6 @@ import org.opendaylight.netconf.topology.singleton.api.RemoteDeviceConnector;
 import org.opendaylight.netconf.topology.singleton.impl.utils.NetconfConnectorDTO;
 import org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup;
 import org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologyUtils;
-import org.opendaylight.protocol.framework.ReconnectStrategyFactory;
-import org.opendaylight.protocol.framework.TimedReconnectStrategyFactory;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
index f8f0153d55d6a3425cdef15ff3ad8c63d091b5c2..d4dc99c698680e4731f4b51636f7016aee9ecf7e 100644 (file)
@@ -38,6 +38,8 @@ import org.opendaylight.netconf.client.NetconfClientSessionListener;
 import org.opendaylight.netconf.client.conf.NetconfClientConfiguration;
 import org.opendaylight.netconf.client.conf.NetconfReconnectingClientConfiguration;
 import org.opendaylight.netconf.client.conf.NetconfReconnectingClientConfigurationBuilder;
+import org.opendaylight.netconf.nettyutil.ReconnectStrategyFactory;
+import org.opendaylight.netconf.nettyutil.TimedReconnectStrategyFactory;
 import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler;
 import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.LoginPasswordHandler;
 import org.opendaylight.netconf.sal.connect.api.DeviceActionFactory;
@@ -59,8 +61,6 @@ import org.opendaylight.netconf.sal.connect.netconf.schema.YangLibrarySchemaYang
 import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
 import org.opendaylight.netconf.topology.api.NetconfTopology;
 import org.opendaylight.netconf.topology.api.SchemaRepositoryProvider;
-import org.opendaylight.protocol.framework.ReconnectStrategyFactory;
-import org.opendaylight.protocol.framework.TimedReconnectStrategyFactory;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
index 8d416c8a3aa3da54e293fa01ffbf9b3eecc5e9e8..0771258da80e7af34ef99909bcabba8e7ce258dc 100644 (file)
@@ -5,7 +5,6 @@
  * 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.sal.connect.netconf.listener;
 
 import static org.junit.Assert.assertEquals;
@@ -59,12 +58,12 @@ import org.opendaylight.netconf.client.NetconfClientSession;
 import org.opendaylight.netconf.client.conf.NetconfClientConfiguration;
 import org.opendaylight.netconf.client.conf.NetconfReconnectingClientConfiguration;
 import org.opendaylight.netconf.client.conf.NetconfReconnectingClientConfigurationBuilder;
+import org.opendaylight.netconf.nettyutil.ReconnectStrategy;
+import org.opendaylight.netconf.nettyutil.TimedReconnectStrategy;
 import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.LoginPasswordHandler;
 import org.opendaylight.netconf.sal.connect.api.RemoteDevice;
 import org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil;
 import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
-import org.opendaylight.protocol.framework.ReconnectStrategy;
-import org.opendaylight.protocol.framework.TimedReconnectStrategy;
 import org.opendaylight.yangtools.util.xml.UntrustedXML;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.RpcError;
index 9a29a1ec9dde73527163f637ce412bbfd3742c95..d808f2bf5d6802ec7f5d63ec85f4c80d1508bf99 100644 (file)
@@ -19,12 +19,12 @@ import org.opendaylight.netconf.client.NetconfClientDispatcherImpl;
 import org.opendaylight.netconf.client.NetconfClientSession;
 import org.opendaylight.netconf.client.conf.NetconfClientConfiguration;
 import org.opendaylight.netconf.client.conf.NetconfClientConfigurationBuilder;
+import org.opendaylight.netconf.nettyutil.NeverReconnectStrategy;
 import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.LoginPasswordHandler;
 import org.opendaylight.netconf.sal.connect.api.RemoteDevice;
 import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCommunicator;
 import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences;
 import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
-import org.opendaylight.protocol.framework.NeverReconnectStrategy;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
diff --git a/pom.xml b/pom.xml
index 88d77e3266b84432067101866bca8bf5a0ee4bb6..5a8e3c06f2b6281c1b17f47f6d8101ecd82365eb 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -32,7 +32,6 @@
         <module>features</module>
         <module>karaf</module>
         <module>netconf</module>
-        <module>protocol-framework</module>
         <module>restconf</module>
     </modules>
 
diff --git a/protocol-framework/.gitignore b/protocol-framework/.gitignore
deleted file mode 100644 (file)
index fc1d35e..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-target
-.classpath
-.settings
diff --git a/protocol-framework/pom.xml b/protocol-framework/pom.xml
deleted file mode 100644 (file)
index c6d5456..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
-<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.odlparent</groupId>
-    <artifactId>bundle-parent</artifactId>
-    <version>4.0.7</version>
-    <relativePath/>
-  </parent>
-
-  <groupId>org.opendaylight.netconf</groupId>
-  <artifactId>protocol-framework</artifactId>
-  <version>1.3.0-SNAPSHOT</version>
-  <packaging>bundle</packaging>
-  <name>${project.artifactId}</name>
-  <description>Common protocol framework</description>
-
-  <dependencies>
-    <dependency>
-      <groupId>com.google.guava</groupId>
-      <artifactId>guava</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>io.netty</groupId>
-      <artifactId>netty-buffer</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>io.netty</groupId>
-      <artifactId>netty-codec</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>io.netty</groupId>
-      <artifactId>netty-common</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>io.netty</groupId>
-      <artifactId>netty-transport</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-    </dependency>
-
-    <!-- Testing dependencies -->
-    <dependency>
-      <groupId>org.opendaylight.yangtools</groupId>
-      <artifactId>mockito-configuration</artifactId>
-      <version>2.1.6</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.osgi</groupId>
-      <artifactId>org.osgi.core</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-api</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>ch.qos.logback</groupId>
-      <artifactId>logback-classic</artifactId>
-      <scope>test</scope>
-    </dependency>
-  </dependencies>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-jar-plugin</artifactId>
-        <executions>
-          <execution>
-            <goals>
-              <goal>test-jar</goal>
-            </goals>
-            <phase>package</phase>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
-
-  <scm>
-    <connection>scm:git:ssh://git.opendaylight.org:29418/netconf.git</connection>
-    <developerConnection>scm:git:ssh://git.opendaylight.org:29418/netconf.git</developerConnection>
-    <tag>HEAD</tag>
-    <url>https://git.opendaylight.org/gerrit/gitweb?p=netconf.git;a=summary</url>
-  </scm>
-</project>
diff --git a/protocol-framework/src/main/java/org/opendaylight/protocol/framework/AbstractProtocolSession.java b/protocol-framework/src/main/java/org/opendaylight/protocol/framework/AbstractProtocolSession.java
deleted file mode 100644 (file)
index 44afc4e..0000000
+++ /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<M> extends SimpleChannelInboundHandler<Object> implements ProtocolSession<M> {
-    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/protocol-framework/src/main/java/org/opendaylight/protocol/framework/AbstractSessionNegotiator.java b/protocol-framework/src/main/java/org/opendaylight/protocol/framework/AbstractSessionNegotiator.java
deleted file mode 100644 (file)
index a7ec22f..0000000
+++ /dev/null
@@ -1,98 +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.channel.Channel;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
-import io.netty.util.concurrent.Promise;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Abstract base class for session negotiators. It implements the basic
- * substrate to implement SessionNegotiator API specification, with subclasses
- * needing to provide only
- *
- * @param <M> Protocol message type
- * @param <S> Protocol session type, has to extend {@code ProtocolSession<M>}
- */
-@Deprecated
-public abstract class AbstractSessionNegotiator<M, S extends AbstractProtocolSession<?>>
-        extends ChannelInboundHandlerAdapter implements SessionNegotiator<S> {
-    private final Logger LOG = LoggerFactory.getLogger(AbstractSessionNegotiator.class);
-    private final Promise<S> promise;
-    protected final Channel channel;
-
-    public AbstractSessionNegotiator(final Promise<S> 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(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/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ProtocolSession.java b/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ProtocolSession.java
deleted file mode 100644 (file)
index b998441..0000000
+++ /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<T> extends Closeable {
-    @Override
-    void close();
-}
diff --git a/protocol-framework/src/main/java/org/opendaylight/protocol/framework/SessionListener.java b/protocol-framework/src/main/java/org/opendaylight/protocol/framework/SessionListener.java
deleted file mode 100644 (file)
index 06b2730..0000000
+++ /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<M, S extends ProtocolSession<?>, 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/protocol-framework/src/main/java/org/opendaylight/protocol/framework/TerminationReason.java b/protocol-framework/src/main/java/org/opendaylight/protocol/framework/TerminationReason.java
deleted file mode 100644 (file)
index 19d1112..0000000
+++ /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/protocol-framework/src/test/java/org/opendaylight/protocol/framework/ServerTest.java b/protocol-framework/src/test/java/org/opendaylight/protocol/framework/ServerTest.java
deleted file mode 100644 (file)
index eeb4aa3..0000000
+++ /dev/null
@@ -1,251 +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.ArgumentMatchers.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;
-
-@Deprecated
-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<Boolean> 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<Boolean> 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<Boolean> 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<Boolean> 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<Boolean> 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<Boolean> 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<Void> 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<Boolean> p) {
-        return new SimpleDispatcher((factory, channel, promise) -> {
-            p.setSuccess(true);
-            return new SimpleSessionNegotiator(promise, channel);
-        }, null, serverLoopGroup);
-    }
-
-}
diff --git a/protocol-framework/src/test/java/org/opendaylight/protocol/framework/Session.java b/protocol-framework/src/test/java/org/opendaylight/protocol/framework/Session.java
deleted file mode 100644 (file)
index 790bd4e..0000000
+++ /dev/null
@@ -1,46 +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.collect.Lists;
-import java.util.List;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Deprecated
-public class Session extends AbstractProtocolSession<SimpleMessage> {
-
-    private static final Logger LOG = LoggerFactory.getLogger(Session.class);
-
-    public final List<SimpleMessage> 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/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleByteToMessageDecoder.java b/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleByteToMessageDecoder.java
deleted file mode 100644 (file)
index c53ee75..0000000
+++ /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;
-
-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;
-
-@Deprecated
-public class SimpleByteToMessageDecoder extends ByteToMessageDecoder {
-    @Override
-    protected void decode(final ChannelHandlerContext ctx, final ByteBuf in, final List<Object> out) {
-        out.add(new SimpleMessage(StandardCharsets.UTF_8.decode(in.nioBuffer()).toString()));
-    }
-}
diff --git a/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleDispatcher.java b/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleDispatcher.java
deleted file mode 100644 (file)
index 5c7cd4f..0000000
+++ /dev/null
@@ -1,66 +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.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;
-
-@Deprecated
-public class SimpleDispatcher extends AbstractDispatcher<SimpleSession, SimpleSessionListener> {
-    private static final Logger LOG = LoggerFactory.getLogger(SimpleDispatcher.class);
-
-    private final SessionNegotiatorFactory<SimpleMessage, SimpleSession, SimpleSessionListener> negotiatorFactory;
-    private final ChannelOutboundHandler encoder = new SimpleMessageToByteEncoder();
-
-    private final class SimplePipelineInitializer implements PipelineInitializer<SimpleSession> {
-        final SessionListenerFactory<SimpleSessionListener> listenerFactory;
-
-        SimplePipelineInitializer(final SessionListenerFactory<SimpleSessionListener> listenerFactory) {
-            this.listenerFactory = Preconditions.checkNotNull(listenerFactory);
-        }
-
-        @Override
-        public void initializeChannel(final SocketChannel channel, final Promise<SimpleSession> 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<SimpleMessage, SimpleSession, SimpleSessionListener> negotiatorFactory,
-            final Promise<SimpleSession> promise, final EventLoopGroup eventLoopGroup) {
-        super(eventLoopGroup, eventLoopGroup);
-        this.negotiatorFactory = Preconditions.checkNotNull(negotiatorFactory);
-    }
-
-    public Future<SimpleSession> createClient(final InetSocketAddress address, final ReconnectStrategy strategy, final SessionListenerFactory<SimpleSessionListener> listenerFactory) {
-        return super.createClient(address, strategy, new SimplePipelineInitializer(listenerFactory));
-    }
-
-    public Future<Void> createReconnectingClient(final InetSocketAddress address, final ReconnectStrategyFactory strategy, final SessionListenerFactory<SimpleSessionListener> listenerFactory) {
-        return super.createReconnectingClient(address, strategy, new SimplePipelineInitializer(listenerFactory));
-    }
-
-    public ChannelFuture createServer(final InetSocketAddress address, final SessionListenerFactory<SimpleSessionListener> listenerFactory) {
-        return super.createServer(address, new SimplePipelineInitializer(listenerFactory));
-    }
-
-    @Override
-    public void close() {
-    }
-}
diff --git a/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleMessage.java b/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleMessage.java
deleted file mode 100644 (file)
index 5bd5b07..0000000
+++ /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;
-
-@Deprecated
-public class SimpleMessage {
-
-    private final String s;
-
-    public SimpleMessage(final String s) {
-        this.s = s;
-    }
-
-    public String getMessage() {
-        return this.s;
-    }
-}
diff --git a/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleMessageToByteEncoder.java b/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleMessageToByteEncoder.java
deleted file mode 100644 (file)
index 43a5601..0000000
+++ /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;
-
-import io.netty.buffer.ByteBuf;
-import io.netty.channel.ChannelHandler.Sharable;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.handler.codec.MessageToByteEncoder;
-
-@Deprecated
-@Sharable
-public class SimpleMessageToByteEncoder extends MessageToByteEncoder<SimpleMessage> {
-    @Override
-    protected void encode(final ChannelHandlerContext ctx, final SimpleMessage msg, final ByteBuf out) {
-        out.writeBytes(msg.getMessage().getBytes());
-    }
-}
diff --git a/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleSession.java b/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleSession.java
deleted file mode 100644 (file)
index 136e98d..0000000
+++ /dev/null
@@ -1,31 +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;
-
-@Deprecated
-public final class SimpleSession extends AbstractProtocolSession<SimpleMessage> {
-
-    public SimpleSession() {
-    }
-
-    @Override
-    public void close() {
-    }
-
-    @Override
-    public void handleMessage(final SimpleMessage msg) {
-    }
-
-    @Override
-    public void endOfInput() {
-    }
-
-    @Override
-    protected void sessionUp() {
-    }
-}
diff --git a/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleSessionListener.java b/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleSessionListener.java
deleted file mode 100644 (file)
index 6323056..0000000
+++ /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.
- */
-@Deprecated
-public class SimpleSessionListener implements SessionListener<SimpleMessage, SimpleSession, TerminationReason> {
-    private static final Logger LOG = LoggerFactory.getLogger(SimpleSessionListener.class);
-
-    public List<SimpleMessage> 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/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleSessionListenerFactory.java b/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleSessionListenerFactory.java
deleted file mode 100644 (file)
index 04bc279..0000000
+++ /dev/null
@@ -1,17 +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;
-
-@Deprecated
-public class SimpleSessionListenerFactory implements SessionListenerFactory<SimpleSessionListener> {
-
-    @Override
-    public SimpleSessionListener getSessionListener() {
-        return new SimpleSessionListener();
-    }
-}
diff --git a/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleSessionNegotiator.java b/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleSessionNegotiator.java
deleted file mode 100644 (file)
index 50b2922..0000000
+++ /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;
-
-@Deprecated
-public class SimpleSessionNegotiator extends AbstractSessionNegotiator<SimpleMessage, SimpleSession> {
-
-    public SimpleSessionNegotiator(final Promise<SimpleSession> 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/protocol-framework/src/test/resources/logback-test.xml b/protocol-framework/src/test/resources/logback-test.xml
deleted file mode 100644 (file)
index 7ace930..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<configuration>
-
-  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
-    <encoder>
-      <Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>
-    </encoder>
-  </appender>
-
-  <root level="TRACE">
-    <appender-ref ref="STDOUT" />
-  </root>
-</configuration>