Search in sources :

Example 1 with NetconfStateSchemasResolverImpl

use of org.opendaylight.netconf.sal.connect.netconf.NetconfStateSchemasResolverImpl in project netconf by opendaylight.

the class DefaultSchemaResourceManager method createResources.

@NonNull
private SchemaResourcesDTO createResources(final String subdir) {
    // Setup the baseline empty registry
    final SharedSchemaRepository repository = new SharedSchemaRepository(subdir, parserFactory);
    // Teach the registry how to transform YANG text to IRSchemaSource internally
    repository.registerSchemaSourceListener(TextToIRTransformer.create(repository, repository));
    // Attach a soft cache of IRSchemaSource instances. This is important during convergence when we are fishing
    // for a consistent set of modules, as it skips the need to re-parse the text sources multiple times. It also
    // helps establishing different sets of contexts, as they can share this pre-made cache.
    repository.registerSchemaSourceListener(// FIXME: add knobs to control cache lifetime explicitly
    GuavaSchemaSourceCache.createSoftCache(repository, IRSchemaSource.class));
    // Attach the filesystem cache, providing persistence capability, so that restarts do not require us to
    // re-populate the cache. This also acts as a side-load capability, as anything pre-populated into that
    // directory will not be fetched from the device.
    repository.registerSchemaSourceListener(new FilesystemSchemaSourceCache<>(repository, YangTextSchemaSource.class, new File(rootDirectory + File.separator + subdir)));
    return new SchemaResourcesDTO(repository, repository, repository.createEffectiveModelContextFactory(SchemaContextFactoryConfiguration.getDefault()), new NetconfStateSchemasResolverImpl());
}
Also used : IRSchemaSource(org.opendaylight.yangtools.yang.parser.rfc7950.ir.IRSchemaSource) YangTextSchemaSource(org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource) NetconfStateSchemasResolverImpl(org.opendaylight.netconf.sal.connect.netconf.NetconfStateSchemasResolverImpl) File(java.io.File) SharedSchemaRepository(org.opendaylight.yangtools.yang.parser.repo.SharedSchemaRepository) SchemaResourcesDTO(org.opendaylight.netconf.sal.connect.netconf.NetconfDevice.SchemaResourcesDTO) Objects.requireNonNull(java.util.Objects.requireNonNull) NonNull(org.eclipse.jdt.annotation.NonNull)

Aggregations

File (java.io.File)1 Objects.requireNonNull (java.util.Objects.requireNonNull)1 NonNull (org.eclipse.jdt.annotation.NonNull)1 SchemaResourcesDTO (org.opendaylight.netconf.sal.connect.netconf.NetconfDevice.SchemaResourcesDTO)1 NetconfStateSchemasResolverImpl (org.opendaylight.netconf.sal.connect.netconf.NetconfStateSchemasResolverImpl)1 YangTextSchemaSource (org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource)1 SharedSchemaRepository (org.opendaylight.yangtools.yang.parser.repo.SharedSchemaRepository)1 IRSchemaSource (org.opendaylight.yangtools.yang.parser.rfc7950.ir.IRSchemaSource)1