2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.netconf.topology;
11 import com.google.common.base.Optional;
12 import com.google.common.base.Preconditions;
13 import com.google.common.base.Strings;
14 import com.google.common.util.concurrent.FutureCallback;
15 import com.google.common.util.concurrent.Futures;
16 import com.google.common.util.concurrent.ListenableFuture;
17 import io.netty.util.concurrent.EventExecutor;
19 import java.math.BigDecimal;
20 import java.net.InetSocketAddress;
21 import java.util.Collection;
22 import java.util.Collections;
23 import java.util.HashMap;
24 import java.util.List;
26 import org.opendaylight.controller.config.threadpool.ScheduledThreadPool;
27 import org.opendaylight.controller.config.threadpool.ThreadPool;
28 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
29 import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
30 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
31 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
32 import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
33 import org.opendaylight.controller.sal.core.api.Broker;
34 import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
35 import org.opendaylight.controller.sal.core.api.Provider;
36 import org.opendaylight.netconf.client.NetconfClientDispatcher;
37 import org.opendaylight.netconf.client.NetconfClientSessionListener;
38 import org.opendaylight.netconf.client.conf.NetconfClientConfiguration;
39 import org.opendaylight.netconf.client.conf.NetconfReconnectingClientConfiguration;
40 import org.opendaylight.netconf.client.conf.NetconfReconnectingClientConfigurationBuilder;
41 import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler;
42 import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.LoginPassword;
43 import org.opendaylight.netconf.sal.connect.api.RemoteDeviceHandler;
44 import org.opendaylight.netconf.sal.connect.netconf.NetconfDevice;
45 import org.opendaylight.netconf.sal.connect.netconf.NetconfStateSchemas;
46 import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCapabilities;
47 import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCommunicator;
48 import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences;
49 import org.opendaylight.netconf.sal.connect.netconf.listener.UserPreferences;
50 import org.opendaylight.netconf.sal.connect.netconf.sal.KeepaliveSalFacade;
51 import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
52 import org.opendaylight.netconf.topology.pipeline.TopologyMountPointFacade.ConnectionStatusListenerRegistration;
53 import org.opendaylight.protocol.framework.ReconnectStrategy;
54 import org.opendaylight.protocol.framework.ReconnectStrategyFactory;
55 import org.opendaylight.protocol.framework.TimedReconnectStrategy;
56 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Host;
57 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.Credentials;
60 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
61 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
62 import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactory;
63 import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
64 import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceFilter;
65 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
66 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistry;
67 import org.opendaylight.yangtools.yang.model.repo.util.FilesystemSchemaSourceCache;
68 import org.opendaylight.yangtools.yang.parser.repo.SharedSchemaRepository;
69 import org.opendaylight.yangtools.yang.parser.util.TextToASTTransformer;
70 import org.slf4j.Logger;
71 import org.slf4j.LoggerFactory;
73 public abstract class AbstractNetconfTopology implements NetconfTopology, BindingAwareProvider, Provider {
75 private static final Logger LOG = LoggerFactory.getLogger(AbstractNetconfTopology.class);
77 protected static final long DEFAULT_REQUEST_TIMEOUT_MILLIS = 60000L;
78 protected static final int DEFAULT_KEEPALIVE_DELAY = 0;
79 protected static final boolean DEFAULT_RECONNECT_ON_CHANGED_SCHEMA = false;
80 private static final int DEFAULT_MAX_CONNECTION_ATTEMPTS = 0;
81 private static final int DEFAULT_BETWEEN_ATTEMPTS_TIMEOUT_MILLIS = 2000;
82 private static final long DEFAULT_CONNECTION_TIMEOUT_MILLIS = 20000L;
83 private static final BigDecimal DEFAULT_SLEEP_FACTOR = new BigDecimal(1.5);
85 // constants related to Schema Cache(s)
87 * Filesystem based caches are stored relative to the cache directory.
89 private static final String CACHE_DIRECTORY = "cache";
92 * The default cache directory relative to <code>CACHE_DIRECTORY</code>
94 private static final String DEFAULT_CACHE_DIRECTORY = "schema";
97 * The qualified schema cache directory <code>cache/schema</code>
99 private static final String QUALIFIED_DEFAULT_CACHE_DIRECTORY = CACHE_DIRECTORY + File.separator+ DEFAULT_CACHE_DIRECTORY;
102 * The name for the default schema repository
104 private static final String DEFAULT_SCHEMA_REPOSITORY_NAME = "sal-netconf-connector";
107 * The default schema repository in the case that one is not specified.
109 private static final SharedSchemaRepository DEFAULT_SCHEMA_REPOSITORY =
110 new SharedSchemaRepository(DEFAULT_SCHEMA_REPOSITORY_NAME);
113 * The default <code>FilesystemSchemaSourceCache</code>, which stores cached files in <code>cache/schema</code>.
115 private static final FilesystemSchemaSourceCache<YangTextSchemaSource> DEFAULT_CACHE =
116 new FilesystemSchemaSourceCache<>(DEFAULT_SCHEMA_REPOSITORY, YangTextSchemaSource.class,
117 new File(QUALIFIED_DEFAULT_CACHE_DIRECTORY));
120 * The default factory for creating <code>SchemaContext</code> instances.
122 private static final SchemaContextFactory DEFAULT_SCHEMA_CONTEXT_FACTORY =
123 DEFAULT_SCHEMA_REPOSITORY.createSchemaContextFactory(SchemaSourceFilter.ALWAYS_ACCEPT);
126 * Keeps track of initialized Schema resources. A Map is maintained in which the key represents the name
127 * of the schema cache directory, and the value is a corresponding <code>SchemaResourcesDTO</code>. The
128 * <code>SchemaResourcesDTO</code> is essentially a container that allows for the extraction of the
129 * <code>SchemaRegistry</code> and <code>SchemaContextFactory</code> which should be used for a particular
130 * Netconf mount. Access to <code>schemaResourcesDTOs</code> should be surrounded by appropriate
131 * synchronization locks.
133 private static volatile Map<String, NetconfDevice.SchemaResourcesDTO> schemaResourcesDTOs = new HashMap<>();
135 // Initializes default constant instances for the case when the default schema repository
136 // directory cache/schema is used.
138 schemaResourcesDTOs.put(DEFAULT_CACHE_DIRECTORY,
139 new NetconfDevice.SchemaResourcesDTO(DEFAULT_SCHEMA_REPOSITORY,
140 DEFAULT_SCHEMA_CONTEXT_FACTORY,
141 new NetconfStateSchemas.NetconfStateSchemasResolverImpl()));
142 DEFAULT_SCHEMA_REPOSITORY.registerSchemaSourceListener(DEFAULT_CACHE);
143 DEFAULT_SCHEMA_REPOSITORY.registerSchemaSourceListener(
144 TextToASTTransformer.create(DEFAULT_SCHEMA_REPOSITORY, DEFAULT_SCHEMA_REPOSITORY));
147 protected final String topologyId;
148 private final NetconfClientDispatcher clientDispatcher;
149 protected final BindingAwareBroker bindingAwareBroker;
150 protected final Broker domBroker;
151 private final EventExecutor eventExecutor;
152 protected final ScheduledThreadPool keepaliveExecutor;
153 protected final ThreadPool processingExecutor;
154 protected final SharedSchemaRepository sharedSchemaRepository;
156 protected SchemaSourceRegistry schemaRegistry = DEFAULT_SCHEMA_REPOSITORY;
157 protected SchemaContextFactory schemaContextFactory = DEFAULT_SCHEMA_CONTEXT_FACTORY;
159 protected DOMMountPointService mountPointService = null;
160 protected DataBroker dataBroker = null;
161 protected final HashMap<NodeId, NetconfConnectorDTO> activeConnectors = new HashMap<>();
163 protected AbstractNetconfTopology(final String topologyId, final NetconfClientDispatcher clientDispatcher,
164 final BindingAwareBroker bindingAwareBroker, final Broker domBroker,
165 final EventExecutor eventExecutor, final ScheduledThreadPool keepaliveExecutor,
166 final ThreadPool processingExecutor, final SchemaRepositoryProvider schemaRepositoryProvider) {
167 this.topologyId = topologyId;
168 this.clientDispatcher = clientDispatcher;
169 this.bindingAwareBroker = bindingAwareBroker;
170 this.domBroker = domBroker;
171 this.eventExecutor = eventExecutor;
172 this.keepaliveExecutor = keepaliveExecutor;
173 this.processingExecutor = processingExecutor;
174 this.sharedSchemaRepository = schemaRepositoryProvider.getSharedSchemaRepository();
177 protected void registerToSal(BindingAwareProvider baProvider, Provider provider) {
178 domBroker.registerProvider(provider);
179 bindingAwareBroker.registerProvider(baProvider);
182 public void setSchemaRegistry(final SchemaSourceRegistry schemaRegistry) {
183 this.schemaRegistry = schemaRegistry;
186 public void setSchemaContextFactory(final SchemaContextFactory schemaContextFactory) {
187 this.schemaContextFactory = schemaContextFactory;
191 public abstract void onSessionInitiated(ProviderContext session);
194 public String getTopologyId() {
199 public DataBroker getDataBroker() {
204 public ListenableFuture<NetconfDeviceCapabilities> connectNode(NodeId nodeId, Node configNode) {
205 LOG.info("Connecting RemoteDevice{{}} , with config {}", nodeId, configNode);
206 return setupConnection(nodeId, configNode);
210 public ListenableFuture<Void> disconnectNode(NodeId nodeId) {
211 LOG.debug("Disconnecting RemoteDevice{{}}", nodeId.getValue());
212 if (!activeConnectors.containsKey(nodeId)) {
213 return Futures.immediateFailedFuture(new IllegalStateException("Unable to disconnect device that is not connected"));
216 // retrieve connection, and disconnect it
217 final NetconfConnectorDTO connectorDTO = activeConnectors.remove(nodeId);
218 connectorDTO.getCommunicator().close();
219 connectorDTO.getFacade().close();
220 return Futures.immediateFuture(null);
223 protected ListenableFuture<NetconfDeviceCapabilities> setupConnection(final NodeId nodeId,
224 final Node configNode) {
225 final NetconfNode netconfNode = configNode.getAugmentation(NetconfNode.class);
227 Preconditions.checkNotNull(netconfNode.getHost());
228 Preconditions.checkNotNull(netconfNode.getPort());
229 Preconditions.checkNotNull(netconfNode.isTcpOnly());
231 final NetconfConnectorDTO deviceCommunicatorDTO = createDeviceCommunicator(nodeId, netconfNode);
232 final NetconfDeviceCommunicator deviceCommunicator = deviceCommunicatorDTO.getCommunicator();
233 final NetconfClientSessionListener netconfClientSessionListener = deviceCommunicatorDTO.getSessionListener();
234 final NetconfReconnectingClientConfiguration clientConfig = getClientConfig(netconfClientSessionListener, netconfNode);
235 final ListenableFuture<NetconfDeviceCapabilities> future = deviceCommunicator.initializeRemoteConnection(clientDispatcher, clientConfig);
237 activeConnectors.put(nodeId, deviceCommunicatorDTO);
239 Futures.addCallback(future, new FutureCallback<NetconfDeviceCapabilities>() {
241 public void onSuccess(NetconfDeviceCapabilities result) {
242 LOG.debug("Connector for : " + nodeId.getValue() + " started succesfully");
246 public void onFailure(Throwable t) {
247 LOG.error("Connector for : " + nodeId.getValue() + " failed");
248 // remove this node from active connectors?
255 protected NetconfConnectorDTO createDeviceCommunicator(final NodeId nodeId,
256 final NetconfNode node) {
257 //setup default values since default value is not supported yet in mdsal
258 // TODO remove this when mdsal starts supporting default values
259 final Long defaultRequestTimeoutMillis = node.getDefaultRequestTimeoutMillis() == null ? DEFAULT_REQUEST_TIMEOUT_MILLIS : node.getDefaultRequestTimeoutMillis();
260 final Long keepaliveDelay = node.getKeepaliveDelay() == null ? DEFAULT_KEEPALIVE_DELAY : node.getKeepaliveDelay();
261 final Boolean reconnectOnChangedSchema = node.isReconnectOnChangedSchema() == null ? DEFAULT_RECONNECT_ON_CHANGED_SCHEMA : node.isReconnectOnChangedSchema();
263 IpAddress ipAddress = node.getHost().getIpAddress();
264 InetSocketAddress address = new InetSocketAddress(ipAddress.getIpv4Address() != null ?
265 ipAddress.getIpv4Address().getValue() : ipAddress.getIpv6Address().getValue(),
266 node.getPort().getValue());
267 RemoteDeviceId remoteDeviceId = new RemoteDeviceId(nodeId.getValue(), address);
269 RemoteDeviceHandler<NetconfSessionPreferences> salFacade =
270 createSalFacade(remoteDeviceId, domBroker, bindingAwareBroker, defaultRequestTimeoutMillis);
272 if (keepaliveDelay > 0) {
273 LOG.warn("Adding keepalive facade, for device {}", nodeId);
274 salFacade = new KeepaliveSalFacade(remoteDeviceId, salFacade, keepaliveExecutor.getExecutor(), keepaliveDelay);
277 final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO = setupSchemaCacheDTO(nodeId, node);
279 final NetconfDevice device = new NetconfDevice(schemaResourcesDTO, remoteDeviceId, salFacade,
280 processingExecutor.getExecutor(), reconnectOnChangedSchema);
282 final Optional<NetconfSessionPreferences> userCapabilities = getUserCapabilities(node);
284 return new NetconfConnectorDTO(
285 userCapabilities.isPresent() ?
286 new NetconfDeviceCommunicator(
287 remoteDeviceId, device, new UserPreferences(userCapabilities.get(), node.getYangModuleCapabilities().isOverride())):
288 new NetconfDeviceCommunicator(remoteDeviceId, device)
292 protected NetconfDevice.SchemaResourcesDTO setupSchemaCacheDTO(final NodeId nodeId, final NetconfNode node) {
293 // Setup information related to the SchemaRegistry, SchemaResourceFactory, etc.
294 NetconfDevice.SchemaResourcesDTO schemaResourcesDTO = null;
295 final String moduleSchemaCacheDirectory = node.getSchemaCacheDirectory();
296 // Only checks to ensure the String is not empty or null; further checks related to directory accessibility and file permissions
297 // are handled during the FilesystemSchemaSourceCache initialization.
298 if (!Strings.isNullOrEmpty(moduleSchemaCacheDirectory)) {
299 // If a custom schema cache directory is specified, create the backing DTO; otherwise, the SchemaRegistry and
300 // SchemaContextFactory remain the default values.
301 if (!moduleSchemaCacheDirectory.equals(DEFAULT_CACHE_DIRECTORY)) {
302 // Multiple modules may be created at once; synchronize to avoid issues with data consistency among threads.
303 synchronized(schemaResourcesDTOs) {
304 // Look for the cached DTO to reuse SchemaRegistry and SchemaContextFactory variables if they already exist
305 schemaResourcesDTO = schemaResourcesDTOs.get(moduleSchemaCacheDirectory);
306 if (schemaResourcesDTO == null) {
307 schemaResourcesDTO = createSchemaResourcesDTO(moduleSchemaCacheDirectory);
308 schemaResourcesDTO.getSchemaRegistry().registerSchemaSourceListener(
309 TextToASTTransformer.create((SchemaRepository) schemaResourcesDTO.getSchemaRegistry(), schemaResourcesDTO.getSchemaRegistry())
311 schemaResourcesDTOs.put(moduleSchemaCacheDirectory, schemaResourcesDTO);
314 LOG.info("Netconf connector for device {} will use schema cache directory {} instead of {}",
315 nodeId.getValue(), moduleSchemaCacheDirectory, DEFAULT_CACHE_DIRECTORY);
318 LOG.warn("schema-cache-directory for {} is null or empty; using the default {}",
319 nodeId.getValue(), QUALIFIED_DEFAULT_CACHE_DIRECTORY);
322 if (schemaResourcesDTO == null) {
323 schemaResourcesDTO = new NetconfDevice.SchemaResourcesDTO(schemaRegistry, schemaContextFactory,
324 new NetconfStateSchemas.NetconfStateSchemasResolverImpl());
327 return schemaResourcesDTO;
331 * Creates the backing Schema classes for a particular directory.
333 * @param moduleSchemaCacheDirectory The string directory relative to "cache"
334 * @return A DTO containing the Schema classes for the Netconf mount.
336 private NetconfDevice.SchemaResourcesDTO createSchemaResourcesDTO(final String moduleSchemaCacheDirectory) {
337 final SharedSchemaRepository repository = new SharedSchemaRepository(moduleSchemaCacheDirectory);
338 final SchemaContextFactory schemaContextFactory
339 = repository.createSchemaContextFactory(SchemaSourceFilter.ALWAYS_ACCEPT);
340 setSchemaRegistry(repository);
341 setSchemaContextFactory(schemaContextFactory);
342 final FilesystemSchemaSourceCache<YangTextSchemaSource> deviceCache =
343 createDeviceFilesystemCache(moduleSchemaCacheDirectory);
344 repository.registerSchemaSourceListener(deviceCache);
345 return new NetconfDevice.SchemaResourcesDTO(repository, schemaContextFactory,
346 new NetconfStateSchemas.NetconfStateSchemasResolverImpl());
350 * Creates a <code>FilesystemSchemaSourceCache</code> for the custom schema cache directory.
352 * @param schemaCacheDirectory The custom cache directory relative to "cache"
353 * @return A <code>FilesystemSchemaSourceCache</code> for the custom schema cache directory
355 private FilesystemSchemaSourceCache<YangTextSchemaSource> createDeviceFilesystemCache(final String schemaCacheDirectory) {
356 final String relativeSchemaCacheDirectory = CACHE_DIRECTORY + File.separator + schemaCacheDirectory;
357 return new FilesystemSchemaSourceCache<>(schemaRegistry, YangTextSchemaSource.class, new File(relativeSchemaCacheDirectory));
360 public NetconfReconnectingClientConfiguration getClientConfig(final NetconfClientSessionListener listener, NetconfNode node) {
362 //setup default values since default value is not supported yet in mdsal
363 // TODO remove this when mdsal starts supporting default values
364 final long clientConnectionTimeoutMillis = node.getConnectionTimeoutMillis() == null ? DEFAULT_CONNECTION_TIMEOUT_MILLIS : node.getConnectionTimeoutMillis();
365 final long maxConnectionAttempts = node.getMaxConnectionAttempts() == null ? DEFAULT_MAX_CONNECTION_ATTEMPTS : node.getMaxConnectionAttempts();
366 final int betweenAttemptsTimeoutMillis = node.getBetweenAttemptsTimeoutMillis() == null ? DEFAULT_BETWEEN_ATTEMPTS_TIMEOUT_MILLIS : node.getBetweenAttemptsTimeoutMillis();
367 final BigDecimal sleepFactor = node.getSleepFactor() == null ? DEFAULT_SLEEP_FACTOR : node.getSleepFactor();
369 final InetSocketAddress socketAddress = getSocketAddress(node.getHost(), node.getPort().getValue());
371 final ReconnectStrategyFactory sf = new TimedReconnectStrategyFactory(eventExecutor,
372 maxConnectionAttempts, betweenAttemptsTimeoutMillis, sleepFactor);
373 final ReconnectStrategy strategy = sf.createReconnectStrategy();
375 final AuthenticationHandler authHandler;
376 final Credentials credentials = node.getCredentials();
377 if (credentials instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPassword) {
378 authHandler = new LoginPassword(
379 ((org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPassword) credentials).getUsername(),
380 ((org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPassword) credentials).getPassword());
382 throw new IllegalStateException("Only login/password authentification is supported");
385 return NetconfReconnectingClientConfigurationBuilder.create()
386 .withAddress(socketAddress)
387 .withConnectionTimeoutMillis(clientConnectionTimeoutMillis)
388 .withReconnectStrategy(strategy)
389 .withAuthHandler(authHandler)
390 .withProtocol(node.isTcpOnly() ?
391 NetconfClientConfiguration.NetconfClientProtocol.TCP :
392 NetconfClientConfiguration.NetconfClientProtocol.SSH)
393 .withConnectStrategyFactory(sf)
394 .withSessionListener(listener)
398 protected abstract RemoteDeviceHandler<NetconfSessionPreferences> createSalFacade(final RemoteDeviceId id, final Broker domBroker, final BindingAwareBroker bindingBroker, long defaultRequestTimeoutMillis);
401 public abstract ConnectionStatusListenerRegistration registerConnectionStatusListener(NodeId node, RemoteDeviceHandler<NetconfSessionPreferences> listener);
404 public void onSessionInitiated(ProviderSession session) {
405 mountPointService = session.getService(DOMMountPointService.class);
409 public Collection<ProviderFunctionality> getProviderFunctionality() {
410 return Collections.emptySet();
413 private InetSocketAddress getSocketAddress(final Host host, int port) {
414 if(host.getDomainName() != null) {
415 return new InetSocketAddress(host.getDomainName().getValue(), port);
417 final IpAddress ipAddress = host.getIpAddress();
418 final String ip = ipAddress.getIpv4Address() != null ? ipAddress.getIpv4Address().getValue() : ipAddress.getIpv6Address().getValue();
419 return new InetSocketAddress(ip, port);
423 private Optional<NetconfSessionPreferences> getUserCapabilities(final NetconfNode node) {
424 if(node.getYangModuleCapabilities() == null) {
425 return Optional.absent();
428 final List<String> capabilities = node.getYangModuleCapabilities().getCapability();
429 if(capabilities == null || capabilities.isEmpty()) {
430 return Optional.absent();
433 final NetconfSessionPreferences parsedOverrideCapabilities = NetconfSessionPreferences.fromStrings(capabilities);
434 Preconditions.checkState(parsedOverrideCapabilities.getNonModuleCaps().isEmpty(), "Capabilities to override can " +
435 "only contain module based capabilities, non-module capabilities will be retrieved from the device," +
436 " configured non-module capabilities: " + parsedOverrideCapabilities.getNonModuleCaps());
438 return Optional.of(parsedOverrideCapabilities);
441 private static final class TimedReconnectStrategyFactory implements ReconnectStrategyFactory {
442 private final Long connectionAttempts;
443 private final EventExecutor executor;
444 private final double sleepFactor;
445 private final int minSleep;
447 TimedReconnectStrategyFactory(final EventExecutor executor, final Long maxConnectionAttempts, final int minSleep, final BigDecimal sleepFactor) {
448 if (maxConnectionAttempts != null && maxConnectionAttempts > 0) {
449 connectionAttempts = maxConnectionAttempts;
451 connectionAttempts = null;
454 this.sleepFactor = sleepFactor.doubleValue();
455 this.executor = executor;
456 this.minSleep = minSleep;
460 public ReconnectStrategy createReconnectStrategy() {
461 final Long maxSleep = null;
462 final Long deadline = null;
464 return new TimedReconnectStrategy(executor, minSleep,
465 minSleep, sleepFactor, maxSleep, connectionAttempts, deadline);
469 protected static class NetconfConnectorDTO {
471 private final NetconfDeviceCommunicator communicator;
472 private final RemoteDeviceHandler<NetconfSessionPreferences> facade;
474 public NetconfConnectorDTO(final NetconfDeviceCommunicator communicator, final RemoteDeviceHandler<NetconfSessionPreferences> facade) {
475 this.communicator = communicator;
476 this.facade = facade;
479 public NetconfDeviceCommunicator getCommunicator() {
483 public RemoteDeviceHandler<NetconfSessionPreferences> getFacade() {
487 public NetconfClientSessionListener getSessionListener() {