From 05e15f26d30d1f4c8c235739fdfdaf4762a4754a Mon Sep 17 00:00:00 2001 From: Christian Wulf <chw@informatik.uni-kiel.de> Date: Thu, 3 Jul 2014 18:16:08 +0200 Subject: [PATCH] added catch in RunnableStage; reverted Recordfactory in TCPReader --- .../framework/core/RunnableStage.java | 18 ++++++++++++++---- .../methodcallWithPorts/stage/EndStage.java | 2 +- .../stage/io/TCPReader.java | 5 +++-- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/main/java/teetime/variant/methodcallWithPorts/framework/core/RunnableStage.java b/src/main/java/teetime/variant/methodcallWithPorts/framework/core/RunnableStage.java index c7435b03..9d4961c5 100644 --- a/src/main/java/teetime/variant/methodcallWithPorts/framework/core/RunnableStage.java +++ b/src/main/java/teetime/variant/methodcallWithPorts/framework/core/RunnableStage.java @@ -1,20 +1,30 @@ package teetime.variant.methodcallWithPorts.framework.core; +import kieker.common.logging.Log; +import kieker.common.logging.LogFactory; + public class RunnableStage implements Runnable { private final StageWithPort<?, ?> stage; + private final Log logger; public RunnableStage(final StageWithPort<?, ?> stage) { this.stage = stage; + this.logger = LogFactory.getLog(stage.getClass()); } @Override public void run() { - this.stage.onStart(); + try { + this.stage.onStart(); - do { - this.stage.executeWithPorts(); - } while (this.stage.isReschedulable()); + do { + this.stage.executeWithPorts(); + } while (this.stage.isReschedulable()); + } catch (RuntimeException e) { + this.logger.error("Terminating thread due to the following exception: ", e); + throw e; + } } } diff --git a/src/main/java/teetime/variant/methodcallWithPorts/stage/EndStage.java b/src/main/java/teetime/variant/methodcallWithPorts/stage/EndStage.java index a9d5dddb..41e4f9e8 100644 --- a/src/main/java/teetime/variant/methodcallWithPorts/stage/EndStage.java +++ b/src/main/java/teetime/variant/methodcallWithPorts/stage/EndStage.java @@ -58,7 +58,7 @@ public class EndStage<T> implements StageWithPort<T, T> { @Override public void executeWithPorts() { - // this.getInputPort().receive(); // just consume + this.getInputPort().receive(); // just consume // do nothing // this.count++; // Object r = this.closure.execute(null); diff --git a/src/main/java/teetime/variant/methodcallWithPorts/stage/io/TCPReader.java b/src/main/java/teetime/variant/methodcallWithPorts/stage/io/TCPReader.java index 091bff10..a5d73561 100644 --- a/src/main/java/teetime/variant/methodcallWithPorts/stage/io/TCPReader.java +++ b/src/main/java/teetime/variant/methodcallWithPorts/stage/io/TCPReader.java @@ -28,6 +28,7 @@ import teetime.variant.methodcallWithPorts.framework.core.ProducerStage; import kieker.common.exception.MonitoringRecordException; import kieker.common.logging.Log; import kieker.common.logging.LogFactory; +import kieker.common.record.AbstractMonitoringRecord; import kieker.common.record.IMonitoringRecord; import kieker.common.record.flow.trace.TraceMetadata; import kieker.common.record.flow.trace.operation.AfterOperationEvent; @@ -150,8 +151,8 @@ public class TCPReader extends ProducerStage<Void, IMonitoringRecord> { final long loggingTimestamp = buffer.getLong(); final IMonitoringRecord record; try { // NOCS (Nested try-catch) - record = this.recordFactory.create(clazzid, buffer, this.stringRegistry); - // record = AbstractMonitoringRecord.createFromByteBuffer(clazzid, buffer, this.stringRegistry); + // record = this.recordFactory.create(clazzid, buffer, this.stringRegistry); + record = AbstractMonitoringRecord.createFromByteBuffer(clazzid, buffer, this.stringRegistry); record.setLoggingTimestamp(loggingTimestamp); this.send(record); } catch (final MonitoringRecordException ex) { -- GitLab