INTO-CPS-Association / maestro

Maestro a Co-Simulation Orchestration Engine
20 stars 3 forks source link

Invoking Mastro2 CLI from WebAPI due to multithreading #362

Closed CThuleHansen closed 2 years ago

CThuleHansen commented 2 years ago

DSE is capable of running multiple simulations in parallel. The maestro2 web api is not thread safe and for this reason, a special method was implemented in the web api: executeViaCLI https://github.com/INTO-CPS-Association/maestro/blob/development/maestro-webapi/src/main/java/org/intocps/maestro/webapi/maestro2/Maestro2SimulationController.java#L311-L314

When this method is called between the requests create session and simulate, it will cause the simulate to spawn a new java process and launch the simulation via the CLI.

However, there is not automated testing for this. Therefore, after the Maestro2 CLI has been updated, this feature is broken. It has to be fixed here: https://github.com/INTO-CPS-Association/maestro/blob/development/maestro-webapi/src/main/java/org/intocps/maestro/webapi/maestro2/Maestro2SimulationController.java#L207-L250

gitting-around commented 2 years ago

As a workaround, to get it working when we are running with one thread, what you suggested @CThuleHansen works. In the DSE scripts I commented (locally): https://github.com/INTO-CPS-Association/dse_scripts/blob/35f9caeff3cd409589067b03da40ac6aa4cd7d28/scripts/COE_handler.py#L78, then it works.

FrederikPM commented 2 years ago

I encounter the following error with the JVM commands used for spawning the process: "Improperly specified VM option 'TieredStopAtLevel=1 '". I can see that this argument gets included from iterating "ManagementFactory.getRuntimeMXBean().getInputArguments()". If I do not include the specific option, other JVM commands also fails to be applied resulting in the JVM not being created. Do you have any ideas about this @CThuleHansen @lausdahl?

FrederikPM commented 2 years ago

The error I encountered was due to running Maestro in Intellij. I have pushed a possible fix to fpm/362, however I am not sure how to test it.

CThuleHansen commented 2 years ago
  1. Tried to run the test via mvn test?
  2. Run it via the web api via the external tester
  3. Separate the calling from generation of arguments and test what you can.

Leave the rest…. This is a rabbit Hole. For my sake 2. is fine.

Some things are just difficult to test directly 🙂