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()));
// 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 {}",
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);
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);
}
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;