+++ /dev/null
-/*
- * 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;
- }
-}
+++ /dev/null
-/*
- * 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;
- }
-
-}
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;
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")
// 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);
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;
this.timer = requireNonNull(timer);
this.additionalHeader = additionalHeader;
this.connectionTimeoutMillis = connectionTimeoutMillis;
- this.options = exiOptions;
- this.clientCapabilities = capabilities;
+ options = exiOptions;
+ clientCapabilities = capabilities;
}
public long getConnectionTimeoutMillis() {
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);
}
}
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;
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 {