Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not expose model context #1840

Merged
merged 1 commit into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService;
import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipService;
import org.opendaylight.mdsal.singleton.api.ClusterSingletonServiceProvider;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -64,7 +63,6 @@ protected void configure() {
.toInstance(lightyServices.getDiagStatusService());
bind(ActorSystemProvider.class)
.toInstance(lightyServices.getActorSystemProvider());
bind(EffectiveModelContext.class).toInstance(lightyServices.getEffectiveModelContext());
bind(DOMSchemaService.class)
.toInstance(lightyServices.getDOMSchemaService());
bind(DOMSchemaService.YangTextSourceExtension.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ public class TestService {
@Inject
private ActorSystemProvider actorSystemProvider;

@Inject
private EffectiveModelContext effectiveModelContext;

@Inject
private DOMSchemaService domSchemaService;

Expand Down Expand Up @@ -156,7 +153,7 @@ public ActorSystemProvider getActorSystemProvider() {
}

public EffectiveModelContext getSchemaContext() {
return effectiveModelContext;
return getDomSchemaService().getGlobalContext();
}

public DOMSchemaService getDomSchemaService() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService;
import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipService;
import org.opendaylight.mdsal.singleton.api.ClusterSingletonServiceProvider;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
Expand Down Expand Up @@ -138,11 +137,6 @@ public ActorSystemProvider actorSystemProvider() {
return this.lightyController.getServices().getActorSystemProvider();
}

@Bean(destroyMethod = "")
public EffectiveModelContext effectiveModelContext() {
return this.lightyController.getServices().getEffectiveModelContext();
}

@Bean(destroyMethod = "")
@Primary
public DOMSchemaService domSchemaService() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService;
import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipService;
import org.opendaylight.mdsal.singleton.api.ClusterSingletonServiceProvider;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -79,9 +78,6 @@ public class LightyCoreSpringConfigurationTest extends AbstractJUnit4SpringConte
@Autowired
ActorSystemProvider actorSystemProviderTestProperty;

@Autowired
EffectiveModelContext effectiveModelContext;

@Autowired
DOMSchemaService domSchemaServiceTestProperty;

Expand Down Expand Up @@ -177,7 +173,6 @@ public void testLightyBeansExists() {
assertNotNull(lightyModuleRegistryServiceTestProperty);
assertNotNull(diagStatusServiceTestProperty);
assertNotNull(actorSystemProviderTestProperty);
assertNotNull(effectiveModelContext);
assertNotNull(domSchemaServiceTestProperty);
assertNotNull(domYangTextSourceProviderTestProperty);
assertNotNull(domMountPointServiceTestProperty);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService;
import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipService;
import org.opendaylight.mdsal.singleton.api.ClusterSingletonServiceProvider;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.parser.api.YangParserFactory;

/**
Expand All @@ -61,8 +60,6 @@ public interface LightyServices extends LightyModuleRegistryService {

ActorSystemProvider getActorSystemProvider();

EffectiveModelContext getEffectiveModelContext();

DOMSchemaService getDOMSchemaService();

DOMSchemaService.YangTextSourceExtension getYangTextSourceExtension();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import akka.actor.Terminated;
import akka.management.javadsl.AkkaManagement;
import com.google.common.base.Stopwatch;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.Futures;
import com.typesafe.config.Config;
import io.lighty.codecs.util.exception.DeserializationException;
import io.lighty.core.cluster.ClusteringHandler;
Expand Down Expand Up @@ -122,8 +122,7 @@
import org.opendaylight.yangtools.util.DurationStatisticsTracker;
import org.opendaylight.yangtools.util.concurrent.SpecialExecutors;
import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.source.YangTextSource;
import org.opendaylight.yangtools.yang.model.repo.api.MissingSchemaSourceException;
import org.opendaylight.yangtools.yang.parser.api.YangParserFactory;
import org.opendaylight.yangtools.yang.parser.impl.DefaultYangParserFactory;
import org.opendaylight.yangtools.yang.xpath.api.YangXPathParserFactory;
Expand Down Expand Up @@ -273,8 +272,13 @@ protected boolean initProcedure() {
this.snapshotResolver = new ModuleInfoSnapshotResolver("binding-dom-codec", yangParserFactory);
this.modelsRegistration = snapshotResolver.registerModuleInfos(modelSet);
this.moduleInfoSnapshot = snapshotResolver.takeSnapshot();
this.schemaService = new FixedDOMSchemaService(this::getEffectiveModelContext,
sourceId -> (ListenableFuture<YangTextSource>) moduleInfoSnapshot.yangTextSource(sourceId));
this.schemaService = new FixedDOMSchemaService(() -> moduleInfoSnapshot.modelContext(), sourceId -> {
try {
return Futures.immediateFuture(moduleInfoSnapshot.getYangTextSource(sourceId));
} catch (MissingSchemaSourceException e) {
return Futures.immediateFailedFuture(e);
}
});

// INIT CODEC FACTORY

Expand Down Expand Up @@ -359,7 +363,7 @@ protected boolean initProcedure() {
final InitialConfigData initialData = this.initialConfigData.get();
try (InputStream inputStream = initialData.getAsInputStream()) {
FileToDatastoreUtils.importConfigDataFile(inputStream, initialData.getFormat(),
getEffectiveModelContext(), this.getClusteredDOMDataBroker(), true);
moduleInfoSnapshot.modelContext(), this.getClusteredDOMDataBroker(), true);
} catch (TimeoutException | ExecutionException | IOException | DeserializationException e) {
LOG.error("Exception occurred while importing config data from file", e);
return false;
Expand Down Expand Up @@ -504,11 +508,6 @@ public ActorSystemProvider getActorSystemProvider() {
return this.actorSystemProvider;
}

@Override
public EffectiveModelContext getEffectiveModelContext() {
return this.moduleInfoSnapshot.modelContext();
}

@Override
public DOMSchemaService getDOMSchemaService() {
return this.schemaService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public void controllerSimpleTest() {
lightyController.getServices().getDiagStatusService().getAllServiceDescriptors());
Assert.assertNotNull(lightyController.getServices().getActorSystemProvider());
Assert.assertNotNull(lightyController.getServices().getActorSystemProvider().getActorSystem());
Assert.assertNotNull(lightyController.getServices().getEffectiveModelContext());
Assert.assertNotNull(lightyController.getServices().getDOMSchemaService());
Assert.assertNotNull(lightyController.getServices().getYangTextSourceExtension());
Assert.assertNotNull(lightyController.getServices().getDOMNotificationRouter());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ private void importFile(final String path, final YangInstanceIdentifier yii, fin
FileToDatastoreUtils.importConfigDataFile(FileToDatastoreUtils.class.getResourceAsStream(path),
yii,
format,
lightyController.getServices().getEffectiveModelContext(),
lightyController.getServices().getDOMSchemaService().getGlobalContext(),
lightyController.getServices().getClusteredDOMDataBroker(),
true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public BgpModule(final EffectiveModelContext modelContext, final DataBroker data
}

public BgpModule(final LightyServices lightyServices) {
this(lightyServices.getEffectiveModelContext(),
this(lightyServices.getDOMSchemaService().getGlobalContext(),
lightyServices.getBindingDataBroker(), lightyServices.getClusteredDOMDataBroker(),
lightyServices.getBindingCodecTreeFactory(),
lightyServices.getAdapterContext().currentSerializer().getRuntimeContext(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public void loadTopLevelSingleNodeModelsFromJsonConfig() throws Exception {
final LightyController lightyController = getLightyController("sampleConfigSingleNode.json");
assertTrue(lightyController.start().get(TIME_OUT, TimeUnit.SECONDS));

final int loadedModulesSize = lightyController.getServices().getEffectiveModelContext().getModules().size();
final int loadedModulesSize = lightyController.getServices().getDOMSchemaService().getGlobalContext()
.getModules().size();
assertTrue(lightyController.shutdown(TIME_OUT, TimeUnit.SECONDS));

assertEquals(loadedModulesSize, 17);
Expand All @@ -40,7 +41,8 @@ public void loadTopLevelClusterModelsFromJsonConfig() throws Exception {
final LightyController lightyController = getLightyController("sampleConfigCluster.json");
assertTrue(lightyController.start().get(TIME_OUT, TimeUnit.SECONDS));

final int loadedModulesSize = lightyController.getServices().getEffectiveModelContext().getModules().size();
final int loadedModulesSize = lightyController.getServices().getDOMSchemaService().getGlobalContext()
.getModules().size();
assertTrue(lightyController.shutdown(TIME_OUT, TimeUnit.SECONDS));

assertEquals(loadedModulesSize, 17);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void patchDataReplaceTest() throws Exception {
final PatchContext patchContext = new PatchContext("test-patch", List.of(entityReplace));

final var strategy = new MdsalRestconfStrategy(DatabindContext.ofModel(getLightyController()
.getServices().getEffectiveModelContext()), getLightyController().getServices()
.getServices().getDOMSchemaService().getGlobalContext()), getLightyController().getServices()
.getClusteredDOMDataBroker(), getLightyController().getServices().getDOMRpcService(),
getLightyController().getServices()
.getDOMActionService(), getLightyController().getServices().getYangTextSourceExtension(),
Expand Down
Loading