Search in sources :

Example 1 with ITraceRecord

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();
}
Also used : SessionEndEvent(org.iobserve.common.record.SessionEndEvent) ITraceRecord(kieker.common.record.flow.ITraceRecord) IMonitoringRecord(kieker.common.record.IMonitoringRecord)

Example 2 with ITraceRecord

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);
        }
    }
}
Also used : ITraceRecord(kieker.common.record.flow.ITraceRecord) KiekerMetadataRecord(kieker.common.record.misc.KiekerMetadataRecord) TraceMetadata(kieker.common.record.flow.trace.TraceMetadata)

Example 3 with ITraceRecord

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);
    }
}
Also used : ITraceRecord(kieker.common.record.flow.ITraceRecord) IMonitoringRecord(kieker.common.record.IMonitoringRecord) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) TraceMetadata(kieker.common.record.flow.trace.TraceMetadata)

Example 4 with ITraceRecord

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);
    }
}
Also used : ITraceRecord(kieker.common.record.flow.ITraceRecord) KiekerMetadataRecord(kieker.common.record.misc.KiekerMetadataRecord) TraceMetadata(kieker.common.record.flow.trace.TraceMetadata) SocketAddress(java.net.SocketAddress) InetSocketAddress(java.net.InetSocketAddress) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

ITraceRecord (kieker.common.record.flow.ITraceRecord)4 TraceMetadata (kieker.common.record.flow.trace.TraceMetadata)3 IMonitoringRecord (kieker.common.record.IMonitoringRecord)2 KiekerMetadataRecord (kieker.common.record.misc.KiekerMetadataRecord)2 InetSocketAddress (java.net.InetSocketAddress)1 SocketAddress (java.net.SocketAddress)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 SessionEndEvent (org.iobserve.common.record.SessionEndEvent)1