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

Avoid fetching the resource/extension on server if we know that the resource/extension does not exist #466

Open
antoinebhs opened this issue Oct 15, 2024 · 0 comments

Comments

@antoinebhs
Copy link
Collaborator

Describe the current behavior

In the simple test below with a network containing one generator "GEN" without extension, we could avoid fetching on server when the extension or equipment does not exist. We should "cache" the fact that the equipment/extension does not exist in the network. If it does not exist, we should not fetch from the server.

    @Test
    public void testExtensionGetIdentifiable() {
        try (NetworkStoreService service = createNetworkStoreService(randomServerPort)) {
            Network network = EurostagTutorialExample1Factory.create(service.getNetworkFactory());
            service.flush(network);
        }

        try (NetworkStoreService service = createNetworkStoreService(null, randomServerPort)) {
            Network network = service.getNetwork(service.getNetworkIds().keySet().iterator().next());
            Generator gen = network.getGenerator("GEN"); // fetch /networks/fbaeae14-65e9-4a85-91eb-bb96b186a9ab/0/generators/GEN
            network.getGenerator("GEN"); // does not fetch as already cached above
            network.getGenerator("GEN123"); // fetch /networks/fbaeae14-65e9-4a85-91eb-bb96b186a9ab/0/generators/GEN123 
            network.getGenerator("GEN123"); // fetch /networks/fbaeae14-65e9-4a85-91eb-bb96b186a9ab/0/generators/GEN123 
            network.getGenerator("GEN123"); // fetch /networks/fbaeae14-65e9-4a85-91eb-bb96b186a9ab/0/generators/GEN123 
            network.getGenerator("GEN123"); // fetch /networks/fbaeae14-65e9-4a85-91eb-bb96b186a9ab/0/generators/GEN123 
            gen.getExtension(ActivePowerControl.class); // fetch /networks/fbaeae14-65e9-4a85-91eb-bb96b186a9ab/0/identifiables/GEN/extensions/activePowerControl
            gen.getExtension(ActivePowerControl.class); // fetch /networks/fbaeae14-65e9-4a85-91eb-bb96b186a9ab/0/identifiables/GEN/extensions/activePowerControl
            gen.getExtension(ActivePowerControl.class); // fetch /networks/fbaeae14-65e9-4a85-91eb-bb96b186a9ab/0/identifiables/GEN/extensions/activePowerControl
            gen.getExtension(ActivePowerControl.class); // fetch /networks/fbaeae14-65e9-4a85-91eb-bb96b186a9ab/0/identifiables/GEN/extensions/activePowerControl
        }
    }

Describe the expected behavior

    @Test
    public void testExtensionGetIdentifiable() {
        try (NetworkStoreService service = createNetworkStoreService(randomServerPort)) {
            Network network = EurostagTutorialExample1Factory.create(service.getNetworkFactory());
            service.flush(network);
        }

        try (NetworkStoreService service = createNetworkStoreService(null, randomServerPort)) {
            Network network = service.getNetwork(service.getNetworkIds().keySet().iterator().next());
            Generator gen = network.getGenerator("GEN"); // fetch /networks/fbaeae14-65e9-4a85-91eb-bb96b186a9ab/0/generators/GEN
            network.getGenerator("GEN"); // does not fetch as already cached above
            network.getGenerator("GEN123"); // fetch /networks/fbaeae14-65e9-4a85-91eb-bb96b186a9ab/0/generators/GEN123 
            network.getGenerator("GEN123"); // does not fetch as we know it does not exist 
            network.getGenerator("GEN123"); // does not fetch as we know it does not exist
            network.getGenerator("GEN123"); // does not fetch as we know it does not exist
            gen.getExtension(ActivePowerControl.class); // fetch /networks/fbaeae14-65e9-4a85-91eb-bb96b186a9ab/0/identifiables/GEN/extensions/activePowerControl
            gen.getExtension(ActivePowerControl.class); // does not fetch as we know it does not exist
            gen.getExtension(ActivePowerControl.class); // does not fetch as we know it does not exist
            gen.getExtension(ActivePowerControl.class); // does not fetch as we know it does not exist
        }
    }

Describe the motivation

No response

Extra Information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant