public abstract class

SubProcessExecutor

extends Object
implements SimulationExecutor
java.lang.Object
   ↳ uk.ac.imperial.presage2.core.cli.run.SubProcessExecutor
Known Direct Subclasses

Class Overview

A SimulationExecutor which has a set of sub processes which each runs a simulation. This abstract class automates the management of these processes. It calls the createProcess(long) function to get a ProcessBuilder with which to spawn the process to manage. This class can also log output from these processes to files.

Summary

Fields
protected int MAX_PROCESSES
protected final String[] customArgs
protected final int gcThreads
protected Logger logger
protected Timer processMonitor
protected List<Process> running
protected final String xms
protected final String xmx
Protected Constructors
SubProcessExecutor(int max_processes)
Create SubProcessExecutor which can execute at most max_processes processes in parallel.
SubProcessExecutor(int max_processes, String xms, String xmx, int gcThreads)
Create SubProcessExecutor with the given properties:
SubProcessExecutor(int max_processes, String... customArgs)
Create SubProcessExecutor with a custom array of properties passed to java.
Public Methods
boolean enableLogs()
Returns whether this executor will log output to file.
void enableLogs(boolean saveLogs)
Enable or disable saving of execution logs to file.
String getLogsDirectory()
Get directory to which execution log will be written.
int maxConcurrent()
Get the maximum number of simultaneously executing simulations this executor can handle.
synchronized void run(long simId)
Submits a simulation to be run on this executor.
int running()
Get the number of simulations this executor is currently running.
void setLogsDirectory(String logsDir)
Set directory to which execution logs will be written.
Protected Methods
abstract ProcessBuilder createProcess(long simId)
Create a ProcessBuilder which will spawn a Process to run the given simulation.@return
String getClasspath()
List<String> getJvmArgs()
Get the list of arguments which should be passed to the java executable for the vm.
[Expand]
Inherited Methods
From class java.lang.Object
From interface uk.ac.imperial.presage2.core.cli.run.SimulationExecutor

Fields

protected int MAX_PROCESSES

protected final String[] customArgs

protected final int gcThreads

protected Logger logger

protected Timer processMonitor

protected List<Process> running

protected final String xms

protected final String xmx

Protected Constructors

protected SubProcessExecutor (int max_processes)

Create SubProcessExecutor which can execute at most max_processes processes in parallel. The processes will use default vm arguments.

Parameters
max_processes max concurrent processes

protected SubProcessExecutor (int max_processes, String xms, String xmx, int gcThreads)

Create SubProcessExecutor with the given properties:

Parameters
max_processes max concurrent processes
xms -Xms value for JVM
xmx -Xmx value for JVM
gcThreads Number of threads to use for parallel GC.

protected SubProcessExecutor (int max_processes, String... customArgs)

Create SubProcessExecutor with a custom array of properties passed to java.

Parameters
max_processes max concurrent processes
customArgs array of args to pass to java executable on the command line.

Public Methods

public boolean enableLogs ()

Returns whether this executor will log output to file.

public void enableLogs (boolean saveLogs)

Enable or disable saving of execution logs to file.

public String getLogsDirectory ()

Get directory to which execution log will be written.

public int maxConcurrent ()

Get the maximum number of simultaneously executing simulations this executor can handle.

Returns
  • max. no. of concurrent simulations.

public synchronized void run (long simId)

Submits a simulation to be run on this executor.

Parameters
simId Id of the simulation to run.

public int running ()

Get the number of simulations this executor is currently running.

Returns
  • no. of simulations currently running.

public void setLogsDirectory (String logsDir)

Set directory to which execution logs will be written.

Protected Methods

protected abstract ProcessBuilder createProcess (long simId)

Create a ProcessBuilder which will spawn a Process to run the given simulation.@return

protected String getClasspath ()

protected List<String> getJvmArgs ()

Get the list of arguments which should be passed to the java executable for the vm. These arguments come before the program args.