From 7fd8a64e481252ecca24d08fbfe8a753a0d93d6e Mon Sep 17 00:00:00 2001 From: Nelson Tavares de Sousa <ntd@informatik.uni-kiel.de> Date: Fri, 12 Dec 2014 17:17:51 +0100 Subject: [PATCH] #84 added JavaDoc and error logging, if init was not executed before start --- src/main/java/teetime/framework/Analysis.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/teetime/framework/Analysis.java b/src/main/java/teetime/framework/Analysis.java index e83d9a31..ec204b3b 100644 --- a/src/main/java/teetime/framework/Analysis.java +++ b/src/main/java/teetime/framework/Analysis.java @@ -23,11 +23,17 @@ public class Analysis implements UncaughtExceptionHandler { private final Collection<Pair<Thread, Throwable>> exceptions = new ConcurrentLinkedQueue<Pair<Thread, Throwable>>(); + private boolean initExecuted = false; + public Analysis(final AnalysisConfiguration configuration) { this.configuration = configuration; } + /** + * This initializes Analysis and needs to be run right before starting it. + */ public void init() { + initExecuted = true; final List<Stage> threadableStageJobs = this.configuration.getThreadableStageJobs(); for (Stage stage : threadableStageJobs) { final Thread thread = new Thread(new RunnableStage(stage)); @@ -49,10 +55,14 @@ public class Analysis implements UncaughtExceptionHandler { } /** + * This method will start the Analysis and all containing stages. * * @return a collection of thread/throwable pairs */ public Collection<Pair<Thread, Throwable>> start() { + if (!initExecuted) { + LOGGER.error("init() not executed before starting the analysis"); + } // start analysis startThreads(this.consumerThreads); startThreads(this.finiteProducerThreads); @@ -93,6 +103,11 @@ public class Analysis implements UncaughtExceptionHandler { } } + /** + * Retrieves the Configuration which was used to add and arrange all stages needed for the Analysis + * + * @return Configuration used for the Analysis + */ public AnalysisConfiguration getConfiguration() { return this.configuration; } -- GitLab