Package jasima.core.expExecution
Class ExperimentExecutor
- java.lang.Object
-
- jasima.core.expExecution.ExperimentExecutor
-
- Direct Known Subclasses:
ThreadPoolExecutor
public abstract class ExperimentExecutor extends Object
Base class for classes executing experiments. This class implements the Abstract Factory pattern, therefore ExperimentExecutor.getExecutor() has to be called to create executor instances. This call is delegated to a non-abstract implementation of ExperimentExecutor. Which ExperimentExecutor to use is determined by a system property "jasima.core.expExecution.ExperimentExecutor". As a default, aThreadPoolExecutoris used (with a maximum number of threads equal to the number of available processors).- Author:
- Torsten Hildebrandt
- See Also:
ThreadPoolExecutor,ForkJoinPoolExecutor
-
-
Field Summary
Fields Modifier and Type Field Description static Class<? extends ExperimentExecutor>execFactoryImplstatic StringEXECUTOR_FACTORY
-
Constructor Summary
Constructors Constructor Description ExperimentExecutor()Don't call directly, usegetExecutor()instead.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract ExecutorServiceexperimentExecutor(Experiment e, Experiment parent)Returns theExecutorServicethat should be used to execute theExperiment.static ExperimentExecutorgetExecutor()static Collection<ExperimentCompletableFuture>runAllExperiments(Collection<? extends Experiment> es, Experiment parent)Execute many experiments at once.static ExperimentCompletableFuturerunExperimentAsync(Experiment e, Experiment parent)Runs an experiment (usually in an asynchronous way).static ExperimentCompletableFuturerunExperimentAsync(Experiment e, Experiment parent, ExecutorService es)Runs an experiment (usually in an asynchronous way).abstract voidshutdownNow()Shuts down thisExperimentExecutor.
-
-
-
Field Detail
-
EXECUTOR_FACTORY
public static final String EXECUTOR_FACTORY
-
execFactoryImpl
public static final Class<? extends ExperimentExecutor> execFactoryImpl
-
-
Constructor Detail
-
ExperimentExecutor
public ExperimentExecutor()
Don't call directly, usegetExecutor()instead. Has to be public to be callable by reflection.
-
-
Method Detail
-
getExecutor
public static ExperimentExecutor getExecutor()
-
shutdownNow
public abstract void shutdownNow()
Shuts down thisExperimentExecutor.
-
experimentExecutor
public abstract ExecutorService experimentExecutor(Experiment e, @Nullable Experiment parent)
Returns theExecutorServicethat should be used to execute theExperiment.- Parameters:
e- The experiment to be executed.parent- A parent experiment that is executinge(can be null).- Returns:
- The
ExecutorServiceto execute it with.
-
runAllExperiments
public static Collection<ExperimentCompletableFuture> runAllExperiments(Collection<? extends Experiment> es, Experiment parent)
Execute many experiments at once. The implementation here simply callsrunExperimentAsync(Experiment,Experiment)for all experiments ines.- Parameters:
es- A list ofExperiments to run.parent- The parent experiment of "es". This might be null.- Returns:
- A
CollectionofExperimentCompletableFutures, one for each submitted experiment.
-
runExperimentAsync
public static ExperimentCompletableFuture runExperimentAsync(Experiment e, Experiment parent)
Runs an experiment (usually in an asynchronous way). Therefore anExperimentCompletableFutureis returned to access results once they become available.- Parameters:
e- The experiment to execute.parent- The parent experiment of "e". This might be null.- Returns:
- An
ExperimentCompletableFutureto access experiment results.
-
runExperimentAsync
public static ExperimentCompletableFuture runExperimentAsync(Experiment e, Experiment parent, ExecutorService es)
Runs an experiment (usually in an asynchronous way). Therefore anExperimentCompletableFutureis returned to access results once they become available.- Parameters:
e- The experiment to execute.parent- The parent experiment of "e". This might be null.- Returns:
- An
ExperimentCompletableFutureto access experiment results.
-
-