From: Robert Varga Date: Thu, 2 Jun 2022 18:40:16 +0000 (+0200) Subject: Remove Netconf(Client)SessionPreferences X-Git-Tag: v4.0.0~43 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=netconf.git;a=commitdiff_plain;h=7884e5218cd2b7c9526d3c77afbb6ffca111d81f Remove Netconf(Client)SessionPreferences 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 --- 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 index 0c444a1fed..0000000000 --- a/netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/NetconfClientSessionPreferences.java +++ /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 index 4360fbfde6..0000000000 --- a/netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/NetconfSessionPreferences.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.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; - } - -} diff --git a/netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/NetconfClientSessionNegotiator.java b/netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/NetconfClientSessionNegotiator.java index bbd17ce7ba..a1fe12eb97 100644 --- a/netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/NetconfClientSessionNegotiator.java +++ b/netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/NetconfClientSessionNegotiator.java @@ -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> INTERNER = Interners.newWeakInterner(); - private final NetconfMessage startExi; + private final NetconfStartExiMessage startExi; - NetconfClientSessionNegotiator(final NetconfClientSessionPreferences sessionPreferences, + NetconfClientSessionNegotiator(final NetconfHelloMessage hello, final NetconfStartExiMessage startExi, final Promise 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); diff --git a/netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/NetconfClientSessionNegotiatorFactory.java b/netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/NetconfClientSessionNegotiatorFactory.java index 0606ca44c9..8a8cb2927d 100644 --- a/netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/NetconfClientSessionNegotiatorFactory.java +++ b/netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/NetconfClientSessionNegotiatorFactory.java @@ -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 sessionListenerFactory, final Channel channel, final Promise 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); } } diff --git a/netconf/netconf-client/src/test/java/org/opendaylight/netconf/client/NetconfClientSessionNegotiatorTest.java b/netconf/netconf-client/src/test/java/org/opendaylight/netconf/client/NetconfClientSessionNegotiatorTest.java index db9e80ed42..29a6879817 100644 --- a/netconf/netconf-client/src/test/java/org/opendaylight/netconf/client/NetconfClientSessionNegotiatorTest.java +++ b/netconf/netconf-client/src/test/java/org/opendaylight/netconf/client/NetconfClientSessionNegotiatorTest.java @@ -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 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 {