From 493d1f617e491d0c4deb8f49079eecf0864f8d80 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 26 Jan 2024 04:06:38 +0100 Subject: [PATCH] Remove netconf-config Rehost the remaining threadpool into netconf-topology and let users inject is as NetconfTopologySchemaAssembler. JIRA: NETCONF-1232 Change-Id: I3dd7a24d689c53aafd1e067028991302a8925ef4 Signed-off-by: Robert Varga --- apps/callhome-provider/pom.xml | 4 - .../callhome/mount/CallHomeMountService.java | 20 ++-- .../callhome/mount/CallHomeTopology.java | 6 +- apps/netconf-nb/pom.xml | 4 - apps/netconf-topology-impl/pom.xml | 4 - .../topology/impl/NetconfTopologyImpl.java | 26 ++--- .../impl/NetconfTopologyImplTest.java | 103 +++++++++--------- apps/netconf-topology-singleton/pom.xml | 4 - .../singleton/impl/NetconfNodeContext.java | 2 +- .../impl/NetconfTopologyManager.java | 28 ++--- .../impl/utils/NetconfTopologySetup.java | 21 ++-- .../impl/MountPointEndToEndTest.java | 10 +- .../impl/NetconfTopologyManagerTest.java | 12 +- apps/netconf-topology/pom.xml | 8 ++ .../topology/spi/AbstractNetconfTopology.java | 13 +-- .../topology/spi/NetconfNodeHandler.java | 6 +- .../spi/NetconfTopologySchemaAssembler.java | 64 +++++++++++ .../topology/spi/NetconfNodeHandlerTest.java | 14 ++- artifacts/pom.xml | 5 - features/odl-netconf-client/pom.xml | 4 - features/odl-netconf-impl/pom.xml | 6 - .../src/main/feature/feature.xml | 13 --- netconf/netconf-config/pom.xml | 67 ------------ .../netconf/config/Configuration.java | 28 ----- .../config/GlobalNetconfConfiguration.java | 88 --------------- .../GlobalNetconfProcessingExecutor.java | 72 ------------ .../config/GlobalNetconfThreadFactory.java | 29 ----- netconf/pom.xml | 1 - 28 files changed, 211 insertions(+), 451 deletions(-) create mode 100644 apps/netconf-topology/src/main/java/org/opendaylight/netconf/topology/spi/NetconfTopologySchemaAssembler.java delete mode 100644 features/odl-netconf-impl/src/main/feature/feature.xml delete mode 100644 netconf/netconf-config/pom.xml delete mode 100644 netconf/netconf-config/src/main/java/org/opendaylight/netconf/config/Configuration.java delete mode 100644 netconf/netconf-config/src/main/java/org/opendaylight/netconf/config/GlobalNetconfConfiguration.java delete mode 100644 netconf/netconf-config/src/main/java/org/opendaylight/netconf/config/GlobalNetconfProcessingExecutor.java delete mode 100644 netconf/netconf-config/src/main/java/org/opendaylight/netconf/config/GlobalNetconfThreadFactory.java diff --git a/apps/callhome-provider/pom.xml b/apps/callhome-provider/pom.xml index e85b3dee78..690af2abea 100644 --- a/apps/callhome-provider/pom.xml +++ b/apps/callhome-provider/pom.xml @@ -65,10 +65,6 @@ org.opendaylight.mdsal.model ietf-topology - - org.opendaylight.controller - threadpool-config-api - org.opendaylight.netconf netconf-api diff --git a/apps/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/CallHomeMountService.java b/apps/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/CallHomeMountService.java index a63ca67c18..e1dddc02c9 100644 --- a/apps/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/CallHomeMountService.java +++ b/apps/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/CallHomeMountService.java @@ -16,11 +16,9 @@ import java.net.InetSocketAddress; import java.net.SocketAddress; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.Executor; import javax.annotation.PreDestroy; import javax.inject.Inject; import javax.inject.Singleton; -import org.opendaylight.controller.config.threadpool.ThreadPool; import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.mdsal.dom.api.DOMMountPointService; import org.opendaylight.netconf.callhome.server.CallHomeStatusRecorder; @@ -41,6 +39,7 @@ import org.opendaylight.netconf.shaded.sshd.client.session.ClientSession; import org.opendaylight.netconf.topology.spi.NetconfClientConfigurationBuilderFactory; import org.opendaylight.netconf.topology.spi.NetconfNodeHandler; import org.opendaylight.netconf.topology.spi.NetconfNodeUtils; +import org.opendaylight.netconf.topology.spi.NetconfTopologySchemaAssembler; import org.opendaylight.netconf.transport.api.UnsupportedConfigurationException; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil; @@ -121,25 +120,24 @@ public final class CallHomeMountService implements AutoCloseable { @Inject public CallHomeMountService( final @Reference(target = "(type=global-timer)") Timer timer, - final @Reference(target = "(type=global-netconf-processing-executor)") ThreadPool processingThreadPool, + final @Reference NetconfTopologySchemaAssembler schemaAssembler, final @Reference SchemaResourceManager schemaRepositoryProvider, final @Reference BaseNetconfSchemas baseSchemas, final @Reference DataBroker dataBroker, final @Reference DOMMountPointService mountService, final @Reference DeviceActionFactory deviceActionFactory) { - this(NetconfNodeUtils.DEFAULT_TOPOLOGY_NAME, timer, - processingThreadPool.getExecutor(), schemaRepositoryProvider, baseSchemas, + this(NetconfNodeUtils.DEFAULT_TOPOLOGY_NAME, timer, schemaAssembler, schemaRepositoryProvider, baseSchemas, dataBroker, mountService, deviceActionFactory); } - public CallHomeMountService(final String topologyId, final Timer timer, final Executor executor, - final SchemaResourceManager schemaRepositoryProvider, final BaseNetconfSchemas baseSchemas, - final DataBroker dataBroker, final DOMMountPointService mountService, + public CallHomeMountService(final String topologyId, final Timer timer, + final NetconfTopologySchemaAssembler schemaAssembler, final SchemaResourceManager schemaRepositoryProvider, + final BaseNetconfSchemas baseSchemas, final DataBroker dataBroker, final DOMMountPointService mountService, final DeviceActionFactory deviceActionFactory) { final var clientConfBuilderFactory = createClientConfigurationBuilderFactory(); final var clientFactory = createClientFactory(); - topology = new CallHomeTopology(topologyId, clientFactory, timer, executor, + topology = new CallHomeTopology(topologyId, clientFactory, timer, schemaAssembler, schemaRepositoryProvider, dataBroker, mountService, clientConfBuilderFactory, baseSchemas, deviceActionFactory); } @@ -220,7 +218,7 @@ public final class CallHomeMountService implements AutoCloseable { } @Override - public void remove(String id) { + public void remove(final String id) { super.remove(id); topology.disableNode(new NodeId(id)); } @@ -239,7 +237,7 @@ public final class CallHomeMountService implements AutoCloseable { } @Override - public void remove(String id) { + public void remove(final String id) { super.remove(id); topology.disableNode(new NodeId(id)); } diff --git a/apps/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/CallHomeTopology.java b/apps/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/CallHomeTopology.java index a73c368c84..d3dceb1bf3 100644 --- a/apps/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/CallHomeTopology.java +++ b/apps/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/CallHomeTopology.java @@ -8,7 +8,6 @@ package org.opendaylight.netconf.callhome.mount; import io.netty.util.Timer; -import java.util.concurrent.Executor; import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.mdsal.dom.api.DOMMountPointService; import org.opendaylight.netconf.client.NetconfClientFactory; @@ -17,17 +16,18 @@ import org.opendaylight.netconf.client.mdsal.api.DeviceActionFactory; import org.opendaylight.netconf.client.mdsal.api.SchemaResourceManager; import org.opendaylight.netconf.topology.spi.AbstractNetconfTopology; import org.opendaylight.netconf.topology.spi.NetconfClientConfigurationBuilderFactory; +import org.opendaylight.netconf.topology.spi.NetconfTopologySchemaAssembler; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node; // Non-final for mocking class CallHomeTopology extends AbstractNetconfTopology { CallHomeTopology(final String topologyId, final NetconfClientFactory clientFactory, final Timer timer, - final Executor processingExecutor, final SchemaResourceManager schemaRepositoryProvider, + final NetconfTopologySchemaAssembler schemaAssembler, 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, + super(topologyId, clientFactory, timer, schemaAssembler, schemaRepositoryProvider, dataBroker, mountPointService, builderFactory, deviceActionFactory, baseSchemas); } diff --git a/apps/netconf-nb/pom.xml b/apps/netconf-nb/pom.xml index fe57f15424..f772508dbd 100644 --- a/apps/netconf-nb/pom.xml +++ b/apps/netconf-nb/pom.xml @@ -46,10 +46,6 @@ org.opendaylight.mdsal mdsal-binding-api - - org.opendaylight.controller - threadpool-config-api - org.opendaylight.netconf netconf-api diff --git a/apps/netconf-topology-impl/pom.xml b/apps/netconf-topology-impl/pom.xml index 865ff352f0..2d97d27b5d 100644 --- a/apps/netconf-topology-impl/pom.xml +++ b/apps/netconf-topology-impl/pom.xml @@ -36,10 +36,6 @@ provided true - - org.opendaylight.controller - threadpool-config-api - org.opendaylight.netconf netconf-topology diff --git a/apps/netconf-topology-impl/src/main/java/org/opendaylight/netconf/topology/impl/NetconfTopologyImpl.java b/apps/netconf-topology-impl/src/main/java/org/opendaylight/netconf/topology/impl/NetconfTopologyImpl.java index 6a129774a4..f71cf9356f 100644 --- a/apps/netconf-topology-impl/src/main/java/org/opendaylight/netconf/topology/impl/NetconfTopologyImpl.java +++ b/apps/netconf-topology-impl/src/main/java/org/opendaylight/netconf/topology/impl/NetconfTopologyImpl.java @@ -10,12 +10,10 @@ package org.opendaylight.netconf.topology.impl; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import io.netty.util.Timer; import java.util.Collection; -import java.util.concurrent.Executor; import javax.annotation.PreDestroy; import javax.inject.Inject; import javax.inject.Singleton; import org.opendaylight.aaa.encrypt.AAAEncryptionService; -import org.opendaylight.controller.config.threadpool.ThreadPool; import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.mdsal.binding.api.DataTreeChangeListener; import org.opendaylight.mdsal.binding.api.DataTreeIdentifier; @@ -31,6 +29,7 @@ import org.opendaylight.netconf.topology.spi.AbstractNetconfTopology; import org.opendaylight.netconf.topology.spi.NetconfClientConfigurationBuilderFactory; import org.opendaylight.netconf.topology.spi.NetconfNodeUtils; import org.opendaylight.netconf.topology.spi.NetconfTopologyRPCProvider; +import org.opendaylight.netconf.topology.spi.NetconfTopologySchemaAssembler; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology; @@ -60,36 +59,37 @@ public class NetconfTopologyImpl extends AbstractNetconfTopology public NetconfTopologyImpl( @Reference(target = "(type=netconf-client-factory)") final NetconfClientFactory clientFactory, @Reference(target = "(type=global-timer)") final Timer timer, - @Reference(target = "(type=global-netconf-processing-executor)") final ThreadPool processingThreadPool, + @Reference final NetconfTopologySchemaAssembler schemaAssembler, @Reference final SchemaResourceManager schemaRepositoryProvider, @Reference final DataBroker dataBroker, @Reference final DOMMountPointService mountPointService, @Reference final AAAEncryptionService encryptionService, @Reference final NetconfClientConfigurationBuilderFactory builderFactory, @Reference final RpcProviderService rpcProviderService, @Reference final BaseNetconfSchemas baseSchemas, @Reference final DeviceActionFactory deviceActionFactory) { - this(NetconfNodeUtils.DEFAULT_TOPOLOGY_NAME, clientFactory, timer, processingThreadPool.getExecutor(), - schemaRepositoryProvider, dataBroker, mountPointService, encryptionService, builderFactory, - rpcProviderService, baseSchemas, deviceActionFactory); + this(NetconfNodeUtils.DEFAULT_TOPOLOGY_NAME, clientFactory, timer, schemaAssembler, schemaRepositoryProvider, + dataBroker, mountPointService, encryptionService, builderFactory, rpcProviderService, baseSchemas, + deviceActionFactory); } public NetconfTopologyImpl(final String topologyId, final NetconfClientFactory clientclientFactory, - 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, + final Timer timer, final NetconfTopologySchemaAssembler schemaAssembler, + 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, schemaAssembler, 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 Executor processingExecutor, final SchemaResourceManager schemaRepositoryProvider, + final NetconfTopologySchemaAssembler schemaAssembler, 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, + super(topologyId, clientFactory, timer, schemaAssembler, schemaRepositoryProvider, dataBroker, mountPointService, builderFactory, deviceActionFactory, baseSchemas); LOG.debug("Registering datastore listener"); diff --git a/apps/netconf-topology-impl/src/test/java/org/opendaylight/netconf/topology/impl/NetconfTopologyImplTest.java b/apps/netconf-topology-impl/src/test/java/org/opendaylight/netconf/topology/impl/NetconfTopologyImplTest.java index 765882b030..2458c85932 100644 --- a/apps/netconf-topology-impl/src/test/java/org/opendaylight/netconf/topology/impl/NetconfTopologyImplTest.java +++ b/apps/netconf-topology-impl/src/test/java/org/opendaylight/netconf/topology/impl/NetconfTopologyImplTest.java @@ -12,10 +12,9 @@ import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -import com.google.common.util.concurrent.MoreExecutors; import io.netty.util.Timer; import java.util.List; -import java.util.concurrent.Executor; +import java.util.concurrent.TimeUnit; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; @@ -35,6 +34,7 @@ import org.opendaylight.netconf.client.mdsal.api.BaseNetconfSchemas; import org.opendaylight.netconf.client.mdsal.api.SchemaResourceManager; import org.opendaylight.netconf.client.mdsal.impl.DefaultBaseNetconfSchemas; import org.opendaylight.netconf.topology.spi.NetconfClientConfigurationBuilderFactory; +import org.opendaylight.netconf.topology.spi.NetconfTopologySchemaAssembler; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; @@ -86,75 +86,74 @@ class NetconfTopologyImplTest { @Mock private DataTreeModification treeMod; - private TestingNetconfTopologyImpl topology; - private TestingNetconfTopologyImpl spyTopology; - @Test void testOnDataTreeChange() throws Exception { doReturn(wtx).when(dataBroker).newWriteOnlyTransaction(); doReturn(CommitInfo.emptyFluentFuture()).when(wtx).commit(); - topology = new TestingNetconfTopologyImpl(TOPOLOGY_KEY.getTopologyId().getValue(), mockedClientFactory, - mockedTimer, MoreExecutors.directExecutor(), mockedResourceManager, dataBroker, mountPointService, - encryptionService, builderFactory, rpcProviderService, - new DefaultBaseNetconfSchemas(new DefaultYangParserFactory())); - //verify initialization of topology - verify(wtx).merge(LogicalDatastoreType.OPERATIONAL, TOPOLOGY_PATH, - new TopologyBuilder().withKey(TOPOLOGY_KEY).build()); - - spyTopology = spy(topology); - - final var key = new NodeKey(new NodeId("testing-node")); - final var node = new NodeBuilder() - .withKey(key) - .addAugmentation(new NetconfNodeBuilder() - .setLockDatastore(true) - .setHost(new Host(new IpAddress(new Ipv4Address("127.0.0.1")))) - .setPort(new PortNumber(Uint16.valueOf(9999))) - .setReconnectOnChangedSchema(true) - .setDefaultRequestTimeoutMillis(Uint32.valueOf(1000)) - .setMinBackoffMillis(Uint16.valueOf(100)) - .setKeepaliveDelay(Uint32.valueOf(1000)) - .setTcpOnly(true) - .setCredentials(new LoginPwUnencryptedBuilder() - .setLoginPasswordUnencrypted(new LoginPasswordUnencryptedBuilder() - .setUsername("testuser") - .setPassword("testpassword") + try (var schemaAssembler = new NetconfTopologySchemaAssembler(1, 1, 0, TimeUnit.SECONDS)) { + final var topology = new TestingNetconfTopologyImpl(TOPOLOGY_KEY.getTopologyId().getValue(), + mockedClientFactory, mockedTimer, schemaAssembler, mockedResourceManager, dataBroker, mountPointService, + encryptionService, builderFactory, rpcProviderService, + new DefaultBaseNetconfSchemas(new DefaultYangParserFactory())); + //verify initialization of topology + verify(wtx).merge(LogicalDatastoreType.OPERATIONAL, TOPOLOGY_PATH, + new TopologyBuilder().withKey(TOPOLOGY_KEY).build()); + + final var spyTopology = spy(topology); + + final var key = new NodeKey(new NodeId("testing-node")); + final var node = new NodeBuilder() + .withKey(key) + .addAugmentation(new NetconfNodeBuilder() + .setLockDatastore(true) + .setHost(new Host(new IpAddress(new Ipv4Address("127.0.0.1")))) + .setPort(new PortNumber(Uint16.valueOf(9999))) + .setReconnectOnChangedSchema(true) + .setDefaultRequestTimeoutMillis(Uint32.valueOf(1000)) + .setMinBackoffMillis(Uint16.valueOf(100)) + .setKeepaliveDelay(Uint32.valueOf(1000)) + .setTcpOnly(true) + .setCredentials(new LoginPwUnencryptedBuilder() + .setLoginPasswordUnencrypted(new LoginPasswordUnencryptedBuilder() + .setUsername("testuser") + .setPassword("testpassword") + .build()) .build()) .build()) - .build()) - .build(); + .build(); - doReturn(DataObjectModification.ModificationType.WRITE).when(objMod).getModificationType(); - doReturn(node).when(objMod).getDataAfter(); + doReturn(DataObjectModification.ModificationType.WRITE).when(objMod).getModificationType(); + doReturn(node).when(objMod).getDataAfter(); - doReturn(DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION, TOPOLOGY_PATH.child(Node.class, key))) - .when(treeMod).getRootPath(); - final var changes = List.of(treeMod); + doReturn(DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION, + TOPOLOGY_PATH.child(Node.class, key))).when(treeMod).getRootPath(); + final var changes = List.of(treeMod); - doReturn(objMod).when(treeMod).getRootNode(); - spyTopology.onDataTreeChanged(changes); - verify(spyTopology).ensureNode(node); + doReturn(objMod).when(treeMod).getRootNode(); + spyTopology.onDataTreeChanged(changes); + verify(spyTopology).ensureNode(node); - doReturn(DataObjectModification.ModificationType.DELETE).when(objMod).getModificationType(); - spyTopology.onDataTreeChanged(changes); - verify(spyTopology).deleteNode(key.getNodeId()); + doReturn(DataObjectModification.ModificationType.DELETE).when(objMod).getModificationType(); + spyTopology.onDataTreeChanged(changes); + verify(spyTopology).deleteNode(key.getNodeId()); - doReturn(DataObjectModification.ModificationType.SUBTREE_MODIFIED).when(objMod).getModificationType(); - spyTopology.onDataTreeChanged(changes); + doReturn(DataObjectModification.ModificationType.SUBTREE_MODIFIED).when(objMod).getModificationType(); + spyTopology.onDataTreeChanged(changes); - // one in previous creating and deleting node and one in updating - verify(spyTopology, times(2)).ensureNode(node); + // one in previous creating and deleting node and one in updating + verify(spyTopology, times(2)).ensureNode(node); + } } private static class TestingNetconfTopologyImpl extends NetconfTopologyImpl { TestingNetconfTopologyImpl(final String topologyId, final NetconfClientFactory clientFactory, final Timer timer, - final Executor processingExecutor, final SchemaResourceManager schemaRepositoryProvider, - final DataBroker dataBroker, final DOMMountPointService mountPointService, - final AAAEncryptionService encryptionService, + final NetconfTopologySchemaAssembler schemaAssembler, + 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, processingExecutor, schemaRepositoryProvider, + super(topologyId, clientFactory, timer, schemaAssembler, schemaRepositoryProvider, dataBroker, mountPointService, encryptionService, builderFactory, rpcProviderService, baseSchemas); } diff --git a/apps/netconf-topology-singleton/pom.xml b/apps/netconf-topology-singleton/pom.xml index ff33560e6d..62d8d5e00e 100644 --- a/apps/netconf-topology-singleton/pom.xml +++ b/apps/netconf-topology-singleton/pom.xml @@ -54,10 +54,6 @@ org.opendaylight.controller sal-clustering-commons - - org.opendaylight.controller - threadpool-config-api - org.opendaylight.mdsal mdsal-singleton-common-api 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 9affe83358..212d3a61b9 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 @@ -142,7 +142,7 @@ final class NetconfNodeContext implements AutoCloseable { masterSalFacade = createSalFacade(netconfNode.requireLockDatastore()); nodeHandler = new NetconfNodeHandler(setup.getNetconfClientFactory(), setup.getTimer(), setup.getBaseSchemas(), - schemaManager, setup.getProcessingExecutor(), builderFactory, deviceActionFactory, masterSalFacade, + schemaManager, setup.getSchemaAssembler(), builderFactory, deviceActionFactory, masterSalFacade, remoteDeviceId, configNode.getNodeId(), netconfNode, nodeOptional); nodeHandler.connect(); } 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 7bd296ac6a..77cf2d9081 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 @@ -20,13 +20,11 @@ import java.time.Duration; import java.util.Collection; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.Executor; 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.ThreadPool; import org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener; import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.mdsal.binding.api.DataObjectModification; @@ -50,6 +48,7 @@ import org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologyUti import org.opendaylight.netconf.topology.spi.NetconfClientConfigurationBuilderFactory; import org.opendaylight.netconf.topology.spi.NetconfNodeUtils; import org.opendaylight.netconf.topology.spi.NetconfTopologyRPCProvider; +import org.opendaylight.netconf.topology.spi.NetconfTopologySchemaAssembler; import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev231121.NetconfNode; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; @@ -97,7 +96,7 @@ public class NetconfTopologyManager implements ClusteredDataTreeChangeListener instanceIdentifier; private final Node node; private final Timer timer; - private final Executor processingExecutor; + private final NetconfTopologySchemaAssembler schemaAssembler; private final ActorSystem actorSystem; private final NetconfClientFactory netconfClientFactory; private final String topologyId; @@ -42,7 +42,7 @@ public final class NetconfTopologySetup { instanceIdentifier = builder.getInstanceIdentifier(); node = builder.getNode(); timer = builder.getTimer(); - processingExecutor = builder.getProcessingExecutor(); + schemaAssembler = builder.getSchemaAssembler(); actorSystem = builder.getActorSystem(); netconfClientFactory = builder.getNetconfClientFactory(); topologyId = builder.getTopologyId(); @@ -67,8 +67,8 @@ public final class NetconfTopologySetup { return node; } - public Executor getProcessingExecutor() { - return processingExecutor; + public NetconfTopologySchemaAssembler getSchemaAssembler() { + return schemaAssembler; } public Timer getTimer() { @@ -109,7 +109,7 @@ public final class NetconfTopologySetup { private InstanceIdentifier instanceIdentifier; private Node node; private Timer timer; - private Executor processingExecutor; + private NetconfTopologySchemaAssembler schemaAssembler; private ActorSystem actorSystem; private String topologyId; private NetconfClientFactory netconfClientFactory; @@ -180,12 +180,13 @@ public final class NetconfTopologySetup { return this; } - Executor getProcessingExecutor() { - return processingExecutor; + + NetconfTopologySchemaAssembler getSchemaAssembler() { + return schemaAssembler; } - public Builder setProcessingExecutor(final Executor processingExecutor) { - this.processingExecutor = processingExecutor; + public Builder setSchemaAssembler(final NetconfTopologySchemaAssembler schemaAssembler) { + this.schemaAssembler = schemaAssembler; return this; } diff --git a/apps/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/MountPointEndToEndTest.java b/apps/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/MountPointEndToEndTest.java index 1320d43277..ce76dc9c12 100644 --- a/apps/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/MountPointEndToEndTest.java +++ b/apps/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/MountPointEndToEndTest.java @@ -30,7 +30,6 @@ import com.google.common.collect.ImmutableMap; import com.google.common.util.concurrent.FluentFuture; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.MoreExecutors; import com.google.common.util.concurrent.SettableFuture; import com.typesafe.config.ConfigFactory; import io.netty.util.Timer; @@ -107,6 +106,7 @@ import org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologyUti import org.opendaylight.netconf.topology.spi.NetconfClientConfigurationBuilderFactory; import org.opendaylight.netconf.topology.spi.NetconfClientConfigurationBuilderFactoryImpl; import org.opendaylight.netconf.topology.spi.NetconfNodeUtils; +import org.opendaylight.netconf.topology.spi.NetconfTopologySchemaAssembler; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; @@ -234,11 +234,14 @@ public class MountPointEndToEndTest extends AbstractBaseSchemasTest { private final ContainerNode getTopInput = ImmutableNodes.containerNode(GetTopInput.QNAME); private SchemaResourceManager resourceManager; + private NetconfTopologySchemaAssembler schemaAssembler; @Before public void setUp() throws Exception { deleteCacheDir(); + schemaAssembler = new NetconfTopologySchemaAssembler(1, 1, 0, TimeUnit.SECONDS); + resourceManager = new DefaultSchemaResourceManager(new DefaultYangParserFactory(), TEST_ROOT_DIRECTORY, TEST_DEFAULT_SUBDIR); @@ -292,6 +295,7 @@ public class MountPointEndToEndTest extends AbstractBaseSchemasTest { deleteCacheDir(); TestKit.shutdownActorSystem(slaveSystem, true); TestKit.shutdownActorSystem(masterSystem, true); + schemaAssembler.close(); } private void setupMaster() throws Exception { @@ -314,7 +318,7 @@ public class MountPointEndToEndTest extends AbstractBaseSchemasTest { YangTextSchemaSource.class, 1)); masterNetconfTopologyManager = new NetconfTopologyManager(BASE_SCHEMAS, masterDataBroker, - masterClusterSingletonServiceProvider, mockTimer, MoreExecutors.directExecutor(), masterSystem, + masterClusterSingletonServiceProvider, mockTimer, schemaAssembler, masterSystem, mockClientFactory, masterMountPointService, mockEncryptionService, mockRpcProviderService, deviceActionFactory, resourceManager, builderFactory, TOPOLOGY_ID, Uint16.ZERO) { @Override @@ -350,7 +354,7 @@ public class MountPointEndToEndTest extends AbstractBaseSchemasTest { .registerClusterSingletonService(any()); slaveNetconfTopologyManager = new NetconfTopologyManager(BASE_SCHEMAS, slaveDataBroker, - mockSlaveClusterSingletonServiceProvider, mockTimer, MoreExecutors.directExecutor(), slaveSystem, + mockSlaveClusterSingletonServiceProvider, mockTimer, schemaAssembler, slaveSystem, mockClientFactory, slaveMountPointService, mockEncryptionService, mockRpcProviderService, deviceActionFactory, resourceManager, builderFactory, TOPOLOGY_ID, Uint16.ZERO) { @Override diff --git a/apps/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/NetconfTopologyManagerTest.java b/apps/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/NetconfTopologyManagerTest.java index e7faaf16d0..9bd03ae2a9 100644 --- a/apps/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/NetconfTopologyManagerTest.java +++ b/apps/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/NetconfTopologyManagerTest.java @@ -34,6 +34,7 @@ import java.util.Set; import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; import java.util.function.Function; +import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -60,6 +61,7 @@ import org.opendaylight.netconf.client.mdsal.impl.DefaultSchemaResourceManager; import org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup; import org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologyUtils; import org.opendaylight.netconf.topology.spi.NetconfClientConfigurationBuilderFactory; +import org.opendaylight.netconf.topology.spi.NetconfTopologySchemaAssembler; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; @@ -110,6 +112,7 @@ public class NetconfTopologyManagerTest extends AbstractBaseSchemasTest { @Mock private NetconfClientConfigurationBuilderFactory builderFactory; + private NetconfTopologySchemaAssembler schemaAssembler; private DataBroker dataBroker; private final Map, Function> @@ -117,6 +120,8 @@ public class NetconfTopologyManagerTest extends AbstractBaseSchemasTest { @Before public void setUp() throws Exception { + schemaAssembler = new NetconfTopologySchemaAssembler(1, 1, 0, TimeUnit.SECONDS); + AbstractDataBrokerTest dataBrokerTest = new AbstractDataBrokerTest() { @Override protected Set getModuleInfos() throws Exception { @@ -132,7 +137,7 @@ public class NetconfTopologyManagerTest extends AbstractBaseSchemasTest { doReturn(mockRpcReg).when(rpcProviderService).registerRpcImplementations(any()); netconfTopologyManager = new NetconfTopologyManager(BASE_SCHEMAS, dataBroker, clusterSingletonServiceProvider, - timer, processingService, actorSystem, clientFactory, mountPointService, encryptionService, + timer, schemaAssembler, actorSystem, clientFactory, mountPointService, encryptionService, rpcProviderService, actionFactory, new DefaultSchemaResourceManager(new DefaultYangParserFactory()), builderFactory, TOPOLOGY_ID, Uint16.ZERO) { @Override @@ -146,6 +151,11 @@ public class NetconfTopologyManagerTest extends AbstractBaseSchemasTest { }; } + @After + public void after() { + schemaAssembler.close(); + } + @Test public void testRegisterDataTreeChangeListener() throws Exception { await().atMost(5, TimeUnit.SECONDS).until(() -> { diff --git a/apps/netconf-topology/pom.xml b/apps/netconf-topology/pom.xml index 3addb17da8..5a691e1d42 100644 --- a/apps/netconf-topology/pom.xml +++ b/apps/netconf-topology/pom.xml @@ -24,6 +24,10 @@ org.opendaylight.aaa aaa-encrypt-service + + org.opendaylight.controller + threadpool-config-impl + org.opendaylight.mdsal.model ietf-topology @@ -40,6 +44,10 @@ org.osgi org.osgi.service.component.annotations + + org.osgi + org.osgi.service.metatype.annotations + org.awaitility 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 ffb03877ec..93f818cd78 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 @@ -14,7 +14,6 @@ import io.netty.util.Timer; import java.util.HashMap; import java.util.NoSuchElementException; import java.util.concurrent.ExecutionException; -import java.util.concurrent.Executor; import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.mdsal.dom.api.DOMMountPointService; @@ -48,20 +47,20 @@ public abstract class AbstractNetconfTopology { private final NetconfClientConfigurationBuilderFactory builderFactory; private final Timer timer; - protected final Executor processingExecutor; + protected final NetconfTopologySchemaAssembler schemaAssembler; protected final DataBroker dataBroker; protected final DOMMountPointService mountPointService; protected final String topologyId; protected AbstractNetconfTopology(final String topologyId, final NetconfClientFactory clientFactory, - final Timer timer, final Executor processingExecutor, final SchemaResourceManager schemaManager, - final DataBroker dataBroker, final DOMMountPointService mountPointService, - final NetconfClientConfigurationBuilderFactory builderFactory, + final Timer timer, final NetconfTopologySchemaAssembler schemaAssembler, + 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.processingExecutor = requireNonNull(processingExecutor); + this.schemaAssembler = requireNonNull(schemaAssembler); this.schemaManager = requireNonNull(schemaManager); this.deviceActionFactory = deviceActionFactory; this.dataBroker = requireNonNull(dataBroker); @@ -121,7 +120,7 @@ public abstract class AbstractNetconfTopology { final NetconfNodeHandler nodeHandler; try { - nodeHandler = new NetconfNodeHandler(clientFactory, timer, baseSchemas, schemaManager, processingExecutor, + nodeHandler = new NetconfNodeHandler(clientFactory, timer, baseSchemas, schemaManager, schemaAssembler, 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 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 82525479a7..a025c83cfb 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 @@ -19,7 +19,6 @@ 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.TimeUnit; import org.checkerframework.checker.lock.qual.GuardedBy; import org.checkerframework.checker.lock.qual.Holding; @@ -130,7 +129,8 @@ public final class NetconfNodeHandler extends AbstractRegistration implements Re public NetconfNodeHandler(final NetconfClientFactory clientFactory, final Timer timer, final BaseNetconfSchemas baseSchemas, final SchemaResourceManager schemaManager, - final Executor processingExecutor, final NetconfClientConfigurationBuilderFactory builderFactory, + final NetconfTopologySchemaAssembler schemaAssembler, + final NetconfClientConfigurationBuilderFactory builderFactory, final DeviceActionFactory deviceActionFactory, final RemoteDeviceHandler delegate, final RemoteDeviceId deviceId, final NodeId nodeId, final NetconfNode node, final NetconfNodeAugmentedOptional nodeOptional) { @@ -174,7 +174,7 @@ public final class NetconfNodeHandler extends AbstractRegistration implements Re device = new NetconfDeviceBuilder() .setReconnectOnSchemasChange(node.requireReconnectOnChangedSchema()) .setSchemaResourcesDTO(resources) - .setGlobalProcessingExecutor(processingExecutor) + .setGlobalProcessingExecutor(schemaAssembler.executor()) .setId(deviceId) .setSalFacade(salFacade) .setDeviceActionFactory(deviceActionFactory) diff --git a/apps/netconf-topology/src/main/java/org/opendaylight/netconf/topology/spi/NetconfTopologySchemaAssembler.java b/apps/netconf-topology/src/main/java/org/opendaylight/netconf/topology/spi/NetconfTopologySchemaAssembler.java new file mode 100644 index 0000000000..0e5ee66664 --- /dev/null +++ b/apps/netconf-topology/src/main/java/org/opendaylight/netconf/topology/spi/NetconfTopologySchemaAssembler.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2024 PANTHEON.tech, s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.netconf.topology.spi; + +import com.google.common.util.concurrent.ThreadFactoryBuilder; +import java.util.concurrent.Executor; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.TimeUnit; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.opendaylight.controller.config.threadpool.util.FlexibleThreadPoolWrapper; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; +import org.osgi.service.metatype.annotations.AttributeDefinition; +import org.osgi.service.metatype.annotations.Designate; +import org.osgi.service.metatype.annotations.ObjectClassDefinition; + +@NonNullByDefault +@Component(service = NetconfTopologySchemaAssembler.class, configurationPid = "org.opendaylight.netconf.topology") +@Designate(ocd = NetconfTopologySchemaAssembler.Configuration.class) +public final class NetconfTopologySchemaAssembler implements AutoCloseable { + @ObjectClassDefinition + public @interface Configuration { + @AttributeDefinition(min = "0") + int assembler$_$min$_$threads() default 1; + @AttributeDefinition(min = "1") + int assembler$_$max$_$threads() default 4; + @AttributeDefinition(min = "0") + long assembler$_$keep$_$alive$_$millis() default 60_000; + } + + private static final ThreadFactory THREAD_FACTORY = new ThreadFactoryBuilder() + .setNameFormat("topology-schema-assembler-%d") + .setDaemon(true) + .build(); + + private final FlexibleThreadPoolWrapper threadPool; + + public NetconfTopologySchemaAssembler(final int minThreads, final int maxThreads, final long keepAliveTime, + final TimeUnit unit) { + threadPool = new FlexibleThreadPoolWrapper(minThreads, maxThreads, keepAliveTime, unit, THREAD_FACTORY); + } + + @Activate + public NetconfTopologySchemaAssembler(final Configuration config) { + this(config.assembler$_$min$_$threads(), config.assembler$_$max$_$threads(), + config.assembler$_$keep$_$alive$_$millis(), TimeUnit.MILLISECONDS); + } + + @Override + @Deactivate + public void close() { + threadPool.close(); + } + + Executor executor() { + return threadPool.getExecutor(); + } +} diff --git a/apps/netconf-topology/src/test/java/org/opendaylight/netconf/topology/spi/NetconfNodeHandlerTest.java b/apps/netconf-topology/src/test/java/org/opendaylight/netconf/topology/spi/NetconfNodeHandlerTest.java index c369027eb7..165fb5ccf5 100644 --- a/apps/netconf-topology/src/test/java/org/opendaylight/netconf/topology/spi/NetconfNodeHandlerTest.java +++ b/apps/netconf-topology/src/test/java/org/opendaylight/netconf/topology/spi/NetconfNodeHandlerTest.java @@ -28,8 +28,8 @@ 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.TimeUnit; +import org.junit.After; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -84,8 +84,6 @@ public class NetconfNodeHandlerTest { @Mock private SchemaResourceManager schemaManager; @Mock - private Executor processingExecutor; - @Mock private DeviceActionFactory deviceActionFactory; @Mock private RemoteDeviceHandler delegate; @@ -118,6 +116,7 @@ public class NetconfNodeHandlerTest { @Mock private EffectiveModelContext schemaContext; + private NetconfTopologySchemaAssembler schemaAssembler; private NetconfNodeHandler handler; @BeforeClass @@ -132,8 +131,10 @@ public class NetconfNodeHandlerTest { @Before public void before() { + schemaAssembler = new NetconfTopologySchemaAssembler(1, 1, 0, TimeUnit.SECONDS); + // Instantiate the handler - handler = new NetconfNodeHandler(clientFactory, timer, BASE_SCHEMAS, schemaManager, processingExecutor, + handler = new NetconfNodeHandler(clientFactory, timer, BASE_SCHEMAS, schemaManager, schemaAssembler, new NetconfClientConfigurationBuilderFactoryImpl(encryptionService, credentialProvider, sslHandlerFactoryProvider), deviceActionFactory, delegate, DEVICE_ID, NODE_ID, new NetconfNodeBuilder() @@ -161,6 +162,11 @@ public class NetconfNodeHandlerTest { .build(), null); } + @After + public void after() { + schemaAssembler.close(); + } + @Test public void successfulOnDeviceConnectedPropagates() throws Exception { assertSuccessfulConnect(); diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 1d0f84cca9..dc5c736477 100644 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -55,11 +55,6 @@ netconf-common-mdsal ${project.version} - - ${project.groupId} - netconf-config - ${project.version} - ${project.groupId} netconf-dom-api diff --git a/features/odl-netconf-client/pom.xml b/features/odl-netconf-client/pom.xml index 577954e24b..9420362a4e 100644 --- a/features/odl-netconf-client/pom.xml +++ b/features/odl-netconf-client/pom.xml @@ -42,9 +42,5 @@ org.opendaylight.netconf netconf-client - - org.opendaylight.netconf - netconf-config - diff --git a/features/odl-netconf-impl/pom.xml b/features/odl-netconf-impl/pom.xml index 701a698aaf..9195ae7a76 100644 --- a/features/odl-netconf-impl/pom.xml +++ b/features/odl-netconf-impl/pom.xml @@ -21,12 +21,6 @@ OpenDaylight :: Netconf :: Impl - - org.opendaylight.controller - odl-controller-exp-netty-config - xml - features - org.opendaylight.netconf odl-netconf-api diff --git a/features/odl-netconf-impl/src/main/feature/feature.xml b/features/odl-netconf-impl/src/main/feature/feature.xml deleted file mode 100644 index 46ce8c13cc..0000000000 --- a/features/odl-netconf-impl/src/main/feature/feature.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - odl-controller-exp-netty-config - - diff --git a/netconf/netconf-config/pom.xml b/netconf/netconf-config/pom.xml deleted file mode 100644 index 6341d46856..0000000000 --- a/netconf/netconf-config/pom.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - 4.0.0 - - org.opendaylight.netconf - netconf-parent - 7.0.0-SNAPSHOT - ../../parent - - - netconf-config - Global threadpools for NETCONF - bundle - - - - com.google.guava - guava - - - org.eclipse.jdt - org.eclipse.jdt.annotation - - - org.opendaylight.controller - threadpool-config-api - - - org.opendaylight.controller - threadpool-config-impl - - - com.guicedee.services - javax.inject - true - - - jakarta.annotation - jakarta.annotation-api - provided - true - - - org.osgi - org.osgi.framework - - - org.osgi - org.osgi.service.component - - - org.osgi - org.osgi.service.component.annotations - - - org.osgi - org.osgi.service.metatype.annotations - - - diff --git a/netconf/netconf-config/src/main/java/org/opendaylight/netconf/config/Configuration.java b/netconf/netconf-config/src/main/java/org/opendaylight/netconf/config/Configuration.java deleted file mode 100644 index 144fac3550..0000000000 --- a/netconf/netconf-config/src/main/java/org/opendaylight/netconf/config/Configuration.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.netconf.config; - -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.osgi.service.metatype.annotations.AttributeDefinition; -import org.osgi.service.metatype.annotations.ObjectClassDefinition; - -@NonNullByDefault -@ObjectClassDefinition -public @interface Configuration { - @AttributeDefinition(min = "1") - String name$_$prefix() default GlobalNetconfThreadFactory.DEFAULT_NAME_PREFIX; - @AttributeDefinition(min = "0") - int min$_$thread$_$count$_$flexible$_$thread$_$pool() - default GlobalNetconfProcessingExecutor.DEFAULT_MIN_THREAD_COUNT; - @AttributeDefinition(min = "1") - int max$_$thread$_$count$_$flexible$_$thread$_$pool() - default GlobalNetconfProcessingExecutor.DEFAULT_MAX_THREAD_COUNT; - @AttributeDefinition(min = "0") - long keep$_$alive$_$millis$_$flexible$_$thread$_$pool() - default GlobalNetconfProcessingExecutor.DEFAULT_KEEPALIVE_MILLIS; -} diff --git a/netconf/netconf-config/src/main/java/org/opendaylight/netconf/config/GlobalNetconfConfiguration.java b/netconf/netconf-config/src/main/java/org/opendaylight/netconf/config/GlobalNetconfConfiguration.java deleted file mode 100644 index de2c608bbf..0000000000 --- a/netconf/netconf-config/src/main/java/org/opendaylight/netconf/config/GlobalNetconfConfiguration.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.netconf.config; - -import static com.google.common.base.Verify.verifyNotNull; -import static java.util.Objects.requireNonNull; - -import java.util.ArrayList; -import java.util.Map; -import org.osgi.framework.FrameworkUtil; -import org.osgi.service.component.ComponentFactory; -import org.osgi.service.component.ComponentInstance; -import org.osgi.service.component.annotations.Activate; -import org.osgi.service.component.annotations.Component; -import org.osgi.service.component.annotations.Deactivate; -import org.osgi.service.component.annotations.Modified; -import org.osgi.service.component.annotations.Reference; -import org.osgi.service.metatype.annotations.Designate; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Component instantiating global NETCONF resources. - */ -@Component(service = { }, configurationPid = "org.opendaylight.netconf.config") -@Designate(ocd = Configuration.class) -public final class GlobalNetconfConfiguration { - private static final Logger LOG = LoggerFactory.getLogger(GlobalNetconfConfiguration.class); - - private final ComponentFactory processingFactory; - - private GlobalNetconfThreadFactory threadFactory; - private ComponentInstance processingExecutor; - private Map processingProps; - - @Activate - public GlobalNetconfConfiguration( - @Reference(target = "(component.factory=" + GlobalNetconfProcessingExecutor.FACTORY_NAME + ")") - final ComponentFactory processingFactory, - final Configuration configuration) { - this.processingFactory = requireNonNull(processingFactory); - - threadFactory = new GlobalNetconfThreadFactory(configuration.name$_$prefix()); - processingProps = GlobalNetconfProcessingExecutor.props(threadFactory, configuration); - processingExecutor = processingFactory.newInstance(FrameworkUtil.asDictionary(processingProps)); - LOG.info("Global NETCONF configuration pools started"); - } - - @Modified - void modified(final Configuration configuration) { - final var newNamePrefix = configuration.name$_$prefix(); - if (!threadFactory.getNamePrefix().equals(newNamePrefix)) { - threadFactory = new GlobalNetconfThreadFactory(newNamePrefix); - processingProps = null; - LOG.debug("Forcing restart of all executors"); - } - - // We want to instantiate new services before we dispose old ones, so - final var toDispose = new ArrayList>(); - - final var newProcessingProps = GlobalNetconfProcessingExecutor.props(threadFactory, configuration); - if (!newProcessingProps.equals(processingProps)) { - processingProps = newProcessingProps; - toDispose.add(processingExecutor); - processingExecutor = processingFactory.newInstance(FrameworkUtil.asDictionary(processingProps)); - LOG.debug("Processing executor restarted with {}", processingProps); - } - - toDispose.forEach(ComponentInstance::dispose); - } - - @Deactivate - void deactivate() { - processingExecutor.dispose(); - processingExecutor = null; - threadFactory = null; - LOG.info("Global NETCONF configuration pools stopped"); - } - - static T extractProp(final Map properties, final String key, final Class valueType) { - return valueType.cast(verifyNotNull(properties.get(requireNonNull(key)))); - } -} diff --git a/netconf/netconf-config/src/main/java/org/opendaylight/netconf/config/GlobalNetconfProcessingExecutor.java b/netconf/netconf-config/src/main/java/org/opendaylight/netconf/config/GlobalNetconfProcessingExecutor.java deleted file mode 100644 index cdde2caecb..0000000000 --- a/netconf/netconf-config/src/main/java/org/opendaylight/netconf/config/GlobalNetconfProcessingExecutor.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.netconf.config; - -import static java.util.Objects.requireNonNull; - -import java.util.Map; -import java.util.concurrent.TimeUnit; -import javax.annotation.PreDestroy; -import javax.inject.Inject; -import javax.inject.Singleton; -import org.opendaylight.controller.config.threadpool.ThreadPool; -import org.opendaylight.controller.config.threadpool.util.FlexibleThreadPoolWrapper; -import org.osgi.service.component.annotations.Activate; -import org.osgi.service.component.annotations.Component; -import org.osgi.service.component.annotations.Deactivate; - -@Singleton -@Component(factory = GlobalNetconfProcessingExecutor.FACTORY_NAME, service = ThreadPool.class) -public final class GlobalNetconfProcessingExecutor extends FlexibleThreadPoolWrapper { - public static final String OSGI_TYPE = "global-netconf-processing-executor"; - public static final int DEFAULT_MIN_THREAD_COUNT = 1; - public static final int DEFAULT_MAX_THREAD_COUNT = 4; - public static final long DEFAULT_KEEPALIVE_MILLIS = 600000; - - // OSGi DS Component Factory name - static final String FACTORY_NAME = "org.opendaylight.netconf.config.GlobalNetconfProcessingExecutor"; - - private static final String PROP_KEEPALIVE = ".keepAlive"; - private static final String PROP_MIN_THREAD_COUNT = ".minThreadCount"; - private static final String PROP_MAX_THREAD_COUNT = ".maxThreadCount"; - private static final String PROP_THREAD_FACTORY = ".threadFactory"; - - public GlobalNetconfProcessingExecutor(final GlobalNetconfThreadFactory threadFactory, final int minThreadCount, - final int maxThreadCount, final long keepAliveMillis) { - super(minThreadCount, maxThreadCount, keepAliveMillis, TimeUnit.MILLISECONDS, threadFactory); - } - - @Inject - public GlobalNetconfProcessingExecutor(final GlobalNetconfThreadFactory threadFactory) { - this(threadFactory, DEFAULT_MIN_THREAD_COUNT, DEFAULT_MAX_THREAD_COUNT, DEFAULT_KEEPALIVE_MILLIS); - } - - @Activate - public GlobalNetconfProcessingExecutor(final Map properties) { - this(GlobalNetconfConfiguration.extractProp(properties, PROP_THREAD_FACTORY, GlobalNetconfThreadFactory.class), - GlobalNetconfConfiguration.extractProp(properties, PROP_MIN_THREAD_COUNT, Integer.class), - GlobalNetconfConfiguration.extractProp(properties, PROP_MAX_THREAD_COUNT, Integer.class), - GlobalNetconfConfiguration.extractProp(properties, PROP_KEEPALIVE, Long.class)); - } - - @Override - @PreDestroy - @Deactivate - public void close() { - super.close(); - } - - static Map props(final GlobalNetconfThreadFactory threadFactory, final Configuration configuration) { - return Map.of( - "type", OSGI_TYPE, - PROP_THREAD_FACTORY, requireNonNull(threadFactory), - PROP_KEEPALIVE, configuration.keep$_$alive$_$millis$_$flexible$_$thread$_$pool(), - PROP_MIN_THREAD_COUNT, configuration.min$_$thread$_$count$_$flexible$_$thread$_$pool(), - PROP_MAX_THREAD_COUNT, configuration.max$_$thread$_$count$_$flexible$_$thread$_$pool()); - } -} diff --git a/netconf/netconf-config/src/main/java/org/opendaylight/netconf/config/GlobalNetconfThreadFactory.java b/netconf/netconf-config/src/main/java/org/opendaylight/netconf/config/GlobalNetconfThreadFactory.java deleted file mode 100644 index 4cf4672781..0000000000 --- a/netconf/netconf-config/src/main/java/org/opendaylight/netconf/config/GlobalNetconfThreadFactory.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.netconf.config; - -import javax.inject.Inject; -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.opendaylight.controller.config.threadpool.util.NamingThreadPoolFactory; - -/** - * Shared {@link NamingThreadPoolFactory} for {@link GlobalNetconfProcessingExecutor}. - */ -@NonNullByDefault -public final class GlobalNetconfThreadFactory extends NamingThreadPoolFactory { - public static final String DEFAULT_NAME_PREFIX = "remote-connector-processing-executor"; - - public GlobalNetconfThreadFactory(final String namePrefix) { - super(namePrefix); - } - - @Inject - public GlobalNetconfThreadFactory() { - this(DEFAULT_NAME_PREFIX); - } -} diff --git a/netconf/pom.xml b/netconf/pom.xml index 7dd3f5b2be..62d08f5de9 100644 --- a/netconf/pom.xml +++ b/netconf/pom.xml @@ -29,7 +29,6 @@ - netconf-config netconf-netty-util netconf-auth yanglib -- 2.36.6