Class Runner

java.lang.Object
org.jgrapes.core.internal.ComponentVertex
org.jgrapes.core.Component
org.jdrupes.vmoperator.runner.qemu.Runner
All Implemented Interfaces:
Iterable<org.jgrapes.core.ComponentType>, org.jgrapes.core.Channel, org.jgrapes.core.ComponentType, org.jgrapes.core.Eligible, org.jgrapes.core.Manager

public class Runner extends org.jgrapes.core.Component
The Runner is responsible for managing the Qemu process and optionally a process that emulates a TPM (software TPM).

It’s main function is best described by the following state diagram.

Runner state diagram

The Runner associates an EventProcessor with the Start event. This “runner event processor” must be used for all events related to the application level function. Components that handle events from other sources (and thus event processors) must fire any resulting events on the runner event processor in order to maintain synchronization.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.jgrapes.core.Channel

    org.jgrapes.core.Channel.Default
  • Field Summary

    Fields inherited from class org.jgrapes.core.Component

    logger

    Fields inherited from interface org.jgrapes.core.Channel

    BROADCAST, SELF
  • Constructor Summary

    Constructors
    Constructor
    Description
    Runner(org.apache.commons.cli.CommandLine cmdLine)
    Instantiates a new runner.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    main(String[] args)
    The main method.
    void
    onConfigurationUpdate(org.jgrapes.util.events.ConfigurationUpdate event)
    Process the initial configuration.
    void
    Whenever a new QEMU configuration is available, check if it is supposed to trigger a reset.
    void
    As last step when handling a new configuration, check if QEMU is suspended after startup and should be continued.
    void
    onExit(Exit event)
    On exit.
    void
    onFileChanged(org.jgrapes.util.events.FileChanged event)
    Watch for the creation of the swtpm socket and start the qemu process if it has been created.
    void
    onHandlingError(org.jgrapes.core.events.HandlingError event)
    Log the exception when a handling error is reported.
    void
    onInput(org.jgrapes.io.events.Input<?> event, org.jgrapes.io.process.ProcessManager.ProcessChannel channel)
    Forward output from the processes to to the log.
    void
    Receiving the OSinfo means that the OS has been booted.
    void
    onProcessExited(org.jgrapes.io.events.ProcessExited event, org.jgrapes.io.process.ProcessManager.ProcessChannel channel)
    On process exited.
    void
    onProcessStarted(org.jgrapes.io.events.ProcessStarted event, org.jgrapes.io.process.ProcessManager.ProcessChannel channel)
    Associate required data with the process channel and register the channel in the context.
    void
    Note ready state and send a ConfigureQemu event for any pending configuration (initial or change).
    void
    onStart(org.jgrapes.core.events.Start event)
    Handle the start event.
    void
    onStarted(org.jgrapes.core.events.Started event)
    Handle the started event.
    void
    onStopFirst(org.jgrapes.core.events.Stop event)
    On stop.
    void
    onStopLast(org.jgrapes.core.events.Stop event)
    On stop.

    Methods inherited from class org.jgrapes.core.Component

    channel, component, defaultCriterion, isEligibleFor, setName

    Methods inherited from class org.jgrapes.core.internal.ComponentVertex

    activeEventPipeline, addHandler, attach, channelReplacements, children, componentPath, componentVertex, detach, fire, initComponentsHandlers, iterator, name, newEventPipeline, newEventPipeline, parent, registerAsGenerator, root, toString, unregisterAsGenerator

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator

    Methods inherited from interface org.jgrapes.core.Manager

    stream
  • Constructor Details

    • Runner

      public Runner(org.apache.commons.cli.CommandLine cmdLine) throws IOException
      Instantiates a new runner.
      Parameters:
      cmdLine - the cmd line
      Throws:
      IOException - Signals that an I/O exception has occurred.
  • Method Details

    • onHandlingError

      @Handler(channels=org.jgrapes.core.Channel.class, priority=-10000) public void onHandlingError(org.jgrapes.core.events.HandlingError event)
      Log the exception when a handling error is reported.
      Parameters:
      event - the event
    • onConfigurationUpdate

      @Handler public void onConfigurationUpdate(org.jgrapes.util.events.ConfigurationUpdate event)
      Process the initial configuration.

      The initial configuration and any subsequent updates will be forwarded to other components only when the QMP connection is ready (see @link #onQmpConfigured(QmpConfigured)).

      Parameters:
      event - the event
    • onQmpConfigured

      @Handler public void onQmpConfigured(QmpConfigured event)
      Note ready state and send a ConfigureQemu event for any pending configuration (initial or change).
      Parameters:
      event - the event
    • onStart

      @Handler(priority=100) public void onStart(org.jgrapes.core.events.Start event)
      Handle the start event.
      Parameters:
      event - the event
    • onStarted

      @Handler public void onStarted(org.jgrapes.core.events.Started event)
      Handle the started event.
      Parameters:
      event - the event
    • onFileChanged

      @Handler public void onFileChanged(org.jgrapes.util.events.FileChanged event)
      Watch for the creation of the swtpm socket and start the qemu process if it has been created.
      Parameters:
      event - the event
    • onProcessStarted

      @Handler public void onProcessStarted(org.jgrapes.io.events.ProcessStarted event, org.jgrapes.io.process.ProcessManager.ProcessChannel channel) throws InterruptedException
      Associate required data with the process channel and register the channel in the context.
      Parameters:
      event - the event
      channel - the channel
      Throws:
      InterruptedException - the interrupted exception
    • onInput

      @Handler public void onInput(org.jgrapes.io.events.Input<?> event, org.jgrapes.io.process.ProcessManager.ProcessChannel channel)
      Forward output from the processes to to the log.
      Parameters:
      event - the event
      channel - the channel
    • onConfigureQemu

      @Handler public void onConfigureQemu(ConfigureQemu event)
      Whenever a new QEMU configuration is available, check if it is supposed to trigger a reset.
      Parameters:
      event - the event
    • onConfigureQemuFinal

      @Handler(priority=-1000) public void onConfigureQemuFinal(ConfigureQemu event)
      As last step when handling a new configuration, check if QEMU is suspended after startup and should be continued.
      Parameters:
      event - the event
    • onOsinfo

      @Handler public void onOsinfo(OsinfoEvent event)
      Receiving the OSinfo means that the OS has been booted.
      Parameters:
      event - the event
    • onProcessExited

      @Handler public void onProcessExited(org.jgrapes.io.events.ProcessExited event, org.jgrapes.io.process.ProcessManager.ProcessChannel channel)
      On process exited.
      Parameters:
      event - the event
      channel - the channel
    • onExit

      @Handler(priority=10001) public void onExit(Exit event)
      On exit.
      Parameters:
      event - the event
    • onStopFirst

      @Handler(priority=10000) public void onStopFirst(org.jgrapes.core.events.Stop event)
      On stop.
      Parameters:
      event - the event
    • onStopLast

      @Handler(priority=-10000) public void onStopLast(org.jgrapes.core.events.Stop event)
      On stop.
      Parameters:
      event - the event
    • main

      public static void main(String[] args)
      The main method.
      Parameters:
      args - the command