import io.netty.util.Timer;
import java.net.InetSocketAddress;
import java.util.concurrent.Executor;
-import java.util.concurrent.ScheduledExecutorService;
-import org.opendaylight.controller.config.threadpool.ScheduledThreadPool;
import org.opendaylight.controller.config.threadpool.ThreadPool;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.dom.api.DOMMountPointService;
private final CallHomeMountSessionManager sessionManager = new CallHomeMountSessionManager();
private final String topologyId;
private final Timer timer;
- private final ScheduledExecutorService scheduledExecutor;
private final Executor processingExecutor;
private final SchemaResourceManager schemaRepositoryProvider;
private final DataBroker dataBroker;
private final DeviceActionFactory deviceActionFactory;
private final BaseNetconfSchemas baseSchemas;
- public CallHomeMountFactory(final String topologyId, final Timer timer,
- final ScheduledExecutorService scheduledExecutor, final Executor processingExecutor,
+ public CallHomeMountFactory(final String topologyId, final Timer timer, final Executor processingExecutor,
final SchemaResourceManager schemaRepositoryProvider, final BaseNetconfSchemas baseSchemas,
final DataBroker dataBroker, final DOMMountPointService mountService,
final NetconfClientConfigurationBuilderFactory builderFactory) {
- this(topologyId, timer, scheduledExecutor, processingExecutor, schemaRepositoryProvider, baseSchemas,
- dataBroker, mountService, builderFactory, null);
+ this(topologyId, timer, processingExecutor, schemaRepositoryProvider, baseSchemas, dataBroker, mountService,
+ builderFactory, null);
}
@Activate
public CallHomeMountFactory(@Reference(target = "(type=global-timer)") final Timer timer,
- @Reference(target = "(type=global-netconf-ssh-scheduled-executor)")
- final ScheduledThreadPool scheduledThreadPool,
@Reference(target = "(type=global-netconf-processing-executor)") final ThreadPool processingThreadPool,
@Reference final SchemaResourceManager schemaRepositoryProvider,
@Reference final BaseNetconfSchemas baseSchemas, @Reference final DataBroker dataBroker,
@Reference final DOMMountPointService mountService,
@Reference(target = "(type=legacy)") final NetconfClientConfigurationBuilderFactory builderFactory,
@Reference final DeviceActionFactory deviceActionFactory) {
- this(NetconfNodeUtils.DEFAULT_TOPOLOGY_NAME, timer, scheduledThreadPool.getExecutor(),
- processingThreadPool.getExecutor(), schemaRepositoryProvider, baseSchemas, dataBroker, mountService,
- builderFactory, deviceActionFactory);
+ this(NetconfNodeUtils.DEFAULT_TOPOLOGY_NAME, timer, processingThreadPool.getExecutor(),
+ schemaRepositoryProvider, baseSchemas, dataBroker, mountService, builderFactory, deviceActionFactory);
}
- public CallHomeMountFactory(final String topologyId, final Timer timer,
- final ScheduledExecutorService scheduledExecutor, final Executor processingExecutor,
+ public CallHomeMountFactory(final String topologyId, final Timer timer, final Executor processingExecutor,
final SchemaResourceManager schemaRepositoryProvider, final BaseNetconfSchemas baseSchemas,
final DataBroker dataBroker, final DOMMountPointService mountService,
final NetconfClientConfigurationBuilderFactory builderFactory,
final DeviceActionFactory deviceActionFactory) {
this.topologyId = topologyId;
this.timer = requireNonNull(timer);
- this.scheduledExecutor = scheduledExecutor;
this.processingExecutor = processingExecutor;
this.schemaRepositoryProvider = schemaRepositoryProvider;
this.deviceActionFactory = deviceActionFactory;
@VisibleForTesting
void createTopology() {
- topology = new CallHomeTopology(topologyId, this, timer, scheduledExecutor, processingExecutor,
- schemaRepositoryProvider, dataBroker, mountService, builderFactory, baseSchemas, deviceActionFactory);
+ topology = new CallHomeTopology(topologyId, this, timer, processingExecutor, schemaRepositoryProvider,
+ dataBroker, mountService, builderFactory, baseSchemas, deviceActionFactory);
}
@VisibleForTesting
import com.google.common.annotations.VisibleForTesting;
import io.netty.util.Timer;
import java.util.concurrent.Executor;
-import java.util.concurrent.ScheduledExecutorService;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.dom.api.DOMMountPointService;
import org.opendaylight.netconf.client.NetconfClientFactory;
// Non-final for mocking
public class CallHomeTopology extends AbstractNetconfTopology {
public CallHomeTopology(final String topologyId, final NetconfClientFactory clientFactory, final Timer timer,
- final ScheduledExecutorService scheduledExecutor, final Executor processingExecutor,
- final SchemaResourceManager schemaRepositoryProvider, final DataBroker dataBroker,
- final DOMMountPointService mountPointService, final NetconfClientConfigurationBuilderFactory builderFactory,
- final BaseNetconfSchemas baseSchemas, final DeviceActionFactory deviceActionFactory) {
- super(topologyId, clientFactory, timer, scheduledExecutor, processingExecutor, schemaRepositoryProvider,
- dataBroker, mountPointService, builderFactory, deviceActionFactory, baseSchemas);
+ final Executor processingExecutor, final SchemaResourceManager schemaRepositoryProvider,
+ final DataBroker dataBroker, final DOMMountPointService mountPointService,
+ final NetconfClientConfigurationBuilderFactory builderFactory, final BaseNetconfSchemas baseSchemas,
+ final DeviceActionFactory deviceActionFactory) {
+ super(topologyId, clientFactory, timer, processingExecutor, schemaRepositoryProvider, dataBroker,
+ mountPointService, builderFactory, deviceActionFactory, baseSchemas);
}
void disconnectNode(final NodeId nodeId) {
import java.net.UnknownHostException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
-import java.util.concurrent.ScheduledExecutorService;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@Mock
private Timer mockTimer;
@Mock
- private ScheduledExecutorService mockScheduledExecutor;
- @Mock
private Executor mockProcessingExecutor;
@Mock
private SchemaResourceManager mockSchemaRepoProvider;
public void setup() {
topologyId = "";
- instance = new CallHomeMountFactory(topologyId, mockTimer, mockScheduledExecutor, mockProcessingExecutor,
- mockSchemaRepoProvider, mockBaseSchemas, mockDataBroker, mockMount, mockBuilderFactory) {
+ instance = new CallHomeMountFactory(topologyId, mockTimer, mockProcessingExecutor, mockSchemaRepoProvider,
+ mockBaseSchemas, mockDataBroker, mockMount, mockBuilderFactory) {
@Override
CallHomeMountSessionManager sessionManager() {
return mockSessMgr;
import io.netty.util.Timer;
import java.util.Collection;
import java.util.concurrent.Executor;
-import java.util.concurrent.ScheduledExecutorService;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.opendaylight.aaa.encrypt.AAAEncryptionService;
-import org.opendaylight.controller.config.threadpool.ScheduledThreadPool;
import org.opendaylight.controller.config.threadpool.ThreadPool;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
public NetconfTopologyImpl(
@Reference(target = "(type=netconf-client-factory)") final NetconfClientFactory clientFactory,
@Reference(target = "(type=global-timer)") final Timer timer,
- @Reference(target = "(type=global-netconf-ssh-scheduled-executor)")
- final ScheduledThreadPool scheduledThreadPool,
@Reference(target = "(type=global-netconf-processing-executor)") final ThreadPool processingThreadPool,
@Reference final SchemaResourceManager schemaRepositoryProvider, @Reference final DataBroker dataBroker,
@Reference final DOMMountPointService mountPointService,
@Reference(target = "(type=default)") final NetconfClientConfigurationBuilderFactory builderFactory,
@Reference final RpcProviderService rpcProviderService, @Reference final BaseNetconfSchemas baseSchemas,
@Reference final DeviceActionFactory deviceActionFactory) {
- this(NetconfNodeUtils.DEFAULT_TOPOLOGY_NAME, clientFactory, timer, scheduledThreadPool.getExecutor(),
- processingThreadPool.getExecutor(), schemaRepositoryProvider, dataBroker, mountPointService,
- encryptionService, builderFactory, rpcProviderService, baseSchemas, deviceActionFactory);
+ this(NetconfNodeUtils.DEFAULT_TOPOLOGY_NAME, clientFactory, timer, processingThreadPool.getExecutor(),
+ schemaRepositoryProvider, dataBroker, mountPointService, encryptionService, builderFactory,
+ rpcProviderService, baseSchemas, deviceActionFactory);
}
public NetconfTopologyImpl(final String topologyId, final NetconfClientFactory clientclientFactory,
- final Timer timer, final ScheduledExecutorService scheduledExecutor, final Executor processingExecutor,
- final SchemaResourceManager schemaRepositoryProvider, final DataBroker dataBroker,
- final DOMMountPointService mountPointService, final AAAEncryptionService encryptionService,
- final NetconfClientConfigurationBuilderFactory builderFactory, final RpcProviderService rpcProviderService,
- final BaseNetconfSchemas baseSchemas) {
- this(topologyId, clientclientFactory, timer, scheduledExecutor, processingExecutor, schemaRepositoryProvider,
- dataBroker, mountPointService, encryptionService, builderFactory, rpcProviderService, baseSchemas, null);
+ final Timer timer, final Executor processingExecutor, final SchemaResourceManager schemaRepositoryProvider,
+ final DataBroker dataBroker, final DOMMountPointService mountPointService,
+ final AAAEncryptionService encryptionService, final NetconfClientConfigurationBuilderFactory builderFactory,
+ final RpcProviderService rpcProviderService, final BaseNetconfSchemas baseSchemas) {
+ this(topologyId, clientclientFactory, timer, processingExecutor, schemaRepositoryProvider, dataBroker,
+ mountPointService, encryptionService, builderFactory, rpcProviderService, baseSchemas, null);
}
@SuppressFBWarnings(value = "MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR",
justification = "DTCL registration of 'this'")
public NetconfTopologyImpl(final String topologyId, final NetconfClientFactory clientFactory, final Timer timer,
- final ScheduledExecutorService scheduledExecutor, final Executor processingExecutor,
- final SchemaResourceManager schemaRepositoryProvider, final DataBroker dataBroker,
- final DOMMountPointService mountPointService, final AAAEncryptionService encryptionService,
- final NetconfClientConfigurationBuilderFactory builderFactory, final RpcProviderService rpcProviderService,
- final BaseNetconfSchemas baseSchemas, final DeviceActionFactory deviceActionFactory) {
- super(topologyId, clientFactory, timer, scheduledExecutor, processingExecutor,
- schemaRepositoryProvider, dataBroker, mountPointService, builderFactory, deviceActionFactory, baseSchemas);
+ final Executor processingExecutor, final SchemaResourceManager schemaRepositoryProvider,
+ final DataBroker dataBroker, final DOMMountPointService mountPointService,
+ final AAAEncryptionService encryptionService, final NetconfClientConfigurationBuilderFactory builderFactory,
+ final RpcProviderService rpcProviderService, final BaseNetconfSchemas baseSchemas,
+ final DeviceActionFactory deviceActionFactory) {
+ super(topologyId, clientFactory, timer, processingExecutor, schemaRepositoryProvider, dataBroker,
+ mountPointService, builderFactory, deviceActionFactory, baseSchemas);
LOG.debug("Registering datastore listener");
dtclReg = dataBroker.registerDataTreeChangeListener(DataTreeIdentifier.create(
import io.netty.util.Timer;
import java.util.List;
import java.util.concurrent.Executor;
-import java.util.concurrent.ScheduledExecutorService;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
@Mock
private Timer mockedTimer;
@Mock
- private ScheduledExecutorService mockedScheduledExecutor;
- @Mock
private SchemaResourceManager mockedResourceManager;
@Mock
private DataBroker dataBroker;
doReturn(CommitInfo.emptyFluentFuture()).when(wtx).commit();
topology = new TestingNetconfTopologyImpl(TOPOLOGY_KEY.getTopologyId().getValue(), mockedClientFactory,
- mockedTimer, mockedScheduledExecutor, MoreExecutors.directExecutor(), mockedResourceManager, dataBroker,
- mountPointService, encryptionService, builderFactory, rpcProviderService,
+ mockedTimer, MoreExecutors.directExecutor(), mockedResourceManager, dataBroker, mountPointService,
+ encryptionService, builderFactory, rpcProviderService,
new DefaultBaseNetconfSchemas(new DefaultYangParserFactory()));
//verify initialization of topology
verify(wtx).merge(LogicalDatastoreType.OPERATIONAL, TOPOLOGY_PATH,
private static class TestingNetconfTopologyImpl extends NetconfTopologyImpl {
TestingNetconfTopologyImpl(final String topologyId, final NetconfClientFactory clientFactory, final Timer timer,
- final ScheduledExecutorService scheduledExecutor, final Executor processingExecutor,
- final SchemaResourceManager schemaRepositoryProvider, final DataBroker dataBroker,
- final DOMMountPointService mountPointService, final AAAEncryptionService encryptionService,
+ final Executor processingExecutor, final SchemaResourceManager schemaRepositoryProvider,
+ final DataBroker dataBroker, final DOMMountPointService mountPointService,
+ final AAAEncryptionService encryptionService,
final NetconfClientConfigurationBuilderFactory builderFactory,
final RpcProviderService rpcProviderService, final BaseNetconfSchemas baseSchemas) {
- super(topologyId, clientFactory, timer, scheduledExecutor, processingExecutor, schemaRepositoryProvider,
+ super(topologyId, clientFactory, timer, processingExecutor, schemaRepositoryProvider,
dataBroker, mountPointService, encryptionService, builderFactory, rpcProviderService, baseSchemas);
}
// Instantiate the handler ...
masterSalFacade = createSalFacade(netconfNode.requireLockDatastore());
- nodeHandler = new NetconfNodeHandler(setup.getNetconfClientFactory(), setup.getTimer(),
- setup.getKeepaliveExecutor(), setup.getBaseSchemas(), schemaManager, setup.getProcessingExecutor(),
- builderFactory, deviceActionFactory, masterSalFacade, remoteDeviceId, configNode.getNodeId(), netconfNode,
- nodeOptional);
+ nodeHandler = new NetconfNodeHandler(setup.getNetconfClientFactory(), setup.getTimer(), setup.getBaseSchemas(),
+ schemaManager, setup.getProcessingExecutor(), builderFactory, deviceActionFactory, masterSalFacade,
+ remoteDeviceId, configNode.getNodeId(), netconfNode, nodeOptional);
nodeHandler.connect();
}
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executor;
-import java.util.concurrent.ScheduledExecutorService;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.opendaylight.aaa.encrypt.AAAEncryptionService;
import org.opendaylight.controller.cluster.ActorSystemProvider;
-import org.opendaylight.controller.config.threadpool.ScheduledThreadPool;
import org.opendaylight.controller.config.threadpool.ThreadPool;
import org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener;
import org.opendaylight.mdsal.binding.api.DataBroker;
private final DataBroker dataBroker;
private final ClusterSingletonServiceProvider clusterSingletonServiceProvider;
private final Timer timer;
- private final ScheduledExecutorService keepaliveExecutor;
private final Executor processingExecutor;
private final ActorSystem actorSystem;
private final NetconfClientFactory clientFactory;
@Reference final DataBroker dataBroker,
@Reference final ClusterSingletonServiceProvider clusterSingletonServiceProvider,
@Reference(target = "(type=global-timer)") final Timer timer,
- @Reference(target = "(type=global-netconf-ssh-scheduled-executor)")
- final ScheduledThreadPool keepaliveExecutor,
@Reference(target = "(type=global-netconf-processing-executor)") final ThreadPool processingExecutor,
@Reference final ActorSystemProvider actorSystemProvider,
@Reference(target = "(type=netconf-client-factory)") final NetconfClientFactory clientFactory,
@Reference final SchemaResourceManager resourceManager,
@Reference final NetconfClientConfigurationBuilderFactory builderFactory,
final Configuration configuration) {
- this(baseSchemas, dataBroker, clusterSingletonServiceProvider, timer, keepaliveExecutor.getExecutor(),
- processingExecutor.getExecutor(), actorSystemProvider.getActorSystem(), clientFactory, mountPointService,
- encryptionService, rpcProviderService, deviceActionFactory, resourceManager, builderFactory,
- configuration.topology$_$id(), Uint16.valueOf(configuration.write$_$transaction$_$idle$_$timeout()));
+ this(baseSchemas, dataBroker, clusterSingletonServiceProvider, timer, processingExecutor.getExecutor(),
+ actorSystemProvider.getActorSystem(), clientFactory, mountPointService, encryptionService,
+ rpcProviderService, deviceActionFactory, resourceManager, builderFactory, configuration.topology$_$id(),
+ Uint16.valueOf(configuration.write$_$transaction$_$idle$_$timeout()));
}
@Inject
public NetconfTopologyManager(final BaseNetconfSchemas baseSchemas, final DataBroker dataBroker,
final ClusterSingletonServiceProvider clusterSingletonServiceProvider, final Timer timer,
- final ScheduledThreadPool keepaliveExecutor, final ThreadPool processingExecutor,
- final ActorSystemProvider actorSystemProvider, final NetconfClientFactory clientFactory,
- final DOMMountPointService mountPointService, final AAAEncryptionService encryptionService,
- final RpcProviderService rpcProviderService, final DeviceActionFactory deviceActionFactory,
- final SchemaResourceManager resourceManager,
+ final ThreadPool processingExecutor, final ActorSystemProvider actorSystemProvider,
+ final NetconfClientFactory clientFactory, final DOMMountPointService mountPointService,
+ final AAAEncryptionService encryptionService, final RpcProviderService rpcProviderService,
+ final DeviceActionFactory deviceActionFactory, final SchemaResourceManager resourceManager,
final NetconfClientConfigurationBuilderFactory builderFactory) {
- this(baseSchemas, dataBroker, clusterSingletonServiceProvider, timer, keepaliveExecutor.getExecutor(),
- processingExecutor.getExecutor(), actorSystemProvider.getActorSystem(), clientFactory,
- mountPointService, encryptionService, rpcProviderService, deviceActionFactory, resourceManager,
- builderFactory, NetconfNodeUtils.DEFAULT_TOPOLOGY_NAME, Uint16.ZERO);
+ this(baseSchemas, dataBroker, clusterSingletonServiceProvider, timer, processingExecutor.getExecutor(),
+ actorSystemProvider.getActorSystem(), clientFactory, mountPointService, encryptionService,
+ rpcProviderService, deviceActionFactory, resourceManager, builderFactory,
+ NetconfNodeUtils.DEFAULT_TOPOLOGY_NAME, Uint16.ZERO);
}
@SuppressFBWarnings(value = "MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR",
justification = "Non-final for mocking, but we register for DTCL and that leaks 'this'")
public NetconfTopologyManager(final BaseNetconfSchemas baseSchemas, final DataBroker dataBroker,
final ClusterSingletonServiceProvider clusterSingletonServiceProvider, final Timer timer,
- final ScheduledExecutorService keepaliveExecutor, final Executor processingExecutor,
- final ActorSystem actorSystem, final NetconfClientFactory clientFactory,
+ final Executor processingExecutor, final ActorSystem actorSystem, final NetconfClientFactory clientFactory,
final DOMMountPointService mountPointService, final AAAEncryptionService encryptionService,
final RpcProviderService rpcProviderService, final DeviceActionFactory deviceActionFactory,
final SchemaResourceManager resourceManager, final NetconfClientConfigurationBuilderFactory builderFactory,
this.dataBroker = requireNonNull(dataBroker);
this.clusterSingletonServiceProvider = requireNonNull(clusterSingletonServiceProvider);
this.timer = requireNonNull(timer);
- this.keepaliveExecutor = requireNonNull(keepaliveExecutor);
this.processingExecutor = requireNonNull(processingExecutor);
this.actorSystem = requireNonNull(actorSystem);
this.clientFactory = requireNonNull(clientFactory);
.setNode(node)
.setActorSystem(actorSystem)
.setTimer(timer)
- .setKeepaliveExecutor(keepaliveExecutor)
.setProcessingExecutor(processingExecutor)
.setTopologyId(topologyId)
.setNetconfClientFactory(clientFactory)
import io.netty.util.Timer;
import java.time.Duration;
import java.util.concurrent.Executor;
-import java.util.concurrent.ScheduledExecutorService;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
private final InstanceIdentifier<Node> instanceIdentifier;
private final Node node;
private final Timer timer;
- private final ScheduledExecutorService keepaliveExecutor;
private final Executor processingExecutor;
private final ActorSystem actorSystem;
private final NetconfClientFactory netconfClientFactory;
instanceIdentifier = builder.getInstanceIdentifier();
node = builder.getNode();
timer = builder.getTimer();
- keepaliveExecutor = builder.getKeepaliveExecutor();
processingExecutor = builder.getProcessingExecutor();
actorSystem = builder.getActorSystem();
netconfClientFactory = builder.getNetconfClientFactory();
return processingExecutor;
}
- public ScheduledExecutorService getKeepaliveExecutor() {
- return keepaliveExecutor;
- }
-
public Timer getTimer() {
return timer;
}
private InstanceIdentifier<Node> instanceIdentifier;
private Node node;
private Timer timer;
- private ScheduledExecutorService keepaliveExecutor;
private Executor processingExecutor;
private ActorSystem actorSystem;
private String topologyId;
return this;
}
- ScheduledExecutorService getKeepaliveExecutor() {
- return keepaliveExecutor;
- }
-
- public Builder setKeepaliveExecutor(final ScheduledExecutorService keepaliveExecutor) {
- this.keepaliveExecutor = keepaliveExecutor;
- return this;
- }
-
Executor getProcessingExecutor() {
return processingExecutor;
}
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.apache.commons.io.FileUtils;
@Mock
private Timer mockTimer;
@Mock
- private ScheduledExecutorService mockKeepaliveExecutor;
- @Mock
private DeviceActionFactory deviceActionFactory;
@Mock
private CredentialProvider credentialProvider;
YangTextSchemaSource.class, 1));
masterNetconfTopologyManager = new NetconfTopologyManager(BASE_SCHEMAS, masterDataBroker,
- masterClusterSingletonServiceProvider, mockTimer, mockKeepaliveExecutor, MoreExecutors.directExecutor(),
- masterSystem, mockClientFactory, masterMountPointService, mockEncryptionService, mockRpcProviderService,
+ masterClusterSingletonServiceProvider, mockTimer, MoreExecutors.directExecutor(), masterSystem,
+ mockClientFactory, masterMountPointService, mockEncryptionService, mockRpcProviderService,
deviceActionFactory, resourceManager, builderFactory, TOPOLOGY_ID, Uint16.ZERO) {
@Override
protected NetconfTopologyContext newNetconfTopologyContext(final NetconfTopologySetup setup,
.registerClusterSingletonService(any());
slaveNetconfTopologyManager = new NetconfTopologyManager(BASE_SCHEMAS, slaveDataBroker,
- mockSlaveClusterSingletonServiceProvider, mockTimer, mockKeepaliveExecutor,
- MoreExecutors.directExecutor(), slaveSystem, mockClientFactory, slaveMountPointService,
- mockEncryptionService, mockRpcProviderService, deviceActionFactory, resourceManager, builderFactory,
- TOPOLOGY_ID, Uint16.ZERO) {
+ mockSlaveClusterSingletonServiceProvider, mockTimer, MoreExecutors.directExecutor(), slaveSystem,
+ mockClientFactory, slaveMountPointService, mockEncryptionService, mockRpcProviderService,
+ deviceActionFactory, resourceManager, builderFactory, TOPOLOGY_ID, Uint16.ZERO) {
@Override
protected NetconfTopologyContext newNetconfTopologyContext(final NetconfTopologySetup setup,
final ServiceGroupIdentifier serviceGroupIdent, final Timeout actorResponseWaitTime,
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ExecutorService;
-import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import org.junit.Before;
@RunWith(MockitoJUnitRunner.StrictStubs.class)
public class NetconfTopologyManagerTest extends AbstractBaseSchemasTest {
- private static final Uint16 ACTOR_RESPONSE_WAIT_TIME = Uint16.valueOf(10);
+ private static final Uint16 ACTOR_RESPONSE_WAIT_TIME = Uint16.TEN;
private static final String TOPOLOGY_ID = "topologyID";
private NetconfTopologyManager netconfTopologyManager;
private ListenerRegistration<?> mockListenerReg;
@Mock
private Registration mockRpcReg;
+ @Mock
+ private Timer timer;
+ @Mock
+ private ExecutorService processingService;
+ @Mock
+ private ActorSystem actorSystem;
+ @Mock
+ private NetconfClientFactory clientFactory;
+ @Mock
+ private DOMMountPointService mountPointService;
+ @Mock
+ private AAAEncryptionService encryptionService;
+ @Mock
+ private DeviceActionFactory actionFactory;
+ @Mock
+ private RpcProviderService rpcProviderService;
+ @Mock
+ private NetconfClientConfigurationBuilderFactory builderFactory;
private DataBroker dataBroker;
dataBrokerTest.setup();
dataBroker = spy(dataBrokerTest.getDataBroker());
- final Timer timer = mock(Timer.class);
- final ScheduledExecutorService keepaliveExecutor = mock(ScheduledExecutorService.class);
- final ExecutorService processingService = mock(ExecutorService.class);
- final ActorSystem actorSystem = mock(ActorSystem.class);
- final NetconfClientFactory clientFactory = mock(NetconfClientFactory.class);
- final DOMMountPointService mountPointService = mock(DOMMountPointService.class);
- final AAAEncryptionService encryptionService = mock(AAAEncryptionService.class);
- final DeviceActionFactory deviceActionFactory = mock(DeviceActionFactory.class);
- final RpcProviderService rpcProviderService = mock(RpcProviderService.class);
- final NetconfClientConfigurationBuilderFactory builderFactory =
- mock(NetconfClientConfigurationBuilderFactory.class);
-
doNothing().when(mockListenerReg).close();
doReturn(mockListenerReg).when(dataBroker).registerDataTreeChangeListener(any(), any());
doReturn(mockRpcReg).when(rpcProviderService).registerRpcImplementations(any());
netconfTopologyManager = new NetconfTopologyManager(BASE_SCHEMAS, dataBroker, clusterSingletonServiceProvider,
- timer, keepaliveExecutor, processingService, actorSystem, clientFactory, mountPointService,
- encryptionService, rpcProviderService, deviceActionFactory,
- new DefaultSchemaResourceManager(new DefaultYangParserFactory()), builderFactory,
- TOPOLOGY_ID, Uint16.ZERO) {
+ timer, processingService, actorSystem, clientFactory, mountPointService, encryptionService,
+ rpcProviderService, actionFactory, new DefaultSchemaResourceManager(new DefaultYangParserFactory()),
+ builderFactory, TOPOLOGY_ID, Uint16.ZERO) {
@Override
protected NetconfTopologyContext newNetconfTopologyContext(final NetconfTopologySetup setup,
final ServiceGroupIdentifier serviceGroupIdent, final Timeout actorResponseWaitTime,
import java.util.NoSuchElementException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
-import java.util.concurrent.ScheduledExecutorService;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.mdsal.dom.api.DOMMountPointService;
private final NetconfClientConfigurationBuilderFactory builderFactory;
private final Timer timer;
- protected final ScheduledExecutorService scheduledExecutor;
protected final Executor processingExecutor;
protected final DataBroker dataBroker;
protected final DOMMountPointService mountPointService;
protected final String topologyId;
protected AbstractNetconfTopology(final String topologyId, final NetconfClientFactory clientFactory,
- final Timer timer, final ScheduledExecutorService scheduledExecutor, final Executor processingExecutor,
- final SchemaResourceManager schemaManager, final DataBroker dataBroker,
- final DOMMountPointService mountPointService, final NetconfClientConfigurationBuilderFactory builderFactory,
+ final Timer timer, final Executor processingExecutor, final SchemaResourceManager schemaManager,
+ final DataBroker dataBroker, final DOMMountPointService mountPointService,
+ final NetconfClientConfigurationBuilderFactory builderFactory,
final DeviceActionFactory deviceActionFactory, final BaseNetconfSchemas baseSchemas) {
this.topologyId = requireNonNull(topologyId);
this.clientFactory = requireNonNull(clientFactory);
this.timer = requireNonNull(timer);
- this.scheduledExecutor = requireNonNull(scheduledExecutor);
this.processingExecutor = requireNonNull(processingExecutor);
this.schemaManager = requireNonNull(schemaManager);
this.deviceActionFactory = deviceActionFactory;
final NetconfNodeHandler nodeHandler;
try {
- nodeHandler = new NetconfNodeHandler(clientFactory, timer, scheduledExecutor, baseSchemas,
- schemaManager, processingExecutor, builderFactory, deviceActionFactory, deviceSalFacade,
- deviceId, nodeId, netconfNode, nodeOptional);
+ nodeHandler = new NetconfNodeHandler(clientFactory, timer, baseSchemas, schemaManager, processingExecutor,
+ builderFactory, deviceActionFactory, deviceSalFacade, deviceId, nodeId, netconfNode, nodeOptional);
} catch (IllegalArgumentException e) {
// This is a workaround for NETCONF-1114 where the encrypted password's lexical structure is not enforced
// in the datastore and it ends up surfacing when we decrypt the password.
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
+import io.netty.util.Timeout;
import io.netty.util.Timer;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CancellationException;
import java.util.concurrent.Executor;
-import java.util.concurrent.Future;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import org.checkerframework.checker.lock.qual.GuardedBy;
import org.checkerframework.checker.lock.qual.Holding;
*/
public final class NetconfNodeHandler extends AbstractRegistration implements RemoteDeviceHandler {
private abstract static sealed class Task {
- private final Future<?> future;
- Task(final Future<?> future) {
- this.future = requireNonNull(future);
- }
-
- final void cancel() {
- future.cancel(false);
- }
+ abstract void cancel();
}
private final class ConnectingTask extends Task implements FutureCallback<NetconfClientSession> {
+ private final ListenableFuture<NetconfClientSession> future;
+
ConnectingTask(final ListenableFuture<NetconfClientSession> future) {
- super(future);
+ this.future = requireNonNull(future);
+ }
+
+ @Override
+ void cancel() {
+ future.cancel(false);
}
@Override
}
private static final class SleepingTask extends Task {
- SleepingTask(final ScheduledFuture<?> future) {
- super(future);
+ private final Timeout timeout;
+
+ SleepingTask(final Timeout timeout) {
+ this.timeout = requireNonNull(timeout);
+ }
+
+ @Override
+ void cancel() {
+ timeout.cancel();
}
}
private final @NonNull NetconfClientConfiguration clientConfig;
private final @NonNull NetconfDeviceCommunicator communicator;
private final @NonNull RemoteDeviceHandler delegate;
- private final @NonNull ScheduledExecutorService scheduledExecutor;
+ private final @NonNull Timer timer;
private final @NonNull RemoteDeviceId deviceId;
private final long maxAttempts;
private Task currentTask;
public NetconfNodeHandler(final NetconfClientFactory clientFactory, final Timer timer,
- final ScheduledExecutorService scheduledExecutor, final BaseNetconfSchemas baseSchemas,
- final SchemaResourceManager schemaManager, final Executor processingExecutor,
- final NetconfClientConfigurationBuilderFactory builderFactory,
+ final BaseNetconfSchemas baseSchemas, final SchemaResourceManager schemaManager,
+ final Executor processingExecutor, final NetconfClientConfigurationBuilderFactory builderFactory,
final DeviceActionFactory deviceActionFactory, final RemoteDeviceHandler delegate,
final RemoteDeviceId deviceId, final NodeId nodeId, final NetconfNode node,
final NetconfNodeAugmentedOptional nodeOptional) {
this.clientFactory = requireNonNull(clientFactory);
- this.scheduledExecutor = requireNonNull(scheduledExecutor);
+ this.timer = requireNonNull(timer);
this.delegate = requireNonNull(delegate);
this.deviceId = requireNonNull(deviceId);
// immediate reconnect. While we could check and got to lockedConnect(), it makes for a rare special case.
// That special case makes for more code paths to test and introduces additional uncertainty as to whether
// the attempt was executed on this thread or not.
- currentTask = new SleepingTask(scheduledExecutor.schedule(this::reconnect, delayMillis, TimeUnit.MILLISECONDS));
+ currentTask = new SleepingTask(timer.newTimeout(this::reconnect, delayMillis, TimeUnit.MILLISECONDS));
return null;
}
- private synchronized void reconnect() {
+ private synchronized void reconnect(final Timeout timeout) {
currentTask = null;
if (notClosed()) {
lockedConnect();
import com.google.common.net.InetAddresses;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.SettableFuture;
+import io.netty.util.Timeout;
import io.netty.util.Timer;
+import io.netty.util.TimerTask;
import java.net.InetSocketAddress;
import java.util.List;
import java.util.concurrent.Executor;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import org.junit.Before;
import org.junit.BeforeClass;
@Mock
private Timer timer;
@Mock
- private ScheduledExecutorService scheduledExecutor;
- @Mock
private SchemaResourceManager schemaManager;
@Mock
private Executor processingExecutor;
@Captor
private ArgumentCaptor<RemoteDeviceServices> servicesCaptor;
- // Mock eventExecutor-related things
+ // Mock Timer-related things
@Mock
- private ScheduledFuture<?> scheduleFuture;
+ private Timeout timeout;
@Captor
- private ArgumentCaptor<Runnable> scheduleCaptor;
+ private ArgumentCaptor<TimerTask> timerCaptor;
@Mock
private EffectiveModelContext schemaContext;
@Before
public void before() {
// Instantiate the handler
- handler = new NetconfNodeHandler(clientFactory, timer, scheduledExecutor, BASE_SCHEMAS,
- schemaManager, processingExecutor,
+ handler = new NetconfNodeHandler(clientFactory, timer, BASE_SCHEMAS, schemaManager, processingExecutor,
new DefaultNetconfClientConfigurationBuilderFactory(encryptionService, credentialProvider,
sslHandlerFactoryProvider),
deviceActionFactory, delegate, DEVICE_ID, NODE_ID, new NetconfNodeBuilder()
assertEquals(1, handler.attempts());
// Note: this will count as a second attempt
- doReturn(scheduleFuture).when(scheduledExecutor)
- .schedule(scheduleCaptor.capture(), anyLong(), any(TimeUnit.class));
+ doReturn(timeout).when(timer).newTimeout(timerCaptor.capture(), anyLong(), any());
handler.onDeviceFailed(new AssertionError("schema failure"));
assertEquals(2, handler.attempts());
// and when we run the task, we get a clientDispatcher invocation, but attempts are still the same
- scheduleCaptor.getValue().run();
+ timerCaptor.getValue().run(timeout);
verify(clientFactory, times(2)).createClient(any());
assertEquals(2, handler.attempts());
}
// when the device is connected, we propagate the information and initiate reconnect
doNothing().when(delegate).onDeviceDisconnected();
- doReturn(scheduleFuture).when(scheduledExecutor).schedule(scheduleCaptor.capture(), eq(100L),
- eq(TimeUnit.MILLISECONDS));
+ doReturn(timeout).when(timer).newTimeout(timerCaptor.capture(), eq(100L), eq(TimeUnit.MILLISECONDS));
handler.onDeviceDisconnected();
assertEquals(1, handler.attempts());
// and when we run the task, we get a clientDispatcher invocation, but attempts are still the same
- scheduleCaptor.getValue().run();
+ timerCaptor.getValue().run(timeout);
verify(clientFactory, times(2)).createClient(any());
assertEquals(1, handler.attempts());
}
handler.connect();
assertEquals(1, handler.attempts());
- doReturn(scheduleFuture).when(scheduledExecutor).schedule(scheduleCaptor.capture(), eq(150L),
- eq(TimeUnit.MILLISECONDS));
+ doReturn(timeout).when(timer).newTimeout(timerCaptor.capture(), eq(150L), eq(TimeUnit.MILLISECONDS));
firstFuture.setException(new AssertionError("first"));
assertEquals(2, handler.attempts());
// and when we run the task, we get a clientDispatcher invocation, but attempts are still the same
- scheduleCaptor.getValue().run();
+ timerCaptor.getValue().run(timeout);
verify(clientFactory, times(2)).createClient(any());
assertEquals(2, handler.attempts());