Class JdkAotCacheTraining
java.lang.Object
io.micronaut.maven.jdkaotcache.JdkAotCacheTraining
Trains a JDK AOT cache in a container of the training image that the
docker goal built with Jib. The
container runs the image's own entrypoint, with -XX:AOTCacheOutput and -XX:-UsePerfData in
JDK_JAVA_OPTIONS. What the application does in it is the TrainingRun:
- In a
loadrun, it loads its bean definitions and exits without starting. - In a
startrun, if its Micronaut version has the training-run switch, it starts, warms itself up and exits. It fails on a request without a response or with a status of 500 or more, and only warns about a status from 400 to 499, so its output is copied to the build log when there are training paths. - Otherwise, it starts, the warm-up script runs in the container with
docker execand the application is stopped with SIGTERM.
- Since:
- 5.1.0
- Author:
- Álvaro Sánchez-Mariscal
-
Constructor Summary
ConstructorsConstructorDescriptionJdkAotCacheTraining(DockerService dockerService, org.apache.maven.plugin.logging.Log log, List<String> trainingPaths, int timeoutSeconds, String networkMode) -
Method Summary
Modifier and TypeMethodDescriptionvoidtrain(String imageId, TrainingRun run, Path cacheFile) Runs the training image once and copies the cache it writes out of the container.validateTrainingPaths(List<String> paths)
-
Constructor Details
-
JdkAotCacheTraining
public JdkAotCacheTraining(DockerService dockerService, org.apache.maven.plugin.logging.Log log, List<String> trainingPaths, int timeoutSeconds, String networkMode) - Parameters:
dockerService- the Docker servicelog- the Maven logtrainingPaths- the paths of the warm-up GET requeststimeoutSeconds- the timeout of each step of the training runnetworkMode- the network of the training container, if any
-
-
Method Details
-
train
public void train(String imageId, TrainingRun run, Path cacheFile) throws org.apache.maven.plugin.MojoExecutionException Runs the training image once and copies the cache it writes out of the container.- Parameters:
imageId- the training imagerun- the training runcacheFile- where to write the cache- Throws:
org.apache.maven.plugin.MojoExecutionException- if the training fails
-
validateTrainingPaths
public static List<String> validateTrainingPaths(List<String> paths) throws org.apache.maven.plugin.MojoExecutionException - Parameters:
paths- the configured training paths- Returns:
- the paths, trimmed
- Throws:
org.apache.maven.plugin.MojoExecutionException- if a path is not an absolute request path
-