Commit 8d430588 authored by Florian Fittkau's avatar Florian Fittkau

trace highlighting - Work in Progress

parent 351b6cbe
......@@ -97,6 +97,6 @@ class TraceReconstructionBuffer {
}
}
}
return new Trace(new ArrayList<AbstractEventRecord>(events), valid);
return new Trace(new ArrayList<AbstractEventRecord>(events), valid, 1);
}
}
......@@ -26,6 +26,8 @@ class TracesSummarizationBuffer {
if (accumulator == null) {
accumulator = trace;
} else {
accumulator.setCalledTimes(accumulator.getCalledTimes() + trace.getCalledTimes());
final List<AbstractEventRecord> aggregatedRecords = accumulator.getTraceEvents();
final List<AbstractEventRecord> records = trace.getTraceEvents();
......
......@@ -23,8 +23,6 @@ public class TracesSummarizationFilter extends AbstractFilter implements ITraceR
private final Map<Trace, TracesSummarizationBuffer> trace2buffer = new ConcurrentSkipListMap<Trace, TracesSummarizationBuffer>(
new TraceComperator());
// TODO cache for buffer objects
public TracesSummarizationFilter(final long maxCollectionDuration,
final IPipeReceiver sinkReceiver) {
super(sinkReceiver, Constants.TRACE_SUMMARIZATION_DISRUPTOR_SIZE,
......
package explorviz.live_trace_processing.filter.reduction.evaluation.ad_hoc;
import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
import explorviz.live_trace_processing.filter.IPipeReceiver;
import explorviz.live_trace_processing.filter.reduction.AbstractReductionFilter;
import explorviz.live_trace_processing.record.event.AbstractAfterEventRecord;
import explorviz.live_trace_processing.record.event.AbstractBeforeEventRecord;
import explorviz.live_trace_processing.record.event.AbstractEventRecord;
import explorviz.live_trace_processing.record.trace.Trace;
public class FragmentationFilter extends AbstractReductionFilter {
private final int objectId;
/*
* The FragmentationFilter keeps all Records with the given objectId.
*/
public FragmentationFilter(final IPipeReceiver receiver, final int objectId) {
super(receiver, "FragmentationFilter");
this.objectId = objectId;
}
@Override
protected Trace reduceTrace(final Trace trace) {
final List<AbstractEventRecord> traceEvents = new ArrayList<AbstractEventRecord>();
final Stack<Integer> stack = new Stack<Integer>();
int count = 0;
for (final AbstractEventRecord event : trace.getTraceEvents()) {
if (event instanceof AbstractBeforeEventRecord) {
count++;
final int objectId = ((AbstractBeforeEventRecord) event).getObjectId();
if (this.objectId == objectId) {
traceEvents.add(event);
stack.push(new Integer(count));
}
} else if (event instanceof AbstractAfterEventRecord) {
if (!stack.isEmpty() && (stack.peek() == count)) {
traceEvents.add(event);
stack.pop();
}
count--;
}
}
return new Trace(traceEvents, true);
}
}
package explorviz.live_trace_processing.filter.reduction.evaluation.ad_hoc;
import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
import explorviz.live_trace_processing.filter.IPipeReceiver;
import explorviz.live_trace_processing.filter.reduction.AbstractReductionFilter;
import explorviz.live_trace_processing.record.event.AbstractAfterEventRecord;
import explorviz.live_trace_processing.record.event.AbstractAfterFailedEventRecord;
import explorviz.live_trace_processing.record.event.AbstractBeforeEventRecord;
import explorviz.live_trace_processing.record.event.AbstractEventRecord;
import explorviz.live_trace_processing.record.trace.Trace;
public class SamplingFilter extends AbstractReductionFilter {
private final int samplingDistance;
public SamplingFilter(final IPipeReceiver receiver, final int samplingDistance) {
super(receiver, "Sampling");
this.samplingDistance = samplingDistance;
}
@Override
protected Trace reduceTrace(final Trace trace) {
final List<AbstractEventRecord> newTraceEvents = new ArrayList<AbstractEventRecord>();
int stackDepth = 0;
int counter = samplingDistance;
final Stack<Integer> stack = new Stack<Integer>();
for (final AbstractEventRecord record : trace.getTraceEvents()) {
if (record instanceof AbstractBeforeEventRecord) {
stackDepth++;
if (counter == samplingDistance) {
newTraceEvents.add(record);
stack.push(new Integer(stackDepth));
counter = 0;
}
counter++;
} else if ((record instanceof AbstractAfterEventRecord)
|| (record instanceof AbstractAfterFailedEventRecord)) {
if (!stack.isEmpty() && (stackDepth == stack.peek())) {
stack.pop();
newTraceEvents.add(record);
}
stackDepth--;
} else {
newTraceEvents.add(record);
}
}
return new Trace(newTraceEvents, true);
}
}
package explorviz.live_trace_processing.filter.reduction.evaluation.language_based;
import explorviz.live_trace_processing.filter.IPipeReceiver;
import explorviz.live_trace_processing.filter.reduction.language_based.AbstractLanguageBasedFilter;
import explorviz.live_trace_processing.record.event.AbstractBeforeEventRecord;
public class RemoveNonPublicMethodsFilter extends AbstractLanguageBasedFilter {
public RemoveNonPublicMethodsFilter(final IPipeReceiver receiver) {
super(receiver, "NonPublic");
}
@Override
protected boolean isSoughtEvent(final AbstractBeforeEventRecord abstractBeforeEventRecord) {
return !abstractBeforeEventRecord.getOperationSignature().contains("public");
}
}
package explorviz.live_trace_processing.filter.reduction.evaluation.language_based;
import explorviz.live_trace_processing.filter.IPipeReceiver;
import explorviz.live_trace_processing.filter.reduction.language_based.AbstractLanguageBasedFilter;
import explorviz.live_trace_processing.record.event.AbstractBeforeEventRecord;
public class RemovePackageFilter extends AbstractLanguageBasedFilter {
String packageName;
public RemovePackageFilter(final IPipeReceiver receiver, final String packageName) {
super(receiver, "packageFiltering");
this.packageName = packageName;
}
@Override
protected boolean isSoughtEvent(final AbstractBeforeEventRecord abstractBeforeEventRecord) {
return abstractBeforeEventRecord.getOperationSignature().contains(packageName);
}
}
package explorviz.live_trace_processing.filter.reduction.evaluation.metrics_based;
import java.util.ArrayList;
import java.util.List;
import explorviz.live_trace_processing.filter.IPipeReceiver;
import explorviz.live_trace_processing.filter.reduction.AbstractReductionFilter;
import explorviz.live_trace_processing.record.event.AbstractAfterEventRecord;
import explorviz.live_trace_processing.record.event.AbstractAfterFailedEventRecord;
import explorviz.live_trace_processing.record.event.AbstractBeforeEventRecord;
import explorviz.live_trace_processing.record.event.AbstractEventRecord;
import explorviz.live_trace_processing.record.event.AbstractRemoteEventRecord;
import explorviz.live_trace_processing.record.trace.Trace;
public class StackDepthFilter extends AbstractReductionFilter {
private final int maxStackDepth;
public StackDepthFilter(final IPipeReceiver receiver, final int maxStackDepth) {
super(receiver, "StackDepthLimitation");
this.maxStackDepth = maxStackDepth;
}
@Override
protected Trace reduceTrace(final Trace trace) {
final List<AbstractEventRecord> newTraceEvents = new ArrayList<AbstractEventRecord>();
int count = 0;
for (final AbstractEventRecord record : trace.getTraceEvents()) {
if (record instanceof AbstractBeforeEventRecord) {
if (count < maxStackDepth) {
newTraceEvents.add(record);
}
count++;
} else if ((record instanceof AbstractAfterEventRecord)
|| (record instanceof AbstractAfterFailedEventRecord)) {
count--;
if (count < maxStackDepth) {
newTraceEvents.add(record);
}
} else if (record instanceof AbstractRemoteEventRecord) {
newTraceEvents.add(record);
} else {
newTraceEvents.add(record);
}
}
return new Trace(newTraceEvents, true);
}
}
package explorviz.live_trace_processing.filter.reduction.evaluation.summarization;
import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
import explorviz.live_trace_processing.filter.IPipeReceiver;
import explorviz.live_trace_processing.filter.reduction.AbstractReductionFilter;
import explorviz.live_trace_processing.record.event.AbstractAfterEventRecord;
import explorviz.live_trace_processing.record.event.AbstractBeforeEventRecord;
import explorviz.live_trace_processing.record.event.AbstractEventRecord;
import explorviz.live_trace_processing.record.trace.Trace;
public class MonotoneSubsequenceFilter extends AbstractReductionFilter {
public MonotoneSubsequenceFilter(final IPipeReceiver receiver) {
super(receiver, "MonotoneSubsequence");
}
@Override
protected Trace reduceTrace(final Trace trace) {
final List<AbstractEventRecord> newTraceEvents = new ArrayList<AbstractEventRecord>();
int count = 0;
boolean keepNextBeforeEvent = true;
boolean lastEventWasAfterEvent = false;
final Stack<Integer> searchCorrespondingAfterEvent = new Stack<Integer>();
for (final AbstractEventRecord event : trace.getTraceEvents()) {
if (event instanceof AbstractBeforeEventRecord) {
count++;
lastEventWasAfterEvent = false;
if (keepNextBeforeEvent) {
newTraceEvents.add(event);
searchCorrespondingAfterEvent.push(new Integer(count));
keepNextBeforeEvent = false;
}
} else if (event instanceof AbstractAfterEventRecord) {
if (lastEventWasAfterEvent) {
keepNextBeforeEvent = true;
} else {
lastEventWasAfterEvent = true;
}
if (!searchCorrespondingAfterEvent.isEmpty()
&& (count == searchCorrespondingAfterEvent.peek())) {
searchCorrespondingAfterEvent.pop();
newTraceEvents.add(event);
}
count--;
} else {
newTraceEvents.add(event);
}
}
return new Trace(newTraceEvents, true);
}
}
package explorviz.live_trace_processing.filter.reduction.language_based;
import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
import explorviz.live_trace_processing.filter.IPipeReceiver;
import explorviz.live_trace_processing.filter.reduction.AbstractReductionFilter;
import explorviz.live_trace_processing.record.event.AbstractAfterEventRecord;
import explorviz.live_trace_processing.record.event.AbstractBeforeEventRecord;
import explorviz.live_trace_processing.record.event.AbstractEventRecord;
import explorviz.live_trace_processing.record.trace.Trace;
public abstract class AbstractLanguageBasedFilter extends AbstractReductionFilter {
public AbstractLanguageBasedFilter(final IPipeReceiver receiver, final String counterString) {
super(receiver, counterString);
}
@Override
protected Trace reduceTrace(final Trace trace) {
final List<AbstractEventRecord> traceEvents = new ArrayList<AbstractEventRecord>();
final Stack<Integer> stack = new Stack<Integer>();
int count = 0;
for (final AbstractEventRecord event : trace.getTraceEvents()) {
if (event instanceof AbstractBeforeEventRecord) {
count++;
final AbstractBeforeEventRecord abstractBeforeEventRecord = (AbstractBeforeEventRecord) event;
if (isSoughtEvent(abstractBeforeEventRecord)) {
stack.push(new Integer(count));
} else {
traceEvents.add(event);
}
} else if (event instanceof AbstractAfterEventRecord) {
if (!stack.isEmpty() && (count == stack.peek())) {
stack.pop();
} else {
traceEvents.add(event);
}
count--;
}
}
if (traceEvents.size() > 0) {
return new Trace(traceEvents, true);
} else {
return new Trace(traceEvents, false);
}
}
protected abstract boolean isSoughtEvent(AbstractBeforeEventRecord abstractBeforeEventRecord);
}
package explorviz.live_trace_processing.filter.reduction.language_based;
import java.util.ArrayList;
import java.util.List;
import explorviz.live_trace_processing.filter.IPipeReceiver;
import explorviz.live_trace_processing.record.event.AbstractBeforeEventRecord;
import explorviz.live_trace_processing.record.event.AbstractEventRecord;
import explorviz.live_trace_processing.record.event.constructor.AfterConstructorEventRecord;
import explorviz.live_trace_processing.record.event.constructor.BeforeConstructorEventRecord;
import explorviz.live_trace_processing.record.trace.Trace;
public class RemoveConstructorsFilter extends AbstractLanguageBasedFilter {
public RemoveConstructorsFilter(final IPipeReceiver receiver) {
super(receiver, "ConstructorHiding");
}
@Override
protected Trace reduceTrace(final Trace trace) {
final List<AbstractEventRecord> traceEvents = new ArrayList<AbstractEventRecord>();
for (final AbstractEventRecord event : trace.getTraceEvents()) {
if (event instanceof BeforeConstructorEventRecord) {
} else if (event instanceof AfterConstructorEventRecord) {
} else {
traceEvents.add(event);
}
}
return new Trace(traceEvents, true);
}
@Override
protected boolean isSoughtEvent(final AbstractBeforeEventRecord abstractBeforeEventRecord) {
// not used
return false;
}
}
package explorviz.live_trace_processing.filter.reduction.language_based;
import explorviz.live_trace_processing.filter.IPipeReceiver;
import explorviz.live_trace_processing.record.event.AbstractBeforeEventRecord;
public class RemoveGettersAndSettersFilter extends AbstractLanguageBasedFilter {
public RemoveGettersAndSettersFilter(final IPipeReceiver receiver) {
super(receiver, "GettersAndSetters");
}
@Override
protected boolean isSoughtEvent(final AbstractBeforeEventRecord abstractBeforeEventRecord) {
return isGetterOrSetter(abstractBeforeEventRecord.getOperationSignature());
}
private boolean isGetterOrSetter(final String operationSignature) {
final String methodName = getMethodName(operationSignature);
return methodName.startsWith("get") || methodName.startsWith("set");
}
private String getMethodName(final String operationSignatureStr) {
final String[] a = operationSignatureStr.split("\\(")[0].split("\\s");
final String b = a[a.length - 1];
final int c = b.lastIndexOf('.');
final String methodName = b.substring(c + 1);
return methodName;
}
}
package explorviz.live_trace_processing.filter.reduction.summarization;
import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
import explorviz.live_trace_processing.filter.IPipeReceiver;
import explorviz.live_trace_processing.filter.reduction.AbstractReductionFilter;
import explorviz.live_trace_processing.record.event.AbstractAfterEventRecord;
import explorviz.live_trace_processing.record.event.AbstractAfterFailedEventRecord;
import explorviz.live_trace_processing.record.event.AbstractBeforeEventRecord;
import explorviz.live_trace_processing.record.event.AbstractEventRecord;
import explorviz.live_trace_processing.record.trace.Trace;
public class AssociativityFilter extends AbstractReductionFilter {
public AssociativityFilter(final IPipeReceiver receiver) {
super(receiver, "AssoziationFilter");
}
@Override
protected Trace reduceTrace(final Trace trace) {
final List<AbstractEventRecord> newTraceEvents = new ArrayList<AbstractEventRecord>();
String caller = null;
int count = 0;
final Stack<Integer> stack = new Stack<Integer>();
final Stack<String> callerStack = new Stack<String>();
for (final AbstractEventRecord record : trace.getTraceEvents()) {
if (record instanceof AbstractBeforeEventRecord) {
count++;
final AbstractBeforeEventRecord abstractBeforeEventRecord = (AbstractBeforeEventRecord) record;
final String signature = abstractBeforeEventRecord.getOperationSignature();
final String callee = getClazzFullQName(signature);
if (!callee.equals(caller)) {
newTraceEvents.add(record);
} else {
stack.push(new Integer(count));
}
caller = callee;
callerStack.push(caller);
} else if ((record instanceof AbstractAfterEventRecord)
|| (record instanceof AbstractAfterFailedEventRecord)) {
callerStack.pop();
if (!callerStack.isEmpty()) {
caller = callerStack.peek();
}
if (!stack.isEmpty() && (count == stack.peek())) {
stack.pop();
} else {
newTraceEvents.add(record);
}
count--;
} else {
newTraceEvents.add(record);
}
}
return new Trace(newTraceEvents, true);
}
private String getClazzFullQName(final String operationSignatureStr) {
final int brace = operationSignatureStr.indexOf('(');
final String signatureWithoutArguments = operationSignatureStr.substring(0, brace);
final int lastWhiteSpace = signatureWithoutArguments.lastIndexOf(' ');
final int lastDot = signatureWithoutArguments.lastIndexOf('.');
if (lastDot == -1) {
return "";
}
final String fullQClazzName = signatureWithoutArguments.substring(lastWhiteSpace + 1,
lastDot);
if (fullQClazzName.indexOf("$") > 0) {
return fullQClazzName.substring(0, fullQClazzName.indexOf("$"));
} else {
return fullQClazzName;
}
}
}
package explorviz.live_trace_processing.filter.reduction.summarization;
import explorviz.live_trace_processing.record.event.AbstractAfterEventRecord;
import explorviz.live_trace_processing.record.event.AbstractBeforeEventRecord;
public class Edge {
private AbstractBeforeEventRecord caller;
private AbstractBeforeEventRecord callee;
private AbstractAfterEventRecord callee_end;
private boolean taken;
public Edge(final AbstractBeforeEventRecord caller, final AbstractBeforeEventRecord callee) {
this.caller = caller;
this.callee = callee;
taken = false;
}
public AbstractAfterEventRecord getCallee_end() {
return callee_end;
}
public void setCallee_end(final AbstractAfterEventRecord callee_end) {
this.callee_end = callee_end;
}
public boolean isTaken() {
return taken;
}
public void setTaken(final boolean taken) {
this.taken = taken;
}
public AbstractBeforeEventRecord getCaller() {
return caller;
}
public void setCaller(final AbstractBeforeEventRecord caller) {
this.caller = caller;
}
public AbstractBeforeEventRecord getCallee() {
return callee;
}
public void setCallee(final AbstractBeforeEventRecord callee) {
this.callee = callee;
}
}
package explorviz.live_trace_processing.filter.reduction.summarization;
import java.util.ArrayList;
import java.util.List;
import explorviz.live_trace_processing.filter.IPipeReceiver;
import explorviz.live_trace_processing.filter.reduction.AbstractReductionFilter;
import explorviz.live_trace_processing.filter.reduction.ITraceReduction;
import explorviz.live_trace_processing.record.event.AbstractAfterEventRecord;
import explorviz.live_trace_processing.record.event.AbstractBeforeEventRecord;
import explorviz.live_trace_processing.record.event.AbstractEventRecord;
import explorviz.live_trace_processing.record.trace.Trace;
public class IterationFilter extends AbstractReductionFilter implements ITraceReduction {
public IterationFilter(final IPipeReceiver receiver) {
super(receiver, "IterationFilter");
}
@Override
protected Trace reduceTrace(final Trace trace) {
final List<AbstractEventRecord> newTraceEvents = new ArrayList<AbstractEventRecord>();
final List<AbstractEventRecord> traceEvents = trace.getTraceEvents();
int i = 0;
while (i < (traceEvents.size() - 3)) {
if (traceEvents.get(i) instanceof AbstractBeforeEventRecord) {
final AbstractBeforeEventRecord firstBeforeEvent = (AbstractBeforeEventRecord) traceEvents
.get(i);
if (traceEvents.get(i + 1) instanceof AbstractAfterEventRecord) {
final AbstractAfterEventRecord firstAfterEvent = (AbstractAfterEventRecord) traceEvents
.get(i + 1);
if (traceEvents.get(i + 2) instanceof AbstractBeforeEventRecord) {
final AbstractBeforeEventRecord secondBeforeEvent = (AbstractBeforeEventRecord) traceEvents
.get(i + 2);
if (firstBeforeEvent.compareTo(secondBeforeEvent) == 0) {
if (traceEvents.get(i + 3) instanceof AbstractAfterEventRecord) {
secondBeforeEvent.getRuntimeStatisticInformation().makeAccumulator(
0);
secondBeforeEvent.getRuntimeStatisticInformation().merge(
firstBeforeEvent.getRuntimeStatisticInformation(),
firstBeforeEvent.getObjectId());
i += 2;
} else {
newTraceEvents.add(firstBeforeEvent);
newTraceEvents.add(firstAfterEvent);
newTraceEvents.add(secondBeforeEvent);
i += 3;
}
} else {
newTraceEvents.add(firstBeforeEvent);
newTraceEvents.add(firstAfterEvent);
i += 2;
}
} else {
newTraceEvents.add(firstBeforeEvent);
newTraceEvents.add(firstAfterEvent);
i += 2;
}
} else {
newTraceEvents.add(firstBeforeEvent);
i++;
}
} else {
newTraceEvents.add(traceEvents.get(i));
i++;
}
}
while (i < traceEvents.size()) {
newTraceEvents.add(traceEvents.get(i));
i++;
}
final Trace reducedTrace = new Trace(newTraceEvents, true);
return reducedTrace;
}
}
package explorviz.live_trace_processing.filter.reduction.summarization;
import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
import explorviz.live_trace_processing.filter.IPipeReceiver;
import explorviz.live_trace_processing.filter.reduction.AbstractReductionFilter;
import explorviz.live_trace_processing.record.event.AbstractAfterEventRecord;
import explorviz.live_trace_processing.record.event.AbstractBeforeEventRecord;
import explorviz.live_trace_processing.record.event.AbstractEventRecord;
import explorviz.live_trace_processing.record.trace.Trace;
public class PatternSummarizationFilter extends AbstractReductionFilter {
public static final int DEFAULT_DISTANCE = 300;
public static final int DEFAULT_NESTINGLEVEL = 1;
private final int distance;
private final int nestingLevel;
// private int maxDistance = 0;
// private boolean nextRound = false;
// private int maxNestingLevel = 0;
public PatternSummarizationFilter(final IPipeReceiver receiver, final int distance,
final int nestingLevel) {
super(receiver, "PatternSummarization");
if (distance < 1) {
this.distance = DEFAULT_DISTANCE;
} else {
this.distance = distance;
}
if (nestingLevel < 1) {
this.nestingLevel = DEFAULT_NESTINGLEVEL;
} else {