Remove Netconf(Client)SessionPreferences 47/101447/3
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 2 Jun 2022 18:40:16 +0000 (20:40 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 2 Jun 2022 19:54:34 +0000 (21:54 +0200)
These NetconfClientSessionPreferences are a strictly netconf-client thing,
remove it and adjust its users. This also renders
NetconfSessionPreferences useless, hence those are removed as well.

JIRA: NETCONF-590
Change-Id: I72c5718182751cb869c13318b4b0133bdbd197ea
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/NetconfClientSessionPreferences.java [deleted file]
netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/NetconfSessionPreferences.java [deleted file]
netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/NetconfClientSessionNegotiator.java
netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/NetconfClientSessionNegotiatorFactory.java
netconf/netconf-client/src/test/java/org/opendaylight/netconf/client/NetconfClientSessionNegotiatorTest.java

diff --git a/netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/NetconfClientSessionPreferences.java b/netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/NetconfClientSessionPreferences.java
deleted file mode 100644 (file)
index 0c444a1..0000000
+++ /dev/null
@@ -1,34 +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.netconf.api;
-
-import org.opendaylight.netconf.api.messages.NetconfHelloMessage;
-
-/**
- * The only input for the start of a NETCONF session is hello-message.
- */
-public final class NetconfClientSessionPreferences extends NetconfSessionPreferences {
-
-    private final NetconfMessage startExiMessage;
-
-    public NetconfClientSessionPreferences(final NetconfHelloMessage helloMessage,
-                                           final NetconfMessage startExiMessage) {
-        super(helloMessage);
-        this.startExiMessage = startExiMessage;
-    }
-
-    /**
-     * Getter for {@code NetconfMessage}.
-     *
-     * @return the startExiMessage
-     */
-    public NetconfMessage getStartExiMessage() {
-        return startExiMessage;
-    }
-}
diff --git a/netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/NetconfSessionPreferences.java b/netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/NetconfSessionPreferences.java
deleted file mode 100644 (file)
index 4360fbf..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netconf.api;
-
-import org.opendaylight.netconf.api.messages.NetconfHelloMessage;
-
-public class NetconfSessionPreferences {
-
-    private final NetconfHelloMessage helloMessage;
-
-    public NetconfSessionPreferences(final NetconfHelloMessage helloMessage) {
-        this.helloMessage = helloMessage;
-    }
-
-    /**
-     * Getter for {@code NetconfHelloMessage}.
-     *
-     * @return the helloMessage
-     */
-    public NetconfHelloMessage getHelloMessage() {
-        return this.helloMessage;
-    }
-
-}
index bbd17ce7bac5f18fc8c90b4c209da9da8d85542a..a1fe12eb97c69d7c0038c2277116d198cf208ed4 100644 (file)
@@ -19,7 +19,6 @@ import io.netty.util.concurrent.Promise;
 import java.util.Set;
 import javax.xml.xpath.XPathConstants;
 import javax.xml.xpath.XPathExpression;
-import org.opendaylight.netconf.api.NetconfClientSessionPreferences;
 import org.opendaylight.netconf.api.NetconfDocumentedException;
 import org.opendaylight.netconf.api.NetconfMessage;
 import org.opendaylight.netconf.api.messages.NetconfHelloMessage;
@@ -51,13 +50,13 @@ class NetconfClientSessionNegotiator
 
     private static final Interner<Set<String>> INTERNER = Interners.newWeakInterner();
 
-    private final NetconfMessage startExi;
+    private final NetconfStartExiMessage startExi;
 
-    NetconfClientSessionNegotiator(final NetconfClientSessionPreferences sessionPreferences,
+    NetconfClientSessionNegotiator(final NetconfHelloMessage hello, final NetconfStartExiMessage startExi,
             final Promise<NetconfClientSession> promise, final Channel channel, final Timer timer,
             final NetconfClientSessionListener sessionListener, final long connectionTimeoutMillis) {
-        super(sessionPreferences.getHelloMessage(), promise, channel, timer, sessionListener, connectionTimeoutMillis);
-        startExi = sessionPreferences.getStartExiMessage();
+        super(hello, promise, channel, timer, sessionListener, connectionTimeoutMillis);
+        this.startExi = startExi;
     }
 
     @SuppressWarnings("checkstyle:IllegalCatch")
@@ -78,9 +77,9 @@ class NetconfClientSessionNegotiator
 
         // If exi should be used, try to initiate exi communication
         // Call negotiationSuccessFul after exi negotiation is finished successfully or not
-        if (startExi instanceof NetconfStartExiMessage && shouldUseExi(netconfMessage)) {
+        if (startExi != null && shouldUseExi(netconfMessage)) {
             LOG.debug("Netconf session {} should use exi.", session);
-            tryToInitiateExi(session, (NetconfStartExiMessage) startExi);
+            tryToInitiateExi(session, startExi);
         } else {
             // Exi is not supported, release session immediately
             LOG.debug("Netconf session {} isn't capable of using exi.", session);
index 0606ca44c9130dfdf64f14e263ac004d1e6a619d..8a8cb2927d618e09365b995dbe82b816202f2bfa 100644 (file)
@@ -15,8 +15,6 @@ import io.netty.util.Timer;
 import io.netty.util.concurrent.Promise;
 import java.util.Optional;
 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;
@@ -98,8 +96,8 @@ public class NetconfClientSessionNegotiatorFactory
         this.timer = requireNonNull(timer);
         this.additionalHeader = additionalHeader;
         this.connectionTimeoutMillis = connectionTimeoutMillis;
-        this.options = exiOptions;
-        this.clientCapabilities = capabilities;
+        options = exiOptions;
+        clientCapabilities = capabilities;
     }
 
     public long getConnectionTimeoutMillis() {
@@ -110,12 +108,9 @@ public class NetconfClientSessionNegotiatorFactory
     public NetconfClientSessionNegotiator getSessionNegotiator(
             final NetconfSessionListenerFactory<NetconfClientSessionListener> sessionListenerFactory,
             final Channel channel, final Promise<NetconfClientSession> promise) {
-
-        NetconfMessage startExiMessage = NetconfStartExiMessage.create(options, START_EXI_MESSAGE_ID);
-        NetconfHelloMessage helloMessage = NetconfHelloMessage.createClientHello(clientCapabilities, additionalHeader);
-
-        NetconfClientSessionPreferences proposal = new NetconfClientSessionPreferences(helloMessage, startExiMessage);
-        return new NetconfClientSessionNegotiator(proposal, promise, channel, timer,
+        return new NetconfClientSessionNegotiator(
+            NetconfHelloMessage.createClientHello(clientCapabilities, additionalHeader),
+            NetconfStartExiMessage.create(options, START_EXI_MESSAGE_ID), promise, channel, timer,
                 sessionListenerFactory.getSessionListener(), connectionTimeoutMillis);
     }
 }
index db9e80ed42688f918acce2acf4a632227c74e5e5..29a687981725540a64bfeb70afd48c3c9cad653d 100644 (file)
@@ -39,7 +39,6 @@ import java.util.Set;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.internal.util.collections.Sets;
-import org.opendaylight.netconf.api.NetconfClientSessionPreferences;
 import org.opendaylight.netconf.api.NetconfDocumentedException;
 import org.opendaylight.netconf.api.NetconfMessage;
 import org.opendaylight.netconf.api.messages.NetconfHelloMessage;
@@ -129,15 +128,15 @@ public class NetconfClientSessionNegotiatorTest {
 
     private NetconfClientSessionNegotiator createNetconfClientSessionNegotiator(
             final Promise<NetconfClientSession> promise,
-            final NetconfMessage startExi) {
+            final NetconfStartExiMessage startExi) {
         ChannelProgressivePromise progressivePromise = mock(ChannelProgressivePromise.class);
-        NetconfClientSessionPreferences preferences = new NetconfClientSessionPreferences(helloMessage, startExi);
         doReturn(progressivePromise).when(promise).setFailure(any(Throwable.class));
 
         long timeout = 10L;
         NetconfClientSessionListener sessionListener = mock(NetconfClientSessionListener.class);
         Timer timer = new HashedWheelTimer();
-        return new NetconfClientSessionNegotiator(preferences, promise, channel, timer, sessionListener, timeout);
+        return new NetconfClientSessionNegotiator(helloMessage, startExi, promise, channel, timer, sessionListener,
+            timeout);
     }
 
     private static NetconfHelloMessage createHelloMsg(final String name) throws Exception {