Move YangLibrarySchemaYangSourceProvider 99/105799/8
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 2 May 2023 23:43:46 +0000 (01:43 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 3 May 2023 10:46:07 +0000 (12:46 +0200)
Rename and move YangLibrarySchemaYangSourceProvider to
netconf.client.mdsal.

JIRA: NETCONF-1006
Change-Id: Idcd268f964df6c831dee06b3232518d26b40f75e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
apps/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/RemoteDeviceConnectorImpl.java
apps/netconf-topology/src/main/java/org/opendaylight/netconf/topology/spi/AbstractNetconfTopology.java
plugins/netconf-client-mdsal/src/main/java/org/opendaylight/netconf/client/mdsal/DeviceSourcesResolver.java
plugins/netconf-client-mdsal/src/main/java/org/opendaylight/netconf/client/mdsal/LibrarySchemaSourceProvider.java [moved from plugins/netconf-client-mdsal/src/main/java/org/opendaylight/netconf/sal/connect/netconf/schema/YangLibrarySchemaYangSourceProvider.java with 78% similarity]
plugins/netconf-client-mdsal/src/test/java/org/opendaylight/netconf/client/mdsal/LibrarySchemaYangSourceProviderTest.java [moved from plugins/netconf-client-mdsal/src/test/java/org/opendaylight/netconf/sal/connect/netconf/schema/YangLibrarySchemaYangSourceProviderTest.java with 88% similarity]

index 16c68c12a3ac01c135ce08a26b8fd357923aebc7..bfb03876dfa9260495639b4cc9078fdc19c48a25 100644 (file)
@@ -27,6 +27,7 @@ import org.opendaylight.netconf.client.conf.NetconfReconnectingClientConfigurati
 import org.opendaylight.netconf.client.conf.NetconfReconnectingClientConfigurationBuilder;
 import org.opendaylight.netconf.client.mdsal.DatastoreBackedPublicKeyAuth;
 import org.opendaylight.netconf.client.mdsal.LibraryModulesSchemas;
+import org.opendaylight.netconf.client.mdsal.LibrarySchemaSourceProvider;
 import org.opendaylight.netconf.client.mdsal.NetconfDevice;
 import org.opendaylight.netconf.client.mdsal.NetconfDeviceBuilder;
 import org.opendaylight.netconf.client.mdsal.SchemalessNetconfDevice;
@@ -41,7 +42,6 @@ import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.LoginPasswo
 import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCommunicator;
 import org.opendaylight.netconf.sal.connect.netconf.sal.KeepaliveSalFacade;
 import org.opendaylight.netconf.sal.connect.netconf.sal.NetconfKeystoreAdapter;
-import org.opendaylight.netconf.sal.connect.netconf.schema.YangLibrarySchemaYangSourceProvider;
 import org.opendaylight.netconf.sal.connect.util.SslHandlerFactoryImpl;
 import org.opendaylight.netconf.topology.singleton.api.RemoteDeviceConnector;
 import org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup;
@@ -172,7 +172,7 @@ public class RemoteDeviceConnectorImpl implements RemoteDeviceConnector {
                         libraryModulesSchemas.getAvailableModels().entrySet()) {
                     registeredYangLibSources
                             .add(schemaResourcesDTO.getSchemaRegistry().registerSchemaSource(
-                                    new YangLibrarySchemaYangSourceProvider(remoteDeviceId,
+                                    new LibrarySchemaSourceProvider(remoteDeviceId,
                                             libraryModulesSchemas.getAvailableModels()),
                                     PotentialSchemaSource
                                             .create(sourceIdentifierURLEntry.getKey(), YangTextSchemaSource.class,
index d0ba57bc92d687673f1a61a064ee740395ef28ec..cdd83ad090518dba19512f0b2ddebc68c42602f7 100644 (file)
@@ -36,6 +36,7 @@ import org.opendaylight.netconf.client.conf.NetconfReconnectingClientConfigurati
 import org.opendaylight.netconf.client.conf.NetconfReconnectingClientConfigurationBuilder;
 import org.opendaylight.netconf.client.mdsal.DatastoreBackedPublicKeyAuth;
 import org.opendaylight.netconf.client.mdsal.LibraryModulesSchemas;
+import org.opendaylight.netconf.client.mdsal.LibrarySchemaSourceProvider;
 import org.opendaylight.netconf.client.mdsal.NetconfDevice.SchemaResourcesDTO;
 import org.opendaylight.netconf.client.mdsal.NetconfDeviceBuilder;
 import org.opendaylight.netconf.client.mdsal.SchemalessNetconfDevice;
@@ -51,7 +52,6 @@ import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.LoginPasswo
 import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCommunicator;
 import org.opendaylight.netconf.sal.connect.netconf.sal.KeepaliveSalFacade;
 import org.opendaylight.netconf.sal.connect.netconf.sal.NetconfKeystoreAdapter;
-import org.opendaylight.netconf.sal.connect.netconf.schema.YangLibrarySchemaYangSourceProvider;
 import org.opendaylight.netconf.sal.connect.netconf.schema.mapping.BaseNetconfSchemas;
 import org.opendaylight.netconf.sal.connect.util.SslHandlerFactoryImpl;
 import org.opendaylight.netconf.topology.api.NetconfTopology;
@@ -284,7 +284,7 @@ public abstract class AbstractNetconfTopology implements NetconfTopology {
                 }
 
                 for (final Map.Entry<SourceIdentifier, URL> entry : schemas.getAvailableModels().entrySet()) {
-                    registrations.add(schemaRegistry.registerSchemaSource(new YangLibrarySchemaYangSourceProvider(
+                    registrations.add(schemaRegistry.registerSchemaSource(new LibrarySchemaSourceProvider(
                         remoteDeviceId, schemas.getAvailableModels()),
                         PotentialSchemaSource.create(entry.getKey(), YangTextSchemaSource.class,
                             PotentialSchemaSource.Costs.REMOTE_IO.getValue())));
index 5a91a077065d1eabef9cf615dd6070aa20017bba..759b900dbdd87dfb913b7eb46cc14c753a4238ae 100644 (file)
@@ -16,7 +16,6 @@ import org.opendaylight.netconf.client.mdsal.api.NetconfDeviceSchemasResolver;
 import org.opendaylight.netconf.client.mdsal.api.RemoteDeviceId;
 import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences;
 import org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceRpc;
-import org.opendaylight.netconf.sal.connect.netconf.schema.YangLibrarySchemaYangSourceProvider;
 import org.opendaylight.netconf.sal.connect.netconf.schema.mapping.BaseSchema;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -74,7 +73,7 @@ final class DeviceSourcesResolver implements Callable<DeviceSources> {
         }
 
         final var sourceProvider = availableSchemas instanceof LibraryModulesSchemas libraryModule
-            ? new YangLibrarySchemaYangSourceProvider(id, libraryModule.getAvailableModels())
+            ? new LibrarySchemaSourceProvider(id, libraryModule.getAvailableModels())
                 : new MonitoringSchemaSourceProvider(id, deviceRpc);
         return new DeviceSources(requiredSources, providedSources, sourceProvider);
     }
@@ -5,7 +5,7 @@
  * 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.sal.connect.netconf.schema;
+package org.opendaylight.netconf.client.mdsal;
 
 import static com.google.common.base.Preconditions.checkArgument;
 import static java.util.Objects.requireNonNull;
@@ -16,7 +16,6 @@ import com.google.common.util.concurrent.ListenableFuture;
 import java.io.IOException;
 import java.net.URL;
 import java.util.Map;
-import org.opendaylight.netconf.client.mdsal.CachedYangTextSchemaSource;
 import org.opendaylight.netconf.client.mdsal.api.RemoteDeviceId;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
@@ -26,16 +25,16 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Provides YANG schema sources from yang library.
+ * Provides YANG schema sources from YANG library. The set of available sources is pre-determined when this provider
+ * is created, but each source is acquired on demand.
  */
-public final class YangLibrarySchemaYangSourceProvider implements SchemaSourceProvider<YangTextSchemaSource> {
-    private static final Logger LOG = LoggerFactory.getLogger(YangLibrarySchemaYangSourceProvider.class);
+public final class LibrarySchemaSourceProvider implements SchemaSourceProvider<YangTextSchemaSource> {
+    private static final Logger LOG = LoggerFactory.getLogger(LibrarySchemaSourceProvider.class);
 
     private final ImmutableMap<SourceIdentifier, URL> availableSources;
     private final RemoteDeviceId id;
 
-    public YangLibrarySchemaYangSourceProvider(final RemoteDeviceId id,
-            final Map<SourceIdentifier, URL> availableSources) {
+    public LibrarySchemaSourceProvider(final RemoteDeviceId id, final Map<SourceIdentifier, URL> availableSources) {
         this.id = requireNonNull(id);
         this.availableSources = ImmutableMap.copyOf(availableSources);
     }
@@ -54,8 +53,7 @@ public final class YangLibrarySchemaYangSourceProvider implements SchemaSourcePr
                 "Unable to download remote schema for " + sourceIdentifier + " from " + url, e));
         }
 
-        final var yangSource = new CachedYangTextSchemaSource(id, sourceIdentifier,
-            url.toString(), schemaContent);
+        final var yangSource = new CachedYangTextSchemaSource(id, sourceIdentifier, url.toString(), schemaContent);
         LOG.debug("Source {} downloaded from a yang library's url {}", sourceIdentifier, url);
         return Futures.immediateFuture(yangSource);
     }
@@ -5,7 +5,7 @@
  * 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.sal.connect.netconf.schema;
+package org.opendaylight.netconf.client.mdsal;
 
 import static org.hamcrest.CoreMatchers.containsString;
 import static org.hamcrest.CoreMatchers.instanceOf;
@@ -24,14 +24,14 @@ import org.opendaylight.netconf.client.mdsal.api.RemoteDeviceId;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 
-public class YangLibrarySchemaYangSourceProviderTest {
+public class LibrarySchemaYangSourceProviderTest {
     private SourceIdentifier workingSid;
-    private YangLibrarySchemaYangSourceProvider yangLibrarySchemaYangSourceProvider;
+    private LibrarySchemaSourceProvider yangLibrarySchemaYangSourceProvider;
 
     @Before
     public void setUp() throws Exception {
         workingSid = new SourceIdentifier("abc");
-        yangLibrarySchemaYangSourceProvider = new YangLibrarySchemaYangSourceProvider(
+        yangLibrarySchemaYangSourceProvider = new LibrarySchemaSourceProvider(
             new RemoteDeviceId("id", new InetSocketAddress("localhost", 22)),
             Map.of(workingSid, getClass().getResource("/schemas/config-test-rpc.yang")));
     }
@@ -46,7 +46,7 @@ public class YangLibrarySchemaYangSourceProviderTest {
     @Test
     public void testGetSourceFailure() throws InterruptedException, MalformedURLException {
         final var sourceIdentifierURLMap = Map.of(workingSid, new URL("http://non-existing-entity.yang"));
-        final var failingYangLibrarySchemaYangSourceProvider = new YangLibrarySchemaYangSourceProvider(
+        final var failingYangLibrarySchemaYangSourceProvider = new LibrarySchemaSourceProvider(
             new RemoteDeviceId("id", new InetSocketAddress("localhost", 22)), sourceIdentifierURLMap);
 
         final var future = failingYangLibrarySchemaYangSourceProvider.getSource(workingSid);