Class SimulationFactory

All Implemented Interfaces:
Runnable

public class SimulationFactory extends PauseableThread
Configuration, setup and baselining of simulations in this batch. This runs as a daemon thread and caches
  • Field Details

    • CACHE_SIZE

      public static int CACHE_SIZE
  • Method Details

    • startFactory

      public static SimulationFactory startFactory(List<SetupConfiguration> setups, List<ExecutionConfiguration> executions, String urnBase, SimulationMonitor mon)
    • setup

      public void setup()
      Description copied from class: PauseableThread
      Run on thread once at the start. Can setup thread local resources. Constructor can be used to set up shared resources.
      Specified by:
      setup in class PauseableThread
    • unpause

      public void unpause()
      Description copied from class: PauseableThread
      Non blocking unpause a thread. Nothing happens if the thread is not paused. Otherwise the thread will be woken up and resume executing doLoop() repeatedly, until isComplete() is true, or told to halt.
      Overrides:
      unpause in class PauseableThread
    • cacheFull

      public boolean cacheFull()
    • doLoop

      public void doLoop()
      Description copied from class: PauseableThread
      Repeatedly called while the thread is not paused or halting. This can interact with resources shared with other threads but needs to be synchronised on them (or use non blocking). This operates equivalent to a `while (!isComplete()) {doLoop();}`
      Specified by:
      doLoop in class PauseableThread
    • isComplete

      public boolean isComplete()
      Description copied from class: PauseableThread
      Signify the thread loop is complete and proceed to shutdown. This is checked even if the thread is paused.
      Specified by:
      isComplete in class PauseableThread
    • shutdown

      public void shutdown(boolean completedNormally)
      Description copied from class: PauseableThread
      Shutdown the thread. This must close down any resources and exit without error.
      Specified by:
      shutdown in class PauseableThread
      Parameters:
      completedNormally - did the loop complete or was the thread halted?
    • finished

      public boolean finished()
      There are no more simulations available.
      Returns:
      true if all the simulations have been created and consumed.
    • ready

      public boolean ready()
      Returns:
      true if the factory is ready to deliver a configured simulation for execution
    • increaseCacheSize

      public void increaseCacheSize(int items)
      Increase simulation queue if loads of memory and risk simulation waiting for factory.
      TODO: Parallelise the simulation factory. The cache being part of the factory is a problem because we can't parallelise it. Increasing the cache size probably wont improve performance if the factory is the limiting factor in the overall speed.
    • getSimulationSize

      public OptionalLong getSimulationSize()
      Returns:
      the rough size of a configured simulation (before it is executed) if we know it yet.
    • status

      public String status()
      Overrides:
      status in class PauseableThread