X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-netconf-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fyang%2Fmd%2Fsal%2Fconnector%2Fnetconf%2FNetconfConnectorModule.java;h=44b2435da2284358b4a2ed13cbb6e699e23f2115;hp=460e072d9a5d8697c373c6449bf822980ca8827f;hb=c31509c7a6630e54a9f9749a643fed5e1a1ad380;hpb=a8cdfe15e97b0ca8f683a2d0aed1b37ab15618e0 diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/config/yang/md/sal/connector/netconf/NetconfConnectorModule.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/config/yang/md/sal/connector/netconf/NetconfConnectorModule.java index 460e072d9a..44b2435da2 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/config/yang/md/sal/connector/netconf/NetconfConnectorModule.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/config/yang/md/sal/connector/netconf/NetconfConnectorModule.java @@ -9,6 +9,7 @@ package org.opendaylight.controller.config.yang.md.sal.connector.netconf; import static org.opendaylight.controller.config.api.JmxAttributeValidationException.checkCondition; import static org.opendaylight.controller.config.api.JmxAttributeValidationException.checkNotNull; + import com.google.common.base.Optional; import io.netty.util.concurrent.EventExecutor; import java.math.BigDecimal; @@ -87,7 +88,6 @@ public final class NetconfConnectorModule extends org.opendaylight.controller.co } userCapabilities = getUserCapabilities(); - } private boolean isHostAddressPresent(final Host address) { @@ -111,17 +111,17 @@ public final class NetconfConnectorModule extends org.opendaylight.controller.co new NetconfDevice.SchemaResourcesDTO(schemaRegistry, schemaContextFactory, new NetconfStateSchemas.NetconfStateSchemasResolverImpl()); final NetconfDevice device = - new NetconfDevice(schemaResourcesDTO, id, salFacade, globalProcessingExecutor, new NetconfMessageTransformer()); + new NetconfDevice(schemaResourcesDTO, id, salFacade, globalProcessingExecutor, new NetconfMessageTransformer(), getReconnectOnChangedSchema()); final NetconfDeviceCommunicator listener = userCapabilities.isPresent() ? new NetconfDeviceCommunicator(id, device, userCapabilities.get()) : new NetconfDeviceCommunicator(id, device); final NetconfReconnectingClientConfiguration clientConfig = getClientConfig(listener); - final NetconfClientDispatcher dispatcher = getClientDispatcherDependency(); + listener.initializeRemoteConnection(dispatcher, clientConfig); - return new MyAutoCloseable(listener, salFacade); + return new SalConnectorCloseable(listener, salFacade); } private Optional getUserCapabilities() { @@ -152,7 +152,7 @@ public final class NetconfConnectorModule extends org.opendaylight.controller.co final InetSocketAddress socketAddress = getSocketAddress(); final long clientConnectionTimeoutMillis = getConnectionTimeoutMillis(); - final ReconnectStrategyFactory sf = new MyReconnectStrategyFactory( + final ReconnectStrategyFactory sf = new TimedReconnectStrategyFactory( getEventExecutorDependency(), getMaxConnectionAttempts(), getBetweenAttemptsTimeoutMillis(), getSleepFactor()); final ReconnectStrategy strategy = sf.createReconnectStrategy(); @@ -160,21 +160,21 @@ public final class NetconfConnectorModule extends org.opendaylight.controller.co .withAddress(socketAddress) .withConnectionTimeoutMillis(clientConnectionTimeoutMillis) .withReconnectStrategy(strategy) - .withSessionListener(listener) .withAuthHandler(new LoginPassword(getUsername(),getPassword())) .withProtocol(getTcpOnly() ? NetconfClientConfiguration.NetconfClientProtocol.TCP : NetconfClientConfiguration.NetconfClientProtocol.SSH) .withConnectStrategyFactory(sf) + .withSessionListener(listener) .build(); } - private static final class MyAutoCloseable implements AutoCloseable { + private static final class SalConnectorCloseable implements AutoCloseable { private final RemoteDeviceHandler salFacade; private final NetconfDeviceCommunicator listener; - public MyAutoCloseable(final NetconfDeviceCommunicator listener, - final RemoteDeviceHandler salFacade) { + public SalConnectorCloseable(final NetconfDeviceCommunicator listener, + final RemoteDeviceHandler salFacade) { this.listener = listener; this.salFacade = salFacade; } @@ -186,13 +186,13 @@ public final class NetconfConnectorModule extends org.opendaylight.controller.co } } - private static final class MyReconnectStrategyFactory implements ReconnectStrategyFactory { + private static final class TimedReconnectStrategyFactory implements ReconnectStrategyFactory { private final Long connectionAttempts; private final EventExecutor executor; private final double sleepFactor; private final int minSleep; - MyReconnectStrategyFactory(final EventExecutor executor, final Long maxConnectionAttempts, final int minSleep, final BigDecimal sleepFactor) { + TimedReconnectStrategyFactory(final EventExecutor executor, final Long maxConnectionAttempts, final int minSleep, final BigDecimal sleepFactor) { if (maxConnectionAttempts != null && maxConnectionAttempts > 0) { connectionAttempts = maxConnectionAttempts; } else {