use of kieker.common.record.flow.ITraceRecord in project iobserve-analysis by research-iobserve.
the class EndSessionDetector method flushAllRecords.
private void flushAllRecords() {
for (final IMonitoringRecord event : this.allRecords) {
if (event instanceof ITraceRecord) {
final ITraceRecord traceEvent = (ITraceRecord) event;
final Pair firstLast = this.getFirstLast(traceEvent);
this.outputPort.send(event);
if (firstLast != null) {
if (firstLast.getLast() == traceEvent) {
this.outputPort.send(new SessionEndEvent(firstLast.getLast().getLoggingTimestamp(), firstLast.getFirst().getHostname(), firstLast.getFirst().getSessionId()));
}
}
} else {
this.outputPort.send(event);
}
}
this.allRecords.clear();
}
use of kieker.common.record.flow.ITraceRecord in project iobserve-analysis by research-iobserve.
the class Splitter method execute.
@Override
protected void execute(final IMonitoringRecord element) {
this.recordCount++;
if (element instanceof TraceMetadata) {
final TraceMetadata traceMetadata = (TraceMetadata) element;
this.traceRegisterMap.put(traceMetadata.getTraceId(), traceMetadata);
boolean send = false;
for (int i = 0; i < this.hostnames.length; i++) {
if (this.hostnames[i].equals(traceMetadata.getHostname())) {
this.outputPorts.get(i).send(element);
send = true;
}
}
if (!send) {
for (int i = 0; i < this.hostnames.length; i++) {
this.outputPorts.get(i).send(element);
}
}
} else if (element instanceof ITraceRecord) {
final TraceMetadata metadata = this.traceRegisterMap.get(((ITraceRecord) element).getTraceId());
boolean send = false;
for (int i = 0; i < this.hostnames.length; i++) {
if (this.hostnames[i].equals(metadata.getHostname())) {
this.outputPorts.get(i).send(element);
send = true;
}
}
if (!send) {
for (int i = 0; i < this.hostnames.length; i++) {
this.outputPorts.get(i).send(element);
}
}
} else if (element instanceof KiekerMetadataRecord) {
/**
* ignore.
*/
Splitter.LOGGER.debug("Metadata record {}.", element);
} else {
for (int i = 0; i < this.hostnames.length; i++) {
this.outputPorts.get(i).send(element);
}
}
}
use of kieker.common.record.flow.ITraceRecord in project iobserve-analysis by research-iobserve.
the class FixTraceMetadata method execute.
@Override
protected void execute(final IMonitoringRecord event) throws Exception {
if (event instanceof TraceMetadata) {
this.traces.put(((TraceMetadata) event).getTraceId(), event.getLoggingTimestamp());
this.outputPort.send(event);
final List<IMonitoringRecord> keptRecords = this.stash.get(((TraceMetadata) event).getTraceId());
if (keptRecords != null) {
for (final IMonitoringRecord record : keptRecords) {
this.outputPort.send(record);
}
}
} else if (event instanceof ITraceRecord) {
final Long time = this.traces.get(((ITraceRecord) event).getTraceId());
if (time != null) {
this.traces.put(((ITraceRecord) event).getTraceId(), event.getLoggingTimestamp());
this.outputPort.send(event);
} else {
List<IMonitoringRecord> keptRecords = this.stash.get(((ITraceRecord) event).getTraceId());
if (keptRecords == null) {
keptRecords = new ArrayList<>();
}
keptRecords.add(event);
this.stash.put(((ITraceRecord) event).getTraceId(), keptRecords);
}
} else {
this.outputPort.send(event);
}
}
use of kieker.common.record.flow.ITraceRecord in project iobserve-analysis by research-iobserve.
the class PlainTraceMetadataRewriter method rewrite.
/**
* Trace data records use unique ids for their respective host. However, in a multi read stage
* these ids may be used on different hosts. Therefore, they have to be mapped.
*
* TODO fails in case of records appearing out of order, i.e., a ITraceRecord appearing before a
* TraceMetadata record.
*
* @param record
* @return
* @throws IOException
*/
@Override
public void rewrite(final Connection connection, final IMonitoringRecord record, final long loggingTimestamp, final OutputPort<IMonitoringRecord> outputPort) throws IOException {
// set logging time stamp
record.setLoggingTimestamp(loggingTimestamp);
if (record instanceof TraceMetadata) {
final TraceMetadata traceMetadata = (TraceMetadata) record;
traceMetadata.setTraceId(this.traceId);
Map<Long, TraceMetadata> map = this.metadatamap.get(traceMetadata.getHostname());
if (map == null) {
map = new HashMap<>();
this.metadatamap.put(traceMetadata.getHostname(), map);
}
map.put(traceMetadata.getTraceId(), traceMetadata);
this.traceId++;
outputPort.send(traceMetadata);
} else if (record instanceof ITraceRecord) {
final SocketAddress remoteAddress = connection.getChannel().getRemoteAddress();
final String ip = this.getIP(remoteAddress);
final long inputTraceId = ((ITraceRecord) record).getTraceId();
final Map<Long, TraceMetadata> map = this.metadatamap.get(ip);
if (map != null) {
final TraceMetadata metaData = map.get(inputTraceId);
((ITraceRecord) record).setTraceId(metaData.getTraceId());
outputPort.send(record);
}
} else if (record instanceof KiekerMetadataRecord) {
// NOCS NOPMD explicitly ignore
// metadata record
/**
* ignore metadata record.
*/
} else {
/**
* pass all records unmodified, which are not trace records.
*/
outputPort.send(record);
}
}
Aggregations