From 106254920582eae9e1da70fbdd2e2fc47f33abac Mon Sep 17 00:00:00 2001 From: Nils Christian Ehmke <nie@informatik.uni-kiel.de> Date: Mon, 8 Dec 2014 15:47:31 +0100 Subject: [PATCH] Refactoring and comments --- .../gui/model/AggregatedExecutionEntry.java | 16 ++++++++++++++++ .../kieker/gui/model/importer/filter/Cloner.java | 13 ++++++------- .../model/importer/filter/TraceAggregator.java | 12 +++++++----- .../importer/filter/TraceReconstructor.java | 7 ++++--- ...pdateObserver.java => ClearTreeObserver.java} | 11 ++++++++--- src/main/java/kieker/gui/view/MainWindow.java | 4 ++-- 6 files changed, 43 insertions(+), 20 deletions(-) rename src/main/java/kieker/gui/view/{TreeUpdateObserver.java => ClearTreeObserver.java} (58%) diff --git a/src/main/java/kieker/gui/model/AggregatedExecutionEntry.java b/src/main/java/kieker/gui/model/AggregatedExecutionEntry.java index efc6ef1a..9fcf9db2 100644 --- a/src/main/java/kieker/gui/model/AggregatedExecutionEntry.java +++ b/src/main/java/kieker/gui/model/AggregatedExecutionEntry.java @@ -1,3 +1,19 @@ +/*************************************************************************** + * Copyright 2014 Kieker Project (http://kieker-monitoring.net) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ***************************************************************************/ + package kieker.gui.model; import java.util.ArrayList; diff --git a/src/main/java/kieker/gui/model/importer/filter/Cloner.java b/src/main/java/kieker/gui/model/importer/filter/Cloner.java index d827eb8c..77533363 100644 --- a/src/main/java/kieker/gui/model/importer/filter/Cloner.java +++ b/src/main/java/kieker/gui/model/importer/filter/Cloner.java @@ -29,6 +29,12 @@ public final class Cloner<T> extends AbstractConsumerStage<T> { private final OutputPort<T> firstOutputPort = super.createOutputPort(); private final OutputPort<T> secondOutputPort = super.createOutputPort(); + @Override + protected void execute(final T element) { + this.firstOutputPort.send(element); + this.secondOutputPort.send(element); + } + public OutputPort<T> getFirstOutputPort() { return this.firstOutputPort; } @@ -36,11 +42,4 @@ public final class Cloner<T> extends AbstractConsumerStage<T> { public OutputPort<T> getSecondOutputPort() { return this.secondOutputPort; } - - @Override - protected void execute(final T element) { - this.firstOutputPort.send(element); - this.secondOutputPort.send(element); - } - } diff --git a/src/main/java/kieker/gui/model/importer/filter/TraceAggregator.java b/src/main/java/kieker/gui/model/importer/filter/TraceAggregator.java index d852bab3..97dab84b 100644 --- a/src/main/java/kieker/gui/model/importer/filter/TraceAggregator.java +++ b/src/main/java/kieker/gui/model/importer/filter/TraceAggregator.java @@ -25,6 +25,8 @@ import teetime.framework.AbstractConsumerStage; import teetime.framework.OutputPort; /** + * Aggregates incoming traces into trace equivalence classes. + * * @author Nils Christian Ehmke */ public final class TraceAggregator extends AbstractConsumerStage<ExecutionEntry> { @@ -33,12 +35,12 @@ public final class TraceAggregator extends AbstractConsumerStage<ExecutionEntry> private final Map<ExecutionEntry, AggregatedExecutionEntry> aggregationMap = new HashMap<>(); @Override - protected void execute(final ExecutionEntry execEntry) { - if (!this.aggregationMap.containsKey(execEntry)) { - final AggregatedExecutionEntry aggregatedExecutionEntry = new AggregatedExecutionEntry(execEntry); - this.aggregationMap.put(execEntry, aggregatedExecutionEntry); + protected void execute(final ExecutionEntry executionEntry) { + if (!this.aggregationMap.containsKey(executionEntry)) { + final AggregatedExecutionEntry aggregatedExecutionEntry = new AggregatedExecutionEntry(executionEntry); + this.aggregationMap.put(executionEntry, aggregatedExecutionEntry); } - this.aggregationMap.get(execEntry).incrementCalls(); + this.aggregationMap.get(executionEntry).incrementCalls(); } @Override diff --git a/src/main/java/kieker/gui/model/importer/filter/TraceReconstructor.java b/src/main/java/kieker/gui/model/importer/filter/TraceReconstructor.java index 440b4274..42454d88 100644 --- a/src/main/java/kieker/gui/model/importer/filter/TraceReconstructor.java +++ b/src/main/java/kieker/gui/model/importer/filter/TraceReconstructor.java @@ -32,10 +32,11 @@ import teetime.framework.AbstractConsumerStage; import teetime.framework.OutputPort; /** - * Reconstruct traces based on the incoming instances of {@code IFlowRecord}. Currently only {@link TraceMetadata}, {@link BeforeOperationEvent} and {@link AfterOperationEvent} instances are supported. + * Reconstruct traces based on the incoming instances of {@code IFlowRecord}. Currently only {@link TraceMetadata}, {@link BeforeOperationEvent} and + * {@link AfterOperationEvent} instances are supported. * * @author Nils Christian Ehmke - */ + */ public final class TraceReconstructor extends AbstractConsumerStage<IFlowRecord> { private final OutputPort<ExecutionEntry> outputPort = super.createOutputPort(); @@ -72,7 +73,7 @@ public final class TraceReconstructor extends AbstractConsumerStage<IFlowRecord> return this.outputPort; } - private final static class TraceBuffer { + private static final class TraceBuffer { private final String hostname; private final Deque<BeforeOperationEvent> stack = new LinkedList<>(); diff --git a/src/main/java/kieker/gui/view/TreeUpdateObserver.java b/src/main/java/kieker/gui/view/ClearTreeObserver.java similarity index 58% rename from src/main/java/kieker/gui/view/TreeUpdateObserver.java rename to src/main/java/kieker/gui/view/ClearTreeObserver.java index 1f308cb9..f446fd55 100644 --- a/src/main/java/kieker/gui/view/TreeUpdateObserver.java +++ b/src/main/java/kieker/gui/view/ClearTreeObserver.java @@ -5,11 +5,16 @@ import java.util.Observer; import org.eclipse.swt.widgets.Tree; -class TreeUpdateObserver implements Observer { +/** + * An observer clearing an instance of {@link Tree}. + * + * @author Nils Christian Ehmke + */ +public final class ClearTreeObserver implements Observer { private final Tree tree; - public TreeUpdateObserver(final Tree tree) { + public ClearTreeObserver(final Tree tree) { this.tree = tree; } @@ -18,4 +23,4 @@ class TreeUpdateObserver implements Observer { this.tree.clearAll(true); } -} \ No newline at end of file +} diff --git a/src/main/java/kieker/gui/view/MainWindow.java b/src/main/java/kieker/gui/view/MainWindow.java index 46be0975..d812ff13 100644 --- a/src/main/java/kieker/gui/view/MainWindow.java +++ b/src/main/java/kieker/gui/view/MainWindow.java @@ -208,7 +208,7 @@ public class MainWindow { this.executionTracesTree.setHeaderVisible(true); this.executionTracesTree.addListener(SWT.SetData, new ExecutionTracesTreeSetDataListener()); this.executionTracesTree.addSelectionListener(new ExecutionTraceTreeSelectionListener(this)); - Properties.getInstance().addObserver(new TreeUpdateObserver(this.executionTracesTree)); + Properties.getInstance().addObserver(new ClearTreeObserver(this.executionTracesTree)); this.tracesTreeContainerColumn = new TreeColumn(this.executionTracesTree, SWT.NONE); this.tracesTreeContainerColumn.setWidth(100); @@ -301,7 +301,7 @@ public class MainWindow { this.tree_1 = new Tree(this.sashForm, SWT.BORDER | SWT.FULL_SELECTION | SWT.VIRTUAL); this.tree_1.setHeaderVisible(true); this.tree_1.addListener(SWT.SetData, new AggregatedExecutionTracesTreeSetDataListener()); - Properties.getInstance().addObserver(new TreeUpdateObserver(this.tree_1)); + Properties.getInstance().addObserver(new ClearTreeObserver(this.tree_1)); this.treeColumn = new TreeColumn(this.tree_1, SWT.NONE); this.treeColumn.setWidth(100); -- GitLab