BUG 5089: Fix incorrect slave schema repo behaviour 21/34321/1
authorTomas Cere <tcere@cisco.com>
Mon, 8 Feb 2016 12:49:11 +0000 (13:49 +0100)
committerTomas Cere <tcere@cisco.com>
Tue, 9 Feb 2016 13:33:42 +0000 (13:33 +0000)
Need to use the correct schema repo in slave schema providers.
Introduced by the patch for BUG 4577.

Change-Id: Iba64841ba0f2f875f4da455cb3025266cf7b6c5e
Signed-off-by: Tomas Cere <tcere@cisco.com>
(cherry picked from commit 0dbc2a1f8597733e72086b0e9dfa191089e3eeab)

opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/util/BaseTopologyManager.java
opendaylight/netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/AbstractNetconfTopology.java
opendaylight/netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/impl/ClusteredNetconfTopology.java
opendaylight/netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/pipeline/ClusteredNetconfDevice.java

index 682555ef931145313f471e551c1ad6757249aa9c..664814223e666830c7346a68229d68ff23eb2e9f 100644 (file)
@@ -603,7 +603,7 @@ public final class BaseTopologyManager
         Futures.addCallback(read, new FutureCallback<Optional<Topology>>() {
             @Override
             public void onSuccess(Optional<Topology> result) {
-                if (result.isPresent()) {
+                if (result.isPresent() && result.get().getNode() != null) {
                     for (final Node node : result.get().getNode()) {
                         final Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry = codecRegistry.toNormalizedNode(getNodeIid(topologyId), node);
                         peer.onRemoteNodeCreated(new NormalizedNodeMessage(entry.getKey(), entry.getValue()));
index de0dc6921577e3356c57cc7550494d409b93e9ae..a72a702c3a3fa7b948cacb22e09faf15ee9e3506 100644 (file)
@@ -300,17 +300,13 @@ public abstract class AbstractNetconfTopology implements NetconfTopology, Bindin
                 // Multiple modules may be created at once;  synchronize to avoid issues with data consistency among threads.
                 synchronized(schemaResourcesDTOs) {
                     // Look for the cached DTO to reuse SchemaRegistry and SchemaContextFactory variables if they already exist
-                    final NetconfDevice.SchemaResourcesDTO dto =
-                            schemaResourcesDTOs.get(moduleSchemaCacheDirectory);
-                    if (dto == null) {
+                    schemaResourcesDTO = schemaResourcesDTOs.get(moduleSchemaCacheDirectory);
+                    if (schemaResourcesDTO == null) {
                         schemaResourcesDTO = createSchemaResourcesDTO(moduleSchemaCacheDirectory, nodeId.getValue());
-                        schemaRegistry.registerSchemaSourceListener(
-                                TextToASTTransformer.create((SchemaRepository) schemaRegistry, schemaRegistry));
+                        schemaResourcesDTO.getSchemaRegistry().registerSchemaSourceListener(
+                                TextToASTTransformer.create((SchemaRepository) schemaResourcesDTO.getSchemaRegistry(), schemaResourcesDTO.getSchemaRegistry())
+                        );
                         schemaResourcesDTOs.put(moduleSchemaCacheDirectory, schemaResourcesDTO);
-                    } else {
-                        setSchemaContextFactory(dto.getSchemaContextFactory());
-                        setSchemaRegistry(dto.getSchemaRegistry());
-                        schemaResourcesDTO = dto;
                     }
                 }
                 LOG.info("Netconf connector for device {} will use schema cache directory {} instead of {}",
@@ -338,7 +334,7 @@ public abstract class AbstractNetconfTopology implements NetconfTopology, Bindin
     private NetconfDevice.SchemaResourcesDTO createSchemaResourcesDTO(final String moduleSchemaCacheDirectory,
             final String instanceName) {
 
-        final SharedSchemaRepository repository = new SharedSchemaRepository(instanceName);
+        final SharedSchemaRepository repository = new SharedSchemaRepository(moduleSchemaCacheDirectory);
         final SchemaContextFactory schemaContextFactory
                 = repository.createSchemaContextFactory(SchemaSourceFilter.ALWAYS_ACCEPT);
         setSchemaRegistry(repository);
index 738728406172a4f715100c7b6f1b90afb3744aa1..76656b467435baa459a930e67705235b1f6970bf 100644 (file)
@@ -160,7 +160,7 @@ public class ClusteredNetconfTopology extends AbstractNetconfTopology implements
         final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO = setupSchemaCacheDTO(nodeId, node);
 
         final NetconfDevice device = new ClusteredNetconfDevice(schemaResourcesDTO, remoteDeviceId, salFacade,
-                processingExecutor.getExecutor(), sharedSchemaRepository, actorSystem, topologyId, nodeId.getValue(), TypedActor.context());
+                processingExecutor.getExecutor(), actorSystem, topologyId, nodeId.getValue(), TypedActor.context());
 
         return new NetconfConnectorDTO(new ClusteredNetconfDeviceCommunicator(remoteDeviceId, device, entityOwnershipService), salFacade);
     }
index 0040c551a23c016369303ea124924c5c9c6a9576..3a838ace21ac154c13f2de85f550e60f8f23ea4e 100644 (file)
@@ -59,10 +59,10 @@ public class ClusteredNetconfDevice extends NetconfDevice implements EntityOwner
     private ClusteredDeviceSourcesResolver resolver = null;
 
     public ClusteredNetconfDevice(final SchemaResourcesDTO schemaResourcesDTO, final RemoteDeviceId id, final RemoteDeviceHandler<NetconfSessionPreferences> salFacade,
-                                  final ExecutorService globalProcessingExecutor, SchemaRepository schemaRepo, ActorSystem actorSystem, String topologyId, String nodeId,
+                                  final ExecutorService globalProcessingExecutor, final ActorSystem actorSystem, final String topologyId, final String nodeId,
                                   ActorContext cachedContext) {
         super(schemaResourcesDTO, id, salFacade, globalProcessingExecutor);
-        this.schemaRepo = schemaRepo;
+        this.schemaRepo = (SchemaRepository) schemaResourcesDTO.getSchemaRegistry();
         this.actorSystem = actorSystem;
         this.topologyId = topologyId;
         this.nodeId = nodeId;