Skip to content
Snippets Groups Projects
Commit 43f27c9d authored by Christian Wulf's avatar Christian Wulf
Browse files

added logging of runnables (experimental)

parent 92498ecb
No related branches found
No related tags found
No related merge requests found
......@@ -15,19 +15,28 @@
*/
package teetime.framework;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import teetime.framework.exceptionHandling.TerminateException;
import teetime.util.StopWatch;
abstract class AbstractRunnableStage implements Runnable {
private static final String TERMINATING_THREAD_DUE_TO_THE_FOLLOWING_EXCEPTION = "Terminating thread due to the following exception: ";
private final StopWatch stopWatch = new StopWatch();
protected final Stage stage;
@SuppressWarnings("PMD.LoggerIsNotStaticFinal")
protected final Logger logger;
public static final Map<Stage, Long> durationsInNs = Collections.synchronizedMap(new LinkedHashMap<Stage, Long>());
protected AbstractRunnableStage(final Stage stage) {
if (stage == null) {
throw new IllegalArgumentException("Argument stage may not be null");
......@@ -50,6 +59,7 @@ abstract class AbstractRunnableStage implements Runnable {
if (stage.getOwningContext() == null) {
throw new IllegalArgumentException("Argument stage may not have a nullable owning context");
}
stopWatch.start();
try {
while (!stage.shouldBeTerminated()) {
executeStage();
......@@ -58,6 +68,8 @@ abstract class AbstractRunnableStage implements Runnable {
stage.abort();
stage.getOwningContext().abortConfigurationRun();
} finally {
stopWatch.end();
durationsInNs.put(stage, stopWatch.getDurationInNs());
afterStageExecution();
}
......
......@@ -21,6 +21,8 @@ import teetime.framework.OutputPort;
import teetime.stage.basic.distributor.Distributor;
/**
* Backoff strategy
*
* @author Christian Wulf
*
* @since 1.1
......
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