Skip to content
Snippets Groups Projects
Commit 7fd8a64e authored by Nelson Tavares de Sousa's avatar Nelson Tavares de Sousa
Browse files

#84 added JavaDoc and error logging, if init was not executed before

start
parent 4760dd77
No related branches found
No related tags found
No related merge requests found
...@@ -23,11 +23,17 @@ public class Analysis implements UncaughtExceptionHandler { ...@@ -23,11 +23,17 @@ public class Analysis implements UncaughtExceptionHandler {
private final Collection<Pair<Thread, Throwable>> exceptions = new ConcurrentLinkedQueue<Pair<Thread, Throwable>>(); private final Collection<Pair<Thread, Throwable>> exceptions = new ConcurrentLinkedQueue<Pair<Thread, Throwable>>();
private boolean initExecuted = false;
public Analysis(final AnalysisConfiguration configuration) { public Analysis(final AnalysisConfiguration configuration) {
this.configuration = configuration; this.configuration = configuration;
} }
/**
* This initializes Analysis and needs to be run right before starting it.
*/
public void init() { public void init() {
initExecuted = true;
final List<Stage> threadableStageJobs = this.configuration.getThreadableStageJobs(); final List<Stage> threadableStageJobs = this.configuration.getThreadableStageJobs();
for (Stage stage : threadableStageJobs) { for (Stage stage : threadableStageJobs) {
final Thread thread = new Thread(new RunnableStage(stage)); final Thread thread = new Thread(new RunnableStage(stage));
...@@ -49,10 +55,14 @@ public class Analysis implements UncaughtExceptionHandler { ...@@ -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 * @return a collection of thread/throwable pairs
*/ */
public Collection<Pair<Thread, Throwable>> start() { public Collection<Pair<Thread, Throwable>> start() {
if (!initExecuted) {
LOGGER.error("init() not executed before starting the analysis");
}
// start analysis // start analysis
startThreads(this.consumerThreads); startThreads(this.consumerThreads);
startThreads(this.finiteProducerThreads); startThreads(this.finiteProducerThreads);
...@@ -93,6 +103,11 @@ public class Analysis implements UncaughtExceptionHandler { ...@@ -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() { public AnalysisConfiguration getConfiguration() {
return this.configuration; return this.configuration;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment