From: Robert Varga Date: Tue, 4 Jul 2023 16:34:00 +0000 (+0200) Subject: Use simple Executor in NetconfDevice X-Git-Tag: v6.0.0~6 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=c3da9ed1522f6172a2ccdd13fc72f739b23bbbda;p=netconf.git Use simple Executor in NetconfDevice Passing down ListenableExecutorService ends up being interesting, as it is not clear what the actual lifecycle is. Luckily we can get by using a simple Executor with Futures.submit(), which essentially performs the same task. This makes it clear that the service is not touched by anyone in the stack and we can use any old Executor -- to the point of using directExecutor() in NetconfDeviceTest. Change-Id: I31fcfcb7b303046935392bffd6d50c8f83ec33a2 Signed-off-by: Robert Varga --- diff --git a/apps/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/NetconfNodeContext.java b/apps/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/NetconfNodeContext.java index ea407fd9ed..dbbf12bdcb 100644 --- a/apps/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/NetconfNodeContext.java +++ b/apps/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/NetconfNodeContext.java @@ -15,9 +15,8 @@ import akka.dispatch.OnComplete; import akka.pattern.Patterns; import akka.util.Timeout; import com.google.common.annotations.VisibleForTesting; -import com.google.common.util.concurrent.ListeningExecutorService; -import com.google.common.util.concurrent.MoreExecutors; import io.netty.util.concurrent.EventExecutor; +import java.util.concurrent.Executor; import org.opendaylight.controller.config.threadpool.ScheduledThreadPool; import org.opendaylight.controller.config.threadpool.ThreadPool; import org.opendaylight.mdsal.binding.api.DataBroker; @@ -48,7 +47,7 @@ final class NetconfNodeContext implements AutoCloseable { private final BaseNetconfSchemas baseSchemas; private final NetconfClientConfigurationBuilderFactory builderFactory; private final ScheduledThreadPool keepaliveExecutor; - private final ListeningExecutorService processingExecutor; + private final Executor processingExecutor; private final DataBroker dataBroker; private final DOMMountPointService mountPointService; private final RemoteDeviceId remoteDeviceId; @@ -70,8 +69,7 @@ final class NetconfNodeContext implements AutoCloseable { this.clientDispatcher = requireNonNull(clientDispatcher); this.eventExecutor = requireNonNull(eventExecutor); this.keepaliveExecutor = requireNonNull(keepaliveExecutor); - // FIXME: share a single instance! - this.processingExecutor = MoreExecutors.listeningDecorator(processingExecutor.getExecutor()); + this.processingExecutor = processingExecutor.getExecutor(); this.schemaManager = requireNonNull(schemaManager); this.dataBroker = requireNonNull(dataBroker); this.mountPointService = requireNonNull(mountPointService); diff --git a/apps/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/NetconfTopologyManager.java b/apps/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/NetconfTopologyManager.java index 04e452f783..228c94b730 100644 --- a/apps/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/NetconfTopologyManager.java +++ b/apps/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/NetconfTopologyManager.java @@ -13,13 +13,13 @@ import akka.actor.ActorSystem; import akka.util.Timeout; import com.google.common.annotations.VisibleForTesting; import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; import io.netty.util.concurrent.EventExecutor; import java.time.Duration; import java.util.Collection; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.Executor; import java.util.concurrent.ScheduledExecutorService; import org.opendaylight.aaa.encrypt.AAAEncryptionService; import org.opendaylight.controller.cluster.ActorSystemProvider; @@ -85,7 +85,7 @@ public class NetconfTopologyManager private final ScheduledThreadPool keepaliveExecutor; private final ScheduledExecutorService keepaliveExecutorService; private final ThreadPool processingExecutor; - private final ListeningExecutorService processingExecutorService; + private final Executor processingExecutorService; private final ActorSystem actorSystem; private final EventExecutor eventExecutor; private final NetconfClientDispatcher clientDispatcher; @@ -124,7 +124,7 @@ public class NetconfTopologyManager this.keepaliveExecutor = keepaliveExecutor; keepaliveExecutorService = keepaliveExecutor.getExecutor(); this.processingExecutor = processingExecutor; - processingExecutorService = MoreExecutors.listeningDecorator(processingExecutor.getExecutor()); + processingExecutorService = processingExecutor.getExecutor(); actorSystem = requireNonNull(actorSystemProvider).getActorSystem(); this.eventExecutor = requireNonNull(eventExecutor); this.clientDispatcher = requireNonNull(clientDispatcher); diff --git a/apps/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/utils/NetconfTopologySetup.java b/apps/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/utils/NetconfTopologySetup.java index 7a0f3c0d99..ecc8239cb3 100644 --- a/apps/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/utils/NetconfTopologySetup.java +++ b/apps/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/utils/NetconfTopologySetup.java @@ -10,9 +10,9 @@ package org.opendaylight.netconf.topology.singleton.impl.utils; import static java.util.Objects.requireNonNull; import akka.actor.ActorSystem; -import com.google.common.util.concurrent.ListeningExecutorService; import io.netty.util.concurrent.EventExecutor; import java.time.Duration; +import java.util.concurrent.Executor; import java.util.concurrent.ScheduledExecutorService; import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.mdsal.dom.api.DOMActionProviderService; @@ -32,7 +32,7 @@ public class NetconfTopologySetup { private final InstanceIdentifier instanceIdentifier; private final Node node; private final ScheduledExecutorService keepaliveExecutor; - private final ListeningExecutorService processingExecutor; + private final Executor processingExecutor; private final ActorSystem actorSystem; private final EventExecutor eventExecutor; private final NetconfClientDispatcher netconfClientDispatcher; @@ -83,7 +83,7 @@ public class NetconfTopologySetup { return node; } - public ListeningExecutorService getProcessingExecutor() { + public Executor getProcessingExecutor() { return processingExecutor; } @@ -127,7 +127,7 @@ public class NetconfTopologySetup { private InstanceIdentifier instanceIdentifier; private Node node; private ScheduledExecutorService keepaliveExecutor; - private ListeningExecutorService processingExecutor; + private Executor processingExecutor; private ActorSystem actorSystem; private EventExecutor eventExecutor; private String topologyId; @@ -218,11 +218,11 @@ public class NetconfTopologySetup { return this; } - ListeningExecutorService getProcessingExecutor() { + Executor getProcessingExecutor() { return processingExecutor; } - public NetconfTopologySetupBuilder setProcessingExecutor(final ListeningExecutorService processingExecutor) { + public NetconfTopologySetupBuilder setProcessingExecutor(final Executor processingExecutor) { this.processingExecutor = processingExecutor; return this; } diff --git a/apps/netconf-topology/src/main/java/org/opendaylight/netconf/topology/spi/AbstractNetconfTopology.java b/apps/netconf-topology/src/main/java/org/opendaylight/netconf/topology/spi/AbstractNetconfTopology.java index 931f716167..8fef25b22e 100644 --- a/apps/netconf-topology/src/main/java/org/opendaylight/netconf/topology/spi/AbstractNetconfTopology.java +++ b/apps/netconf-topology/src/main/java/org/opendaylight/netconf/topology/spi/AbstractNetconfTopology.java @@ -10,11 +10,11 @@ package org.opendaylight.netconf.topology.spi; import static java.util.Objects.requireNonNull; import com.google.common.annotations.VisibleForTesting; -import com.google.common.util.concurrent.ListeningExecutorService; -import com.google.common.util.concurrent.MoreExecutors; import io.netty.util.concurrent.EventExecutor; import java.util.HashMap; import java.util.concurrent.ExecutionException; +import java.util.concurrent.Executor; +import java.util.concurrent.ScheduledExecutorService; import org.checkerframework.checker.lock.qual.Holding; import org.opendaylight.controller.config.threadpool.ScheduledThreadPool; import org.opendaylight.controller.config.threadpool.ThreadPool; @@ -51,8 +51,8 @@ public abstract class AbstractNetconfTopology { private final BaseNetconfSchemas baseSchemas; private final NetconfClientConfigurationBuilderFactory builderFactory; - protected final ScheduledThreadPool keepaliveExecutor; - protected final ListeningExecutorService processingExecutor; + protected final ScheduledExecutorService keepaliveExecutor; + protected final Executor processingExecutor; protected final DataBroker dataBroker; protected final DOMMountPointService mountPointService; protected final String topologyId; @@ -65,8 +65,8 @@ public abstract class AbstractNetconfTopology { this.topologyId = requireNonNull(topologyId); this.clientDispatcher = clientDispatcher; this.eventExecutor = eventExecutor; - this.keepaliveExecutor = keepaliveExecutor; - this.processingExecutor = MoreExecutors.listeningDecorator(processingExecutor.getExecutor()); + this.keepaliveExecutor = keepaliveExecutor.getExecutor(); + this.processingExecutor = processingExecutor.getExecutor(); this.schemaManager = requireNonNull(schemaManager); this.deviceActionFactory = deviceActionFactory; this.dataBroker = requireNonNull(dataBroker); @@ -139,7 +139,7 @@ public abstract class AbstractNetconfTopology { // Instantiate the handler ... final var deviceId = NetconfNodeUtils.toRemoteDeviceId(nodeId, netconfNode); final var deviceSalFacade = createSalFacade(deviceId, netconfNode.requireLockDatastore()); - final var nodeHandler = new NetconfNodeHandler(clientDispatcher, eventExecutor, keepaliveExecutor.getExecutor(), + final var nodeHandler = new NetconfNodeHandler(clientDispatcher, eventExecutor, keepaliveExecutor, baseSchemas, schemaManager, processingExecutor, builderFactory, deviceActionFactory, deviceSalFacade, deviceId, nodeId, netconfNode, nodeOptional); diff --git a/apps/netconf-topology/src/main/java/org/opendaylight/netconf/topology/spi/NetconfNodeHandler.java b/apps/netconf-topology/src/main/java/org/opendaylight/netconf/topology/spi/NetconfNodeHandler.java index 9fa81131f1..d768f5842a 100644 --- a/apps/netconf-topology/src/main/java/org/opendaylight/netconf/topology/spi/NetconfNodeHandler.java +++ b/apps/netconf-topology/src/main/java/org/opendaylight/netconf/topology/spi/NetconfNodeHandler.java @@ -9,12 +9,12 @@ package org.opendaylight.netconf.topology.spi; import static java.util.Objects.requireNonNull; -import com.google.common.util.concurrent.ListeningExecutorService; import io.netty.util.concurrent.EventExecutor; import io.netty.util.concurrent.Future; import java.util.ArrayList; import java.util.List; import java.util.concurrent.CancellationException; +import java.util.concurrent.Executor; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import org.checkerframework.checker.lock.qual.GuardedBy; @@ -77,7 +77,7 @@ public final class NetconfNodeHandler extends AbstractRegistration implements Re public NetconfNodeHandler(final NetconfClientDispatcher clientDispatcher, final EventExecutor eventExecutor, final ScheduledExecutorService keepaliveExecutor, final BaseNetconfSchemas baseSchemas, - final SchemaResourceManager schemaManager, final ListeningExecutorService processingExecutor, + final SchemaResourceManager schemaManager, final Executor processingExecutor, final NetconfClientConfigurationBuilderFactory builderFactory, final DeviceActionFactory deviceActionFactory, final RemoteDeviceHandler delegate, final RemoteDeviceId deviceId, final NodeId nodeId, final NetconfNode node, diff --git a/plugins/netconf-client-mdsal/src/main/java/org/opendaylight/netconf/client/mdsal/NetconfDevice.java b/plugins/netconf-client-mdsal/src/main/java/org/opendaylight/netconf/client/mdsal/NetconfDevice.java index 9cf46db79b..9d9e4f1a6e 100644 --- a/plugins/netconf-client-mdsal/src/main/java/org/opendaylight/netconf/client/mdsal/NetconfDevice.java +++ b/plugins/netconf-client-mdsal/src/main/java/org/opendaylight/netconf/client/mdsal/NetconfDevice.java @@ -19,7 +19,6 @@ import com.google.common.collect.Sets; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; import com.google.common.util.concurrent.SettableFuture; import java.io.Serial; @@ -32,6 +31,7 @@ import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.concurrent.ExecutionException; +import java.util.concurrent.Executor; import java.util.stream.Collectors; import org.checkerframework.checker.lock.qual.GuardedBy; import org.eclipse.jdt.annotation.NonNull; @@ -83,7 +83,7 @@ public class NetconfDevice implements RemoteDevice { private static final QName RFC8528_SCHEMA_MOUNTS_QNAME = QName.create( SchemaMountConstants.RFC8528_MODULE, "schema-mounts").intern(); - private static final YangInstanceIdentifier RFC8528_SCHEMA_MOUNTS = YangInstanceIdentifier.create( + private static final YangInstanceIdentifier RFC8528_SCHEMA_MOUNTS = YangInstanceIdentifier.of( NodeIdentifier.create(RFC8528_SCHEMA_MOUNTS_QNAME)); protected final RemoteDeviceId id; @@ -94,7 +94,7 @@ public class NetconfDevice implements RemoteDevice { protected final List sourceRegistrations = new ArrayList<>(); private final RemoteDeviceHandler salFacade; - private final ListeningExecutorService processingExecutor; + private final Executor processingExecutor; private final DeviceActionFactory deviceActionFactory; private final NetconfDeviceSchemasResolver stateSchemasResolver; private final NotificationHandler notificationHandler; @@ -108,15 +108,14 @@ public class NetconfDevice implements RemoteDevice { private NetconfMessageTransformer messageTransformer; public NetconfDevice(final SchemaResourcesDTO schemaResourcesDTO, final BaseNetconfSchemas baseSchemas, - final RemoteDeviceId id, final RemoteDeviceHandler salFacade, - final ListeningExecutorService globalProcessingExecutor, final boolean reconnectOnSchemasChange) { + final RemoteDeviceId id, final RemoteDeviceHandler salFacade, final Executor globalProcessingExecutor, + final boolean reconnectOnSchemasChange) { this(schemaResourcesDTO, baseSchemas, id, salFacade, globalProcessingExecutor, reconnectOnSchemasChange, null); } public NetconfDevice(final SchemaResourcesDTO schemaResourcesDTO, final BaseNetconfSchemas baseSchemas, - final RemoteDeviceId id, final RemoteDeviceHandler salFacade, - final ListeningExecutorService globalProcessingExecutor, final boolean reconnectOnSchemasChange, - final DeviceActionFactory deviceActionFactory) { + final RemoteDeviceId id, final RemoteDeviceHandler salFacade, final Executor globalProcessingExecutor, + final boolean reconnectOnSchemasChange, final DeviceActionFactory deviceActionFactory) { this.baseSchemas = requireNonNull(baseSchemas); this.id = id; this.reconnectOnSchemasChange = reconnectOnSchemasChange; @@ -144,8 +143,9 @@ public class NetconfDevice implements RemoteDevice { final BaseSchema baseSchema = resolveBaseSchema(remoteSessionCapabilities.isNotificationsSupported()); final NetconfDeviceRpc initRpc = new NetconfDeviceRpc(baseSchema.getEffectiveModelContext(), listener, new NetconfMessageTransformer(baseSchema.getMountPointContext(), false, baseSchema)); - final ListenableFuture sourceResolverFuture = processingExecutor.submit( - new DeviceSourcesResolver(id, baseSchema, initRpc, remoteSessionCapabilities, stateSchemasResolver)); + final ListenableFuture sourceResolverFuture = Futures.submit( + new DeviceSourcesResolver(id, baseSchema, initRpc, remoteSessionCapabilities, stateSchemasResolver), + processingExecutor); if (shouldListenOnSchemaChange(remoteSessionCapabilities)) { registerToBaseNetconfStream(initRpc, listener); diff --git a/plugins/netconf-client-mdsal/src/main/java/org/opendaylight/netconf/client/mdsal/NetconfDeviceBuilder.java b/plugins/netconf-client-mdsal/src/main/java/org/opendaylight/netconf/client/mdsal/NetconfDeviceBuilder.java index 8207d81115..7ce98d0b75 100644 --- a/plugins/netconf-client-mdsal/src/main/java/org/opendaylight/netconf/client/mdsal/NetconfDeviceBuilder.java +++ b/plugins/netconf-client-mdsal/src/main/java/org/opendaylight/netconf/client/mdsal/NetconfDeviceBuilder.java @@ -9,7 +9,7 @@ package org.opendaylight.netconf.client.mdsal; import static java.util.Objects.requireNonNull; -import com.google.common.util.concurrent.ListeningExecutorService; +import java.util.concurrent.Executor; import org.opendaylight.netconf.client.mdsal.NetconfDevice.SchemaResourcesDTO; import org.opendaylight.netconf.client.mdsal.api.BaseNetconfSchemas; import org.opendaylight.netconf.client.mdsal.api.DeviceActionFactory; @@ -21,13 +21,10 @@ public class NetconfDeviceBuilder { private SchemaResourcesDTO schemaResourcesDTO; private RemoteDeviceId id; private RemoteDeviceHandler salFacade; - private ListeningExecutorService globalProcessingExecutor; + private Executor globalProcessingExecutor; private DeviceActionFactory deviceActionFactory; private BaseNetconfSchemas baseSchemas; - public NetconfDeviceBuilder() { - } - public NetconfDeviceBuilder setReconnectOnSchemasChange(final boolean reconnectOnSchemasChange) { this.reconnectOnSchemasChange = reconnectOnSchemasChange; return this; @@ -48,7 +45,7 @@ public class NetconfDeviceBuilder { return this; } - public NetconfDeviceBuilder setGlobalProcessingExecutor(final ListeningExecutorService globalProcessingExecutor) { + public NetconfDeviceBuilder setGlobalProcessingExecutor(final Executor globalProcessingExecutor) { this.globalProcessingExecutor = globalProcessingExecutor; return this; } diff --git a/plugins/netconf-client-mdsal/src/test/java/org/opendaylight/netconf/client/mdsal/NetconfDeviceTest.java b/plugins/netconf-client-mdsal/src/test/java/org/opendaylight/netconf/client/mdsal/NetconfDeviceTest.java index 99dff81d55..9b1acf1158 100644 --- a/plugins/netconf-client-mdsal/src/test/java/org/opendaylight/netconf/client/mdsal/NetconfDeviceTest.java +++ b/plugins/netconf-client-mdsal/src/test/java/org/opendaylight/netconf/client/mdsal/NetconfDeviceTest.java @@ -26,20 +26,16 @@ import static org.mockito.Mockito.verify; import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.Sets; import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; import com.google.common.util.concurrent.SettableFuture; import java.io.IOException; import java.net.InetSocketAddress; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.concurrent.Executors; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.opendaylight.mdsal.dom.api.DOMNotification; @@ -129,7 +125,7 @@ public class NetconfDeviceTest extends AbstractTestModelTest { final NetconfDevice device = new NetconfDeviceBuilder() .setReconnectOnSchemasChange(true) .setSchemaResourcesDTO(schemaResourcesDTO) - .setGlobalProcessingExecutor(getExecutor()) + .setGlobalProcessingExecutor(MoreExecutors.directExecutor()) .setId(getId()) .setSalFacade(facade) .setBaseSchemas(BASE_SCHEMAS) @@ -162,7 +158,7 @@ public class NetconfDeviceTest extends AbstractTestModelTest { final NetconfDevice device = new NetconfDeviceBuilder() .setReconnectOnSchemasChange(true) .setSchemaResourcesDTO(schemaResourcesDTO) - .setGlobalProcessingExecutor(getExecutor()) + .setGlobalProcessingExecutor(MoreExecutors.directExecutor()) .setId(getId()) .setSalFacade(facade) .setBaseSchemas(BASE_SCHEMAS) @@ -214,7 +210,7 @@ public class NetconfDeviceTest extends AbstractTestModelTest { final NetconfDevice device = new NetconfDeviceBuilder() .setReconnectOnSchemasChange(true) .setSchemaResourcesDTO(schemaResourcesDTO) - .setGlobalProcessingExecutor(getExecutor()) + .setGlobalProcessingExecutor(MoreExecutors.directExecutor()) .setBaseSchemas(BASE_SCHEMAS) .setId(getId()) .setSalFacade(facade) @@ -260,7 +256,7 @@ public class NetconfDeviceTest extends AbstractTestModelTest { final NetconfDevice device = new NetconfDeviceBuilder() .setReconnectOnSchemasChange(true) .setSchemaResourcesDTO(schemaResourcesDTO) - .setGlobalProcessingExecutor(getExecutor()) + .setGlobalProcessingExecutor(MoreExecutors.directExecutor()) .setId(getId()) .setSalFacade(facade) .setBaseSchemas(BASE_SCHEMAS) @@ -293,7 +289,7 @@ public class NetconfDeviceTest extends AbstractTestModelTest { final NetconfDevice device = new NetconfDeviceBuilder() .setReconnectOnSchemasChange(true) .setSchemaResourcesDTO(schemaResourcesDTO) - .setGlobalProcessingExecutor(getExecutor()) + .setGlobalProcessingExecutor(MoreExecutors.directExecutor()) .setId(getId()) .setSalFacade(facade) .setBaseSchemas(BASE_SCHEMAS) @@ -329,7 +325,7 @@ public class NetconfDeviceTest extends AbstractTestModelTest { final NetconfDevice device = new NetconfDeviceBuilder() .setReconnectOnSchemasChange(true) .setSchemaResourcesDTO(schemaResourcesDTO) - .setGlobalProcessingExecutor(getExecutor()) + .setGlobalProcessingExecutor(MoreExecutors.directExecutor()) .setId(getId()) .setSalFacade(facade) .setBaseSchemas(BASE_SCHEMAS) @@ -359,7 +355,7 @@ public class NetconfDeviceTest extends AbstractTestModelTest { final NetconfDevice device = new NetconfDeviceBuilder() .setReconnectOnSchemasChange(true) .setSchemaResourcesDTO(schemaResourcesDTO) - .setGlobalProcessingExecutor(getExecutor()) + .setGlobalProcessingExecutor(MoreExecutors.directExecutor()) .setId(getId()) .setSalFacade(facade) .setBaseSchemas(BASE_SCHEMAS) @@ -375,7 +371,7 @@ public class NetconfDeviceTest extends AbstractTestModelTest { netconfSpy.onRemoteSessionUp(sessionCaps.replaceModuleCaps(moduleBasedCaps), listener); - final ArgumentCaptor argument = ArgumentCaptor.forClass(NetconfDeviceSchema.class); + final ArgumentCaptor argument = ArgumentCaptor.forClass(NetconfDeviceSchema.class); verify(facade, timeout(5000)).onDeviceConnected(argument.capture(), any(NetconfSessionPreferences.class), any(RemoteDeviceServices.class)); argument.getValue().capabilities().resolvedCapabilities() @@ -394,7 +390,7 @@ public class NetconfDeviceTest extends AbstractTestModelTest { getSchemaRegistry(), getSchemaRepository(), schemaContextProviderFactory, STATE_SCHEMAS_RESOLVER); final NetconfDevice device = new NetconfDeviceBuilder() .setSchemaResourcesDTO(schemaResourcesDTO) - .setGlobalProcessingExecutor(getExecutor()) + .setGlobalProcessingExecutor(MoreExecutors.directExecutor()) .setId(getId()) .setSalFacade(facade) .setBaseSchemas(BASE_SCHEMAS) @@ -409,7 +405,7 @@ public class NetconfDeviceTest extends AbstractTestModelTest { verify(facade, timeout(5000)).onDeviceConnected(argument.capture(), any(NetconfSessionPreferences.class), any(RemoteDeviceServices.class)); - List notificationModulesName = Arrays.asList( + List notificationModulesName = List.of( org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714 .$YangModuleInfoImpl.getInstance().getName().toString(), org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715 @@ -432,7 +428,7 @@ public class NetconfDeviceTest extends AbstractTestModelTest { getSchemaRegistry(), getSchemaRepository(), schemaContextProviderFactory, STATE_SCHEMAS_RESOLVER); final NetconfDevice device = new NetconfDeviceBuilder() .setSchemaResourcesDTO(schemaResourcesDTO) - .setGlobalProcessingExecutor(getExecutor()) + .setGlobalProcessingExecutor(MoreExecutors.directExecutor()) .setId(getId()) .setSalFacade(facade) .setBaseSchemas(BASE_SCHEMAS) @@ -469,14 +465,14 @@ public class NetconfDeviceTest extends AbstractTestModelTest { getSchemaRegistry(), getSchemaRepository(), schemaContextProviderFactory, STATE_SCHEMAS_RESOLVER); final NetconfDevice device = new NetconfDeviceBuilder() .setSchemaResourcesDTO(schemaResourcesDTO) - .setGlobalProcessingExecutor(getExecutor()) + .setGlobalProcessingExecutor(MoreExecutors.directExecutor()) .setId(getId()) .setSalFacade(facade) .setBaseSchemas(BASE_SCHEMAS) .build(); final NetconfDevice netconfSpy = spy(device); - final NetconfSessionPreferences sessionCaps = getSessionCaps(false, Collections.emptyList()); + final NetconfSessionPreferences sessionCaps = getSessionCaps(false, List.of()); final Map moduleBasedCaps = new HashMap<>(); moduleBasedCaps.put(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714 @@ -538,10 +534,6 @@ public class NetconfDeviceTest extends AbstractTestModelTest { return new RemoteDeviceId("test-D", InetSocketAddress.createUnresolved("localhost", 22)); } - public ListeningExecutorService getExecutor() { - return MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor()); - } - public NetconfSessionPreferences getSessionCaps(final boolean addMonitor, final Collection additionalCapabilities) { final var capabilities = new ArrayList(); @@ -555,9 +547,6 @@ public class NetconfDeviceTest extends AbstractTestModelTest { } public NetconfDeviceCommunicator getListener() throws Exception { - final NetconfDeviceCommunicator remoteDeviceCommunicator = mockCloseableClass(NetconfDeviceCommunicator.class); -// doReturn(Futures.immediateFuture(rpcResult)) -// .when(remoteDeviceCommunicator).sendRequest(any(NetconfMessage.class), any(QName.class)); - return remoteDeviceCommunicator; + return mockCloseableClass(NetconfDeviceCommunicator.class); } }