Skip to content
Snippets Groups Projects
Commit 44d7b6f3 authored by Nils Christian Ehmke's avatar Nils Christian Ehmke
Browse files

Added some comparators; Minor refactoring to the execution entries

parent a56098e1
No related branches found
No related tags found
No related merge requests found
package kieker.gui.model.domain;
import java.util.ArrayList;
import java.util.List;
public abstract class AbstractExecutionEntry<T extends AbstractExecutionEntry<T>> {
protected final String container;
protected final String component;
protected final String operation;
protected String failedCause;
protected T parent;
protected final List<T> children = new ArrayList<>();
public AbstractExecutionEntry(final String container, final String component, final String operation) {
this.container = container;
this.component = component;
this.operation = operation;
}
public int getTraceDepth() {
int traceDepth = this.children.isEmpty() ? 0 : 1;
int maxChildrenTraceDepth = 0;
for (final T child : this.children) {
maxChildrenTraceDepth = Math.max(maxChildrenTraceDepth, child.getTraceDepth());
}
traceDepth += maxChildrenTraceDepth;
return traceDepth;
}
public int getTraceSize() {
int traceSize = 1;
for (final T child : this.children) {
traceSize += child.getTraceSize();
}
return traceSize;
}
public boolean isFailed() {
return (this.failedCause != null);
}
public String getFailedCause() {
return this.failedCause;
}
public void setFailedCause(final String failedCause) {
this.failedCause = failedCause;
}
public String getContainer() {
return this.container;
}
public String getComponent() {
return this.component;
}
public String getOperation() {
return this.operation;
}
public List<T> getChildren() {
return this.children;
}
public void addExecutionEntry(final T entry) {
this.children.add(entry);
entry.parent = (T) this;
}
public T getParent() {
return this.parent;
}
}
......@@ -16,69 +16,23 @@
package kieker.gui.model.domain;
import java.util.ArrayList;
import java.util.List;
public final class AggregatedExecutionEntry extends AbstractExecutionEntry<AggregatedExecutionEntry> {
public final class AggregatedExecutionEntry {
private final List<AggregatedExecutionEntry> children = new ArrayList<>();
private final String failedCause;
private final String container;
private final String component;
private final String operation;
private long minDuration;
private long maxDuration;
private long avgDuration;
private int calls;
public AggregatedExecutionEntry(final ExecutionEntry execEntry) {
this.container = execEntry.getContainer();
this.component = execEntry.getComponent();
this.operation = execEntry.getOperation();
this.failedCause = execEntry.getFailedCause();
super(execEntry.getContainer(), execEntry.getComponent(), execEntry.getOperation());
this.setFailedCause(execEntry.getFailedCause());
this.minDuration = execEntry.getDuration();
this.maxDuration = execEntry.getDuration();
for (final ExecutionEntry child : execEntry.getChildren()) {
this.children.add(new AggregatedExecutionEntry(child));
}
}
public int getTraceDepth() {
int traceDepth = this.children.isEmpty() ? 0 : 1;
int maxChildrenTraceDepth = 0;
for (final AggregatedExecutionEntry child : this.children) {
maxChildrenTraceDepth = Math.max(maxChildrenTraceDepth, child.getTraceDepth());
}
traceDepth += maxChildrenTraceDepth;
return traceDepth;
}
public int getTraceSize() {
int traceSize = 1;
for (final AggregatedExecutionEntry child : this.children) {
traceSize += child.getTraceSize();
super.addExecutionEntry(new AggregatedExecutionEntry(child));
}
return traceSize;
}
public List<AggregatedExecutionEntry> getChildren() {
return this.children;
}
public String getContainer() {
return this.container;
}
public String getComponent() {
return this.component;
}
public String getOperation() {
return this.operation;
}
public void incrementCalls(final ExecutionEntry executionEntry) {
......@@ -108,11 +62,4 @@ public final class AggregatedExecutionEntry {
return this.calls;
}
public String getFailedCause() {
return this.failedCause;
}
public boolean isFailed() {
return (this.failedCause != null);
}
}
......@@ -16,54 +16,23 @@
package kieker.gui.model.domain;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* A simplified representation of an execution within a trace. As an instance of this class can contain other instances, it can be used to represent a trace tree.
*
*
* @author Nils Christian Ehmke
*/
public final class ExecutionEntry {
public final class ExecutionEntry extends AbstractExecutionEntry<ExecutionEntry> {
private final long traceID;
private final String container;
private final String component;
private final String operation;
private float percent;
private long duration;
private String failedCause;
private ExecutionEntry parent;
private final List<ExecutionEntry> children = new ArrayList<>();
public ExecutionEntry(final long traceID, final String container, final String component, final String operation) {
super(container, component, operation);
this.traceID = traceID;
this.container = container;
this.component = component;
this.operation = operation;
}
public int getTraceDepth() {
int traceDepth = this.children.isEmpty() ? 0 : 1;
int maxChildrenTraceDepth = 0;
for (final ExecutionEntry child : this.children) {
maxChildrenTraceDepth = Math.max(maxChildrenTraceDepth, child.getTraceDepth());
}
traceDepth += maxChildrenTraceDepth;
return traceDepth;
}
public int getTraceSize() {
int traceSize = 1;
for (final ExecutionEntry child : this.children) {
traceSize += child.getTraceSize();
}
return traceSize;
}
public long getTraceID() {
......@@ -78,47 +47,10 @@ public final class ExecutionEntry {
this.duration = duration;
}
public boolean isFailed() {
return (this.failedCause != null);
}
public String getFailedCause() {
return this.failedCause;
}
public void setFailedCause(final String failedCause) {
this.failedCause = failedCause;
}
public float getPercent() {
return this.percent;
}
public String getContainer() {
return this.container;
}
public String getComponent() {
return this.component;
}
public String getOperation() {
return this.operation;
}
public List<ExecutionEntry> getChildren() {
return this.children;
}
public void addExecutionEntry(final ExecutionEntry entry) {
this.children.add(entry);
entry.parent = this;
}
public ExecutionEntry getParent() {
return this.parent;
}
public void recalculateValues() {
this.updatePercent();
}
......
......@@ -10,8 +10,10 @@ import kieker.gui.model.PropertiesModel;
import kieker.gui.model.TracesSubViewModel;
import kieker.gui.model.domain.ExecutionEntry;
import kieker.gui.view.util.ExecutionEntryComponentComparator;
import kieker.gui.view.util.ExecutionEntryContainerComparator;
import kieker.gui.view.util.ExecutionEntryDurationComparator;
import kieker.gui.view.util.ExecutionEntryOperationComparator;
import kieker.gui.view.util.ExecutionEntryTraceIDComparator;
import kieker.gui.view.util.TreeColumnSortListener;
import org.eclipse.swt.SWT;
......@@ -173,9 +175,11 @@ public class TracesSubView implements Observer {
this.tree.addSelectionListener(this.controller);
this.tree.addListener(SWT.SetData, new DataProvider());
trclmnExecutionContainer.addSelectionListener(new TreeColumnSortListener<>(new ExecutionEntryContainerComparator()));
trclmnComponent.addSelectionListener(new TreeColumnSortListener<>(new ExecutionEntryComponentComparator()));
trclmnOperation.addSelectionListener(new TreeColumnSortListener<>(new ExecutionEntryOperationComparator()));
trclmnDuration.addSelectionListener(new TreeColumnSortListener<>(new ExecutionEntryDurationComparator()));
trclmnTraceId.addSelectionListener(new TreeColumnSortListener<>(new ExecutionEntryTraceIDComparator()));
}
public Tree getTree() {
......
package kieker.gui.view.util;
import kieker.gui.model.domain.ExecutionEntry;
import org.eclipse.swt.SWT;
public class ExecutionEntryContainerComparator extends AbstractDirectedComparator<ExecutionEntry> {
@Override
public int compare(final ExecutionEntry arg0, final ExecutionEntry arg1) {
int result = arg0.getContainer().compareTo(arg1.getContainer());
if (this.getDirection() == SWT.UP) {
result = -result;
}
return result;
}
}
package kieker.gui.view.util;
import kieker.gui.model.domain.ExecutionEntry;
import org.eclipse.swt.SWT;
public class ExecutionEntryTraceIDComparator extends AbstractDirectedComparator<ExecutionEntry> {
@Override
public int compare(final ExecutionEntry arg0, final ExecutionEntry arg1) {
int result = Long.compare(arg0.getTraceID(), arg1.getTraceID());
if (this.getDirection() == SWT.UP) {
result = -result;
}
return result;
}
}
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