- private ReconnectStrategy getReconnectStrategy() {
- final Long connectionAttempts;
- if (getMaxConnectionAttempts() != null && getMaxConnectionAttempts() > 0) {
- connectionAttempts = getMaxConnectionAttempts();
- } else {
- logger.trace("Setting {} on {} to infinity", maxConnectionAttemptsJmxAttribute, this);
- connectionAttempts = null;
+ private static final class SalConnectorCloseable implements AutoCloseable {
+ private final RemoteDeviceHandler<NetconfSessionPreferences> salFacade;
+ private final NetconfDeviceCommunicator listener;
+
+ public SalConnectorCloseable(final NetconfDeviceCommunicator listener,
+ final RemoteDeviceHandler<NetconfSessionPreferences> salFacade) {
+ this.listener = listener;
+ this.salFacade = salFacade;
+ }
+
+ @Override
+ public void close() {
+ listener.close();
+ salFacade.close();
+ }
+ }
+
+ private static final class TimedReconnectStrategyFactory implements ReconnectStrategyFactory {
+ private final Long connectionAttempts;
+ private final EventExecutor executor;
+ private final double sleepFactor;
+ private final int minSleep;
+
+ TimedReconnectStrategyFactory(final EventExecutor executor, final Long maxConnectionAttempts, final int minSleep, final BigDecimal sleepFactor) {
+ if (maxConnectionAttempts != null && maxConnectionAttempts > 0) {
+ connectionAttempts = maxConnectionAttempts;
+ } else {
+ logger.trace("Setting {} on {} to infinity", maxConnectionAttemptsJmxAttribute, this);
+ connectionAttempts = null;
+ }
+
+ this.sleepFactor = sleepFactor.doubleValue();
+ this.executor = executor;
+ this.minSleep = minSleep;