Skip to content
Snippets Groups Projects
Commit 4d2f1b00 authored by Lars Erik Blümke's avatar Lars Erik Blümke
Browse files

migrated TimestampFilter

parent 2f4476dd
No related branches found
No related tags found
No related merge requests found
package kieker.analysis.plugin.filter.select.timestamp;
import kieker.common.record.IMonitoringRecord;
import teetime.framework.AbstractConsumerStage;
import teetime.framework.OutputPort;
import teetime.stage.InstanceOfFilter;
/**
* Allows to filter {@link IMonitoringRecord} objects based on their given timestamps.
*
* If the received record is within the defined timestamps, the object is delivered unmodified to the nameWithinPeriodOutputPort otherwise to the
* nameOutsidePeriodOutputPort.
*
* In a concrete P&F architecture this stage should be used behind TeeTime's {@link InstanceOfFilter} to forward records to either {@link FlowRecordTimestampStage},
* {@link OperationExecutionRecordTimestampStage} or {@link MonitioringRecordTimestampStage}.
*
* @author Andre van Hoorn, Jan Waller, Lars Erik Bluemke
*
* @since 1.2
*
* @param <T>
* Generic type of incoming records. Subclasses use concrete types.
*/
public abstract class AbstractTimestampStage<T> extends AbstractConsumerStage<T> {
private final long ignoreBeforeTimestamp;
private final long ignoreAfterTimestamp;
protected final OutputPort<T> nameWithinPeriodOutputPort = this.createOutputPort();
protected final OutputPort<T> nameOutsidePeriodOutputPort = this.createOutputPort();
/**
* Creates a new instance of this class using the given parameters.
*
* @param ignoreBeforeTimestamp
* bla
* @param ignoreAfterTimestamp
*/
public AbstractTimestampStage(final long ignoreBeforeTimestamp, final long ignoreAfterTimestamp) {
this.ignoreBeforeTimestamp = ignoreBeforeTimestamp;
this.ignoreAfterTimestamp = ignoreAfterTimestamp;
}
/**
* A simple helper method which checks whether the given timestamp is in the configured limits.
*
* @param timestamp
* The timestamp to be checked.
* @return true if and only if the given timestamp is between or equals ignoreBeforeTimestamp and ignoreAfterTimestamp.
*/
protected final boolean inRange(final long timestamp) {
return (timestamp >= this.ignoreBeforeTimestamp) && (timestamp <= this.ignoreAfterTimestamp);
}
}
package kieker.analysis.plugin.filter.select.timestamp;
import kieker.common.record.flow.IEventRecord;
import kieker.common.record.flow.IFlowRecord;
import kieker.common.record.flow.trace.TraceMetadata;
/**
* Concrete implementation of {@link AbstractTimestampStage}. Allows to filter {@link IFlowRecord} objects based on their given timestamps.
*
* @author Andre van Hoorn, Jan Waller, Lars Erik Bluemke
*/
public class FlowRecordTimestampStage extends AbstractTimestampStage<IFlowRecord> {
public FlowRecordTimestampStage(final long ignoreBeforeTimestamp, final long ignoreAfterTimestamp) {
super(ignoreBeforeTimestamp, ignoreAfterTimestamp);
}
@Override
protected void execute(final IFlowRecord record) {
final long timestamp;
if (record instanceof TraceMetadata) {
timestamp = ((TraceMetadata) record).getLoggingTimestamp();
} else if (record instanceof IEventRecord) {
timestamp = ((IEventRecord) record).getTimestamp();
} else {
// should not happen given the accepted type
return;
}
if (this.inRange(timestamp)) {
this.nameWithinPeriodOutputPort.send(record);
} else {
this.nameOutsidePeriodOutputPort.send(record);
}
}
}
package kieker.analysis.plugin.filter.select.timestamp;
import kieker.common.record.IMonitoringRecord;
/**
* Concrete implementation of {@link AbstractTimestampStage}. Allows to filter {@link IMonitoringRecord} objects based on their given timestamps.
*
* @author Andre van Hoorn, Jan Waller, Lars Erik Bluemke
*/
public class MonitioringRecordTimestampStage extends AbstractTimestampStage<IMonitoringRecord> {
public MonitioringRecordTimestampStage(final long ignoreBeforeTimestamp, final long ignoreAfterTimestamp) {
super(ignoreBeforeTimestamp, ignoreAfterTimestamp);
}
@Override
protected void execute(final IMonitoringRecord record) {
if (this.inRange(record.getLoggingTimestamp())) {
this.nameWithinPeriodOutputPort.send(record);
} else {
this.nameOutsidePeriodOutputPort.send(record);
}
}
}
package kieker.analysis.plugin.filter.select.timestamp;
import kieker.common.record.controlflow.OperationExecutionRecord;
/**
* Concrete implementation of {@link AbstractTimestampStage}. Allows to filter {@link OperationExecutionRecord} objects based on their given timestamps.
* This stage receives trace events to be selected by a specific timestamp selector (based on tin and tout).
*
* @author Andre van Hoorn, Jan Waller, Lars Erik Bluemke
*/
public class OperationExecutionRecordTimestampStage extends AbstractTimestampStage<OperationExecutionRecord> {
public OperationExecutionRecordTimestampStage(final long ignoreBeforeTimestamp, final long ignoreAfterTimestamp) {
super(ignoreBeforeTimestamp, ignoreAfterTimestamp);
}
@Override
protected void execute(final OperationExecutionRecord execution) {
if (this.inRange(execution.getTin()) && this.inRange(execution.getTout())) {
this.nameWithinPeriodOutputPort.send(execution);
} else {
this.nameOutsidePeriodOutputPort.send(execution);
}
}
}
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