public class

ExecutorModule

extends AbstractModule
java.lang.Object
   ↳ com.google.inject.AbstractModule
     ↳ uk.ac.imperial.presage2.core.cli.run.ExecutorModule

Class Overview

This AbstractModule binds a set of SimulationExecutors which can be used by an ExecutorManager. This module will usually be loaded via load() which will create the module from configuration files if present.

Summary

Public Constructors
ExecutorModule()
ExecutorModule(int localProcesses)
Public Methods
void addExecutor(Class<? extends SimulationExecutor> exeClass)
void addExecutorInstance(SimulationExecutor exec)
static AbstractModule load()

Load an AbstractModule which can inject an ExecutorManager with the appropriate SimulationExecutors as per provided configuration.

Protected Methods
void configure()
[Expand]
Inherited Methods
From class com.google.inject.AbstractModule
From class java.lang.Object
From interface com.google.inject.Module

Public Constructors

public ExecutorModule ()

public ExecutorModule (int localProcesses)

Public Methods

public void addExecutor (Class<? extends SimulationExecutor> exeClass)

public void addExecutorInstance (SimulationExecutor exec)

public static AbstractModule load ()

Load an AbstractModule which can inject an ExecutorManager with the appropriate SimulationExecutors as per provided configuration.

The executor config can be provided in two ways (in order of precedence):

  • executors.properties file on the classpath. This file should contain a module key who's value is the fully qualified name of a class which extends AbstractModule and has a public constructor which takes a single Properties object as an argument or public no-args constructor. An instance of this class will be returned.
  • executors.json file on the classpath. This file contains a specification of the executors to load in JSON format. If this file is valid we will instantiate each executor defined in the spec and add it to an ExecutorModule which will provide the bindings for them.

executors.json format

The executors.json file should contain a JSON object with the following:

  • executors key whose value is an array. Each element of the array is a JSON object with the following keys:
    • class: the fully qualified name of the executor class.
    • args: an array of arguments to pass to a public constructor of the class.
    • enableLogs (optional): boolean value whether this executor should save logs to file. Defaults to global value.
    • logDir (optional): string path to save logs to. Defaults to global value
  • enableLogs (optional): Global value for enableLogs for each executor. Defaults to false.
  • logDir (optional): Global value for logDir for each executor. Default values depend on the executor.

e.g.:

 {
 	"executors": [{
 		"class": "my.fully.qualified.Executor",
 		"args": [1, "some string", true]
 	},{
 		...
 	}],
 "enableLogs": true
 }
 

Protected Methods

protected void configure ()