Class DBPrepareProgressReporter

  • All Implemented Interfaces:

    
    public final class DBPrepareProgressReporter
    
                        

    Reads the preparation progress of the dbPrepare process running inside the container and reports it as a rendered progress bar.

    The dbPrepare process exposes its progress as JMX attributes instead of writing them to its output, so that the progress cannot interfere with the log output. Unlike a locally started process, a process inside a container cannot be attached to by its process id, so it is read through the JMX connector of the container. The connector is enabled by the environment variable ENABLE_JMX, see the entrypoint of the ICM-AS image.

    All errors are handled silently: the progress is purely informational and must never fail the build.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Unit start() Starts reading the progress in the background.
      final Unit stop() Stops reading the progress and releases the connection to the container.
      final static String render(Integer percent, Integer processed, Integer total, String cartridge, String step) Renders the progress bar shown in Gradle's status line.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DBPrepareProgressReporter

        DBPrepareProgressReporter(String host, Integer port, Function1<String, Unit> onProgress)
        Parameters:
        host - the host the JMX connector of the container is reachable at
        port - the port the JMX connector of the container is published to
        onProgress - consumer of the rendered progress bar
    • Method Detail

      • start

         final Unit start()

        Starts reading the progress in the background.

      • stop

         final Unit stop()

        Stops reading the progress and releases the connection to the container.

      • render

         final static String render(Integer percent, Integer processed, Integer total, String cartridge, String step)

        Renders the progress bar shown in Gradle's status line.

        Parameters:
        percent - the progress in percent
        processed - the number of executed preparation steps
        total - the number of preparation steps expected to be executed
        cartridge - the path of the cartridge of the current step, may be null or empty
        step - the name of the current step, may be null or empty
        Returns:

        the rendered progress bar