Class JdkAotCacheTraining

java.lang.Object
io.micronaut.maven.jdkaotcache.JdkAotCacheTraining

@Internal public final class JdkAotCacheTraining extends Object
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 load run, it loads its bean definitions and exits without starting.
  • In a start run, 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 exec and the application is stopped with SIGTERM.
Since:
5.1.0
Author:
Álvaro Sánchez-Mariscal
  • 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 service
      log - the Maven log
      trainingPaths - the paths of the warm-up GET requests
      timeoutSeconds - the timeout of each step of the training run
      networkMode - 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 image
      run - the training run
      cacheFile - 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