From 40593c42f5ca637847c3b4367eee8e0bc7af32b5 Mon Sep 17 00:00:00 2001 From: Nils Christian Ehmke <nie@informatik.uni-kiel.de> Date: Thu, 5 Feb 2015 15:47:18 +0100 Subject: [PATCH] Started with the presentation of (aggregated) calls --- .../diagnosis/common/model/DataModel.java | 13 + .../importer/ImportAnalysisConfiguration.java | 31 +- .../importer/stages/FailedCallFilter.java | 38 +++ .../stages/OperationCallExtractor.java | 21 ++ .../kieker/diagnosis/mainview/Controller.java | 36 ++- .../java/kieker/diagnosis/mainview/View.java | 37 ++- .../java/kieker/diagnosis/subview/Filter.java | 7 + .../subview/aggregatedcalls/Controller.java | 80 +++++ .../subview/aggregatedcalls/Model.java | 37 +++ .../subview/aggregatedcalls/View.java | 206 +++++++++++++ .../subview/aggregatedtraces/Controller.java | 9 +- .../subview/aggregatedtraces/View.java | 8 +- .../diagnosis/subview/calls/Controller.java | 96 ++++++ .../kieker/diagnosis/subview/calls/Model.java | 38 +++ .../kieker/diagnosis/subview/calls/View.java | 273 ++++++++++++++++++ .../calls/util/ComponentSortListener.java | 15 + .../calls/util/ContainerSortListener.java | 15 + .../calls/util/DurationSortListener.java | 15 + .../calls/util/OperationSortListener.java | 15 + .../calls/util/TraceIDSortListener.java | 15 + .../diagnosis/subview/traces/Controller.java | 15 +- .../AbstractCallTableColumnSortListener.java | 86 ++++++ 22 files changed, 1076 insertions(+), 30 deletions(-) create mode 100644 src/main/java/kieker/diagnosis/common/model/importer/stages/FailedCallFilter.java create mode 100644 src/main/java/kieker/diagnosis/common/model/importer/stages/OperationCallExtractor.java create mode 100644 src/main/java/kieker/diagnosis/subview/Filter.java create mode 100644 src/main/java/kieker/diagnosis/subview/aggregatedcalls/Controller.java create mode 100644 src/main/java/kieker/diagnosis/subview/aggregatedcalls/Model.java create mode 100644 src/main/java/kieker/diagnosis/subview/aggregatedcalls/View.java create mode 100644 src/main/java/kieker/diagnosis/subview/calls/Controller.java create mode 100644 src/main/java/kieker/diagnosis/subview/calls/Model.java create mode 100644 src/main/java/kieker/diagnosis/subview/calls/View.java create mode 100644 src/main/java/kieker/diagnosis/subview/calls/util/ComponentSortListener.java create mode 100644 src/main/java/kieker/diagnosis/subview/calls/util/ContainerSortListener.java create mode 100644 src/main/java/kieker/diagnosis/subview/calls/util/DurationSortListener.java create mode 100644 src/main/java/kieker/diagnosis/subview/calls/util/OperationSortListener.java create mode 100644 src/main/java/kieker/diagnosis/subview/calls/util/TraceIDSortListener.java create mode 100644 src/main/java/kieker/diagnosis/subview/util/AbstractCallTableColumnSortListener.java diff --git a/src/main/java/kieker/diagnosis/common/model/DataModel.java b/src/main/java/kieker/diagnosis/common/model/DataModel.java index 25aa616a..29144a18 100644 --- a/src/main/java/kieker/diagnosis/common/model/DataModel.java +++ b/src/main/java/kieker/diagnosis/common/model/DataModel.java @@ -25,6 +25,7 @@ import java.util.concurrent.TimeUnit; import kieker.common.record.misc.KiekerMetadataRecord; import kieker.diagnosis.common.domain.AggregatedTrace; +import kieker.diagnosis.common.domain.OperationCall; import kieker.diagnosis.common.domain.Trace; import kieker.diagnosis.common.model.importer.ImportAnalysisConfiguration; import teetime.framework.Analysis; @@ -42,6 +43,8 @@ public final class DataModel extends Observable { private List<AggregatedTrace> aggregatedTraces = Collections.emptyList(); private List<AggregatedTrace> failedAggregatedTraces = Collections.emptyList(); private List<AggregatedTrace> failureAggregatedContainingTraces = Collections.emptyList(); + private List<OperationCall> operationCalls = Collections.emptyList(); + private List<OperationCall> failedOperationCalls = Collections.emptyList(); private String shortTimeUnit = ""; public void loadMonitoringLogFromFS(final String directory) { @@ -58,6 +61,8 @@ public final class DataModel extends Observable { this.aggregatedTraces = analysisConfiguration.getAggregatedTraces(); this.failedAggregatedTraces = analysisConfiguration.getFailedAggregatedTracesList(); this.failureAggregatedContainingTraces = analysisConfiguration.getFailureContainingAggregatedTracesList(); + this.operationCalls = analysisConfiguration.getOperationCalls(); + this.failedOperationCalls = analysisConfiguration.getFailedOperationCalls(); final List<KiekerMetadataRecord> metadataRecords = analysisConfiguration.getMetadataRecords(); if (!metadataRecords.isEmpty()) { @@ -132,4 +137,12 @@ public final class DataModel extends Observable { return new ArrayList<>(this.failureAggregatedContainingTraces); } + public List<OperationCall> getOperationCalls() { + return new ArrayList<>(this.operationCalls); + } + + public List<OperationCall> getFailedOperationCalls() { + return new ArrayList<>(this.failedOperationCalls); + } + } diff --git a/src/main/java/kieker/diagnosis/common/model/importer/ImportAnalysisConfiguration.java b/src/main/java/kieker/diagnosis/common/model/importer/ImportAnalysisConfiguration.java index 5031c134..414b14e9 100644 --- a/src/main/java/kieker/diagnosis/common/model/importer/ImportAnalysisConfiguration.java +++ b/src/main/java/kieker/diagnosis/common/model/importer/ImportAnalysisConfiguration.java @@ -24,7 +24,10 @@ import kieker.common.record.IMonitoringRecord; import kieker.common.record.flow.IFlowRecord; import kieker.common.record.misc.KiekerMetadataRecord; import kieker.diagnosis.common.domain.AggregatedTrace; +import kieker.diagnosis.common.domain.OperationCall; import kieker.diagnosis.common.domain.Trace; +import kieker.diagnosis.common.model.importer.stages.FailedCallFilter; +import kieker.diagnosis.common.model.importer.stages.OperationCallExtractor; import kieker.diagnosis.common.model.importer.stages.ReadingComposite; import kieker.diagnosis.common.model.importer.stages.TraceAggregationComposite; import kieker.diagnosis.common.model.importer.stages.TraceReconstructionComposite; @@ -34,6 +37,8 @@ import teetime.framework.pipe.PipeFactoryRegistry.PipeOrdering; import teetime.framework.pipe.PipeFactoryRegistry.ThreadCommunication; import teetime.stage.CollectorSink; import teetime.stage.MultipleInstanceOfFilter; +import teetime.stage.basic.distributor.CopyByReferenceStrategy; +import teetime.stage.basic.distributor.Distributor; /** * A {@code TeeTime} configuration for the import and analysis of monitoring logs. @@ -46,6 +51,9 @@ public final class ImportAnalysisConfiguration extends AnalysisConfiguration { private final List<Trace> failedTraces = new ArrayList<>(1000); private final List<Trace> failureContainingTraces = new ArrayList<>(1000); + private final List<OperationCall> operationCalls = new ArrayList<>(1000); + private final List<OperationCall> failedOperationCalls = new ArrayList<>(1000); + private final List<AggregatedTrace> aggregatedTraces = new ArrayList<>(1000); private final List<AggregatedTrace> failedAggregatedTraces = new ArrayList<>(1000); private final List<AggregatedTrace> failureContainingAggregatedTraces = new ArrayList<>(1000); @@ -57,15 +65,26 @@ public final class ImportAnalysisConfiguration extends AnalysisConfiguration { final ReadingComposite reader = new ReadingComposite(importDirectory); final MultipleInstanceOfFilter<IMonitoringRecord> typeFilter = new MultipleInstanceOfFilter<>(); final TraceReconstructionComposite reconstruction = new TraceReconstructionComposite(this.traces, this.failedTraces, this.failureContainingTraces); + final Distributor<Trace> distributor = new Distributor<>(new CopyByReferenceStrategy()); + final OperationCallExtractor operationCallExtractor = new OperationCallExtractor(); final TraceAggregationComposite aggregation = new TraceAggregationComposite(this.aggregatedTraces, this.failedAggregatedTraces, this.failureContainingAggregatedTraces); - final CollectorSink<KiekerMetadataRecord> metadataCollector = new CollectorSink<>(this.metadataRecords); + final CollectorSink<OperationCall> callCollector = new CollectorSink<>(this.operationCalls); + final Distributor<OperationCall> distributor2 = new Distributor<>(new CopyByReferenceStrategy()); + final FailedCallFilter<OperationCall> failedCallFilter = new FailedCallFilter<>(); + final CollectorSink<OperationCall> failedCallCollector = new CollectorSink<>(this.failedOperationCalls); // Connect the stages final IPipeFactory pipeFactory = AnalysisConfiguration.PIPE_FACTORY_REGISTRY.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false); pipeFactory.create(reader.getOutputPort(), typeFilter.getInputPort()); pipeFactory.create(typeFilter.getOutputPortForType(IFlowRecord.class), reconstruction.getInputPort()); - pipeFactory.create(reconstruction.getOutputPort(), aggregation.getInputPort()); + pipeFactory.create(reconstruction.getOutputPort(), distributor.getInputPort()); + pipeFactory.create(distributor.getNewOutputPort(), operationCallExtractor.getInputPort()); + pipeFactory.create(operationCallExtractor.getOutputPort(), distributor2.getInputPort()); + pipeFactory.create(distributor2.getNewOutputPort(), callCollector.getInputPort()); + pipeFactory.create(distributor2.getNewOutputPort(), failedCallFilter.getInputPort()); + pipeFactory.create(failedCallFilter.getOutputPort(), failedCallCollector.getInputPort()); + pipeFactory.create(distributor.getNewOutputPort(), aggregation.getInputPort()); pipeFactory.create(typeFilter.getOutputPortForType(KiekerMetadataRecord.class), metadataCollector.getInputPort()); // Make sure that the producer is executed by the analysis @@ -100,4 +119,12 @@ public final class ImportAnalysisConfiguration extends AnalysisConfiguration { return this.metadataRecords; } + public List<OperationCall> getOperationCalls() { + return this.operationCalls; + } + + public List<OperationCall> getFailedOperationCalls() { + return this.failedOperationCalls; + } + } diff --git a/src/main/java/kieker/diagnosis/common/model/importer/stages/FailedCallFilter.java b/src/main/java/kieker/diagnosis/common/model/importer/stages/FailedCallFilter.java new file mode 100644 index 00000000..f76c13b4 --- /dev/null +++ b/src/main/java/kieker/diagnosis/common/model/importer/stages/FailedCallFilter.java @@ -0,0 +1,38 @@ +/*************************************************************************** + * 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.diagnosis.common.model.importer.stages; + +import kieker.diagnosis.common.domain.AbstractOperationCall; + +/** + * This stage filters incoming calls and forwards only those which are failed. + * + * @author Nils Christian Ehmke + * + * @param <T> + * The precise type of the incoming and outgoing calls. + */ +public final class FailedCallFilter<T extends AbstractOperationCall<?>> extends AbstractStage<T, T> { + + @Override + protected void execute(final T element) { + if (element.isFailed()) { + super.send(element); + } + } + +} diff --git a/src/main/java/kieker/diagnosis/common/model/importer/stages/OperationCallExtractor.java b/src/main/java/kieker/diagnosis/common/model/importer/stages/OperationCallExtractor.java new file mode 100644 index 00000000..b96fa7a1 --- /dev/null +++ b/src/main/java/kieker/diagnosis/common/model/importer/stages/OperationCallExtractor.java @@ -0,0 +1,21 @@ +package kieker.diagnosis.common.model.importer.stages; + +import kieker.diagnosis.common.domain.OperationCall; +import kieker.diagnosis.common.domain.Trace; + +public final class OperationCallExtractor extends AbstractStage<Trace, OperationCall> { + + @Override + protected void execute(final Trace element) { + this.sendAllCalls(element.getRootOperationCall()); + } + + private void sendAllCalls(final OperationCall call) { + super.send(call); + + for (final OperationCall child : call.getChildren()) { + this.sendAllCalls(child); + } + } + +} diff --git a/src/main/java/kieker/diagnosis/mainview/Controller.java b/src/main/java/kieker/diagnosis/mainview/Controller.java index 6779101a..b7af4832 100644 --- a/src/main/java/kieker/diagnosis/mainview/Controller.java +++ b/src/main/java/kieker/diagnosis/mainview/Controller.java @@ -25,10 +25,9 @@ import java.util.prefs.Preferences; import kieker.diagnosis.common.model.DataModel; import kieker.diagnosis.common.model.PropertiesModel; import kieker.diagnosis.dialog.SettingsDialog; +import kieker.diagnosis.subview.Filter; import kieker.diagnosis.subview.ISubController; import kieker.diagnosis.subview.ISubView; -import kieker.diagnosis.subview.aggregatedtraces.Controller.Filter; -import kieker.diagnosis.subview.traces.Controller.Type; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent; @@ -56,11 +55,15 @@ public final class Controller implements SelectionListener { // Create the sub-controllers final ISubController subViewController1 = new kieker.diagnosis.subview.aggregatedtraces.Controller(Filter.NONE, this.dataModel, propertiesModel); - final ISubController subViewController2 = new kieker.diagnosis.subview.traces.Controller(Type.JUST_FAILED_TRACES, this.dataModel, propertiesModel); - final ISubController subViewController3 = new kieker.diagnosis.subview.traces.Controller(Type.NONE, this.dataModel, propertiesModel); - final ISubController subViewController4 = new kieker.diagnosis.subview.traces.Controller(Type.JUST_FAILURE_CONTAINING_TRACES, this.dataModel, propertiesModel); - final ISubController subViewController5 = new kieker.diagnosis.subview.aggregatedtraces.Controller(Filter.JUST_FAILED_TRACES, this.dataModel, propertiesModel); - final ISubController subViewController6 = new kieker.diagnosis.subview.aggregatedtraces.Controller(Filter.JUST_FAILURE_CONTAINING_TRACES, this.dataModel, propertiesModel); + final ISubController subViewController2 = new kieker.diagnosis.subview.traces.Controller(Filter.JUST_FAILED, this.dataModel, propertiesModel); + final ISubController subViewController3 = new kieker.diagnosis.subview.traces.Controller(Filter.NONE, this.dataModel, propertiesModel); + final ISubController subViewController4 = new kieker.diagnosis.subview.traces.Controller(Filter.JUST_FAILURE_CONTAINING, this.dataModel, propertiesModel); + final ISubController subViewController5 = new kieker.diagnosis.subview.aggregatedtraces.Controller(Filter.JUST_FAILED, this.dataModel, propertiesModel); + final ISubController subViewController6 = new kieker.diagnosis.subview.aggregatedtraces.Controller(Filter.JUST_FAILURE_CONTAINING, this.dataModel, propertiesModel); + final ISubController subViewController7 = new kieker.diagnosis.subview.aggregatedcalls.Controller(Filter.NONE, this.dataModel, propertiesModel); + final ISubController subViewController8 = new kieker.diagnosis.subview.aggregatedcalls.Controller(Filter.JUST_FAILED, this.dataModel, propertiesModel); + final ISubController subViewController9 = new kieker.diagnosis.subview.calls.Controller(Filter.NONE, this.dataModel, propertiesModel); + final ISubController subViewController10 = new kieker.diagnosis.subview.calls.Controller(Filter.JUST_FAILED, this.dataModel, propertiesModel); // Get the sub-views from the controllers final Map<String, ISubView> subViews = new HashMap<>(); @@ -70,6 +73,10 @@ public final class Controller implements SelectionListener { subViews.put(SubView.FAILURE_CONTAINING_TRACES_SUB_VIEW.name(), subViewController4.getView()); subViews.put(SubView.FAILED_AGGREGATED_TRACES_SUB_VIEW.name(), subViewController5.getView()); subViews.put(SubView.FAILURE_CONTAINING_AGGREGATED_TRACES_SUB_VIEW.name(), subViewController6.getView()); + subViews.put(SubView.AGGREGATED_OPERATION_CALLS_SUB_VIEW.name(), subViewController7.getView()); + subViews.put(SubView.FAILED_AGGREGATED_OPERATION_CALLS_SUB_VIEW.name(), subViewController8.getView()); + subViews.put(SubView.OPERATION_CALLS_SUB_VIEW.name(), subViewController9.getView()); + subViews.put(SubView.FAILED_OPERATION_CALLS_SUB_VIEW.name(), subViewController10.getView()); // Create the main model and the main view this.mainViewModel = new Model(); @@ -144,6 +151,18 @@ public final class Controller implements SelectionListener { if (e.item == this.mainView.getTrtmJustAggTracesContaining()) { this.mainViewModel.setCurrentActiveSubView(SubView.FAILURE_CONTAINING_AGGREGATED_TRACES_SUB_VIEW.name()); } + if (e.item == this.mainView.getTrtmAggregatedOperationCalls()) { + this.mainViewModel.setCurrentActiveSubView(SubView.AGGREGATED_OPERATION_CALLS_SUB_VIEW.name()); + } + if (e.item == this.mainView.getTrtmFailedAggregatedOperationCalls()) { + this.mainViewModel.setCurrentActiveSubView(SubView.FAILED_AGGREGATED_OPERATION_CALLS_SUB_VIEW.name()); + } + if (e.item == this.mainView.getTrtmOperationCalls()) { + this.mainViewModel.setCurrentActiveSubView(SubView.OPERATION_CALLS_SUB_VIEW.name()); + } + if (e.item == this.mainView.getTrtmJustFailedOperation()) { + this.mainViewModel.setCurrentActiveSubView(SubView.FAILED_OPERATION_CALLS_SUB_VIEW.name()); + } } @Override @@ -153,7 +172,8 @@ public final class Controller implements SelectionListener { public enum SubView { TRACES_SUB_VIEW, FAILED_TRACES_SUB_VIEW, AGGREGATED_TRACES_SUB_VIEW, NONE, FAILURE_CONTAINING_TRACES_SUB_VIEW, FAILED_AGGREGATED_TRACES_SUB_VIEW, - FAILURE_CONTAINING_AGGREGATED_TRACES_SUB_VIEW + FAILURE_CONTAINING_AGGREGATED_TRACES_SUB_VIEW, AGGREGATED_OPERATION_CALLS_SUB_VIEW, FAILED_AGGREGATED_OPERATION_CALLS_SUB_VIEW, OPERATION_CALLS_SUB_VIEW, + FAILED_OPERATION_CALLS_SUB_VIEW, } } diff --git a/src/main/java/kieker/diagnosis/mainview/View.java b/src/main/java/kieker/diagnosis/mainview/View.java index 146d47af..cdca4cdc 100644 --- a/src/main/java/kieker/diagnosis/mainview/View.java +++ b/src/main/java/kieker/diagnosis/mainview/View.java @@ -72,6 +72,10 @@ public final class View implements Observer { private TreeItem trtmJustAggTracesContaining; private MenuItem mntmAbout; private MenuItem mntmSettings; + private TreeItem trtmAggregatedOperationCalls; + private TreeItem trtmJustFailedAggregated; + private TreeItem trtmOperationCalls; + private TreeItem trtmJustFailedOperation; public View(final Model mainViewModel, final Controller controller, final Map<String, ISubView> subViews, final PropertiesModel propertiesModel) { this.model = mainViewModel; @@ -127,6 +131,22 @@ public final class View implements Observer { return this.trtmJustAggTracesContaining; } + public Widget getTrtmAggregatedOperationCalls() { + return this.trtmAggregatedOperationCalls; + } + + public Widget getTrtmFailedAggregatedOperationCalls() { + return this.trtmJustFailedAggregated; + } + + public TreeItem getTrtmOperationCalls() { + return this.trtmOperationCalls; + } + + public TreeItem getTrtmJustFailedOperation() { + return this.trtmJustFailedOperation; + } + public MenuItem getMntmExit() { return this.mntmExit; } @@ -172,7 +192,7 @@ public final class View implements Observer { this.settingsDialog = new SettingsDialog(this.shell, SWT.NONE, this.propertiesModel); this.aboutDialog.setText("About..."); - this.aboutDialog.setMessage("Kieker Trace Diagnosis - 1.0-SNAPSHOT\n\nCopyright 2014 Kieker Project (http://kieker-monitoring.net)"); + this.aboutDialog.setMessage("Kieker Trace Diagnosis - 1.0-SNAPSHOT\n\nCopyright 2015 Kieker Project (http://kieker-monitoring.net)"); final SashForm sashForm = new SashForm(this.shell, SWT.NONE); @@ -200,6 +220,20 @@ public final class View implements Observer { this.trtmJustAggTracesContaining = new TreeItem(this.trtmAggregatedTraces, SWT.NONE); this.trtmJustAggTracesContaining.setText("Just Traces Containing Failures"); this.trtmAggregatedTraces.setExpanded(true); + + this.trtmOperationCalls = new TreeItem(this.trtmExplorer, SWT.NONE); + this.trtmOperationCalls.setText("Operation Calls"); + + this.trtmJustFailedOperation = new TreeItem(this.trtmOperationCalls, SWT.NONE); + this.trtmJustFailedOperation.setText("Just Failed Operation Calls"); + this.trtmOperationCalls.setExpanded(true); + + this.trtmAggregatedOperationCalls = new TreeItem(this.trtmExplorer, SWT.NONE); + this.trtmAggregatedOperationCalls.setText("Aggregated Operation Calls"); + + this.trtmJustFailedAggregated = new TreeItem(this.trtmAggregatedOperationCalls, SWT.NONE); + this.trtmJustFailedAggregated.setText("Just Failed Operation Calls"); + this.trtmAggregatedOperationCalls.setExpanded(true); this.trtmExplorer.setExpanded(true); this.subViewLayout = new StackLayout(); @@ -276,4 +310,5 @@ public final class View implements Observer { private void handleChangedCursor() { this.shell.setCursor(this.model.getCursor()); } + } diff --git a/src/main/java/kieker/diagnosis/subview/Filter.java b/src/main/java/kieker/diagnosis/subview/Filter.java new file mode 100644 index 00000000..b3483be5 --- /dev/null +++ b/src/main/java/kieker/diagnosis/subview/Filter.java @@ -0,0 +1,7 @@ +package kieker.diagnosis.subview; + +public enum Filter { + + NONE, JUST_FAILED, JUST_FAILURE_CONTAINING + +} diff --git a/src/main/java/kieker/diagnosis/subview/aggregatedcalls/Controller.java b/src/main/java/kieker/diagnosis/subview/aggregatedcalls/Controller.java new file mode 100644 index 00000000..bb434eb2 --- /dev/null +++ b/src/main/java/kieker/diagnosis/subview/aggregatedcalls/Controller.java @@ -0,0 +1,80 @@ +/*************************************************************************** + * 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.diagnosis.subview.aggregatedcalls; + +import java.util.List; + +import kieker.diagnosis.common.domain.AggregatedOperationCall; +import kieker.diagnosis.common.domain.OperationCall; +import kieker.diagnosis.common.model.DataModel; +import kieker.diagnosis.common.model.PropertiesModel; +import kieker.diagnosis.subview.Filter; +import kieker.diagnosis.subview.ISubController; +import kieker.diagnosis.subview.ISubView; +import kieker.diagnosis.subview.util.AbstractDataModelProxy; +import kieker.diagnosis.subview.util.IModel; + +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; + +public final class Controller implements ISubController, SelectionListener { + + private final ISubView view; + private final Model model; + + public Controller(final Filter filter, final DataModel dataModel, final PropertiesModel propertiesModel) { + final IModel<OperationCall> modelProxy = Controller.createModelProxy(dataModel, filter); + this.model = new Model(); + + this.view = new View(modelProxy, this.model, propertiesModel, this); + } + + @Override + public ISubView getView() { + return this.view; + } + + @Override + public void widgetSelected(final SelectionEvent e) { + if (e.item.getData() instanceof AggregatedOperationCall) { + this.model.setCurrentActiveCall((AggregatedOperationCall) e.item.getData()); + } + } + + @Override + public void widgetDefaultSelected(final SelectionEvent e) { + // Just implemented for the interface + } + + private static IModel<OperationCall> createModelProxy(final DataModel dataModel, final Filter filter) { + return new OperationCallsModelProxy(dataModel); + } + + private static final class OperationCallsModelProxy extends AbstractDataModelProxy<OperationCall> { + + public OperationCallsModelProxy(final DataModel dataModel) { + super(dataModel); + } + + @Override + public List<OperationCall> getContent() { + return super.getDataModel().getOperationCalls(); + } + + } + +} diff --git a/src/main/java/kieker/diagnosis/subview/aggregatedcalls/Model.java b/src/main/java/kieker/diagnosis/subview/aggregatedcalls/Model.java new file mode 100644 index 00000000..be6814ca --- /dev/null +++ b/src/main/java/kieker/diagnosis/subview/aggregatedcalls/Model.java @@ -0,0 +1,37 @@ +/*************************************************************************** + * 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.diagnosis.subview.aggregatedcalls; + +import java.util.Observable; + +import kieker.diagnosis.common.domain.AggregatedOperationCall; + +public final class Model extends Observable { + + private AggregatedOperationCall operationCall; + + public AggregatedOperationCall getCurrentActiveCall() { + return this.operationCall; + } + + public void setCurrentActiveCall(final AggregatedOperationCall operationCall) { + this.operationCall = operationCall; + + this.setChanged(); + this.notifyObservers(); + } +} diff --git a/src/main/java/kieker/diagnosis/subview/aggregatedcalls/View.java b/src/main/java/kieker/diagnosis/subview/aggregatedcalls/View.java new file mode 100644 index 00000000..bcb6dbd9 --- /dev/null +++ b/src/main/java/kieker/diagnosis/subview/aggregatedcalls/View.java @@ -0,0 +1,206 @@ +package kieker.diagnosis.subview.aggregatedcalls; + +import java.util.Observable; +import java.util.Observer; + +import kieker.diagnosis.common.domain.OperationCall; +import kieker.diagnosis.common.model.PropertiesModel; +import kieker.diagnosis.subview.ISubView; +import kieker.diagnosis.subview.util.IModel; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.SashForm; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.wb.swt.SWTResourceManager; + +public class View implements ISubView, Observer { + + private static final String N_A = "N/A"; + private Composite composite; + private Composite detailComposite; + private Label lblComponentDisplay; + private Label lblOperationDisplay; + private Label lblNumberOfCallsDisplay; + private Label lblMinimalDurationDisplay; + private Label lblAverageDurationDisplay; + private Label lblMeanDurationDisplay; + private Label lblMaximalDurationDisplay; + private Label lblFailedDisplay; + private Label lblExecutionContainerDisplay; + private Label lblFailed; + private Label lblTotalDurationDisplay; + private Composite statusBar; + private Label lblTraceEquivalence; + private Table table; + + public View(final IModel<OperationCall> modelProxy, final Model model, final PropertiesModel propertiesModel, final Controller controller) { + modelProxy.addObserver(this); + model.addObserver(this); + propertiesModel.addObserver(this); + } + + /** + * @wbp.parser.entryPoint + */ + @Override + public void createComposite(final Composite parent) { // NOPMD (This method violates some metrics) + if (this.composite != null) { + this.composite.dispose(); + } + + this.composite = new Composite(parent, SWT.NONE); + final GridLayout gl_composite = new GridLayout(1, false); + gl_composite.verticalSpacing = 0; + gl_composite.marginHeight = 0; + gl_composite.marginWidth = 0; + gl_composite.horizontalSpacing = 0; + this.composite.setLayout(gl_composite); + + final SashForm sashForm = new SashForm(this.composite, SWT.VERTICAL); + sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); + + this.table = new Table(sashForm, SWT.BORDER | SWT.FULL_SELECTION); + this.table.setHeaderVisible(true); + this.table.setLinesVisible(true); + + final TableColumn tblclmnExecutionContainer = new TableColumn(this.table, SWT.NONE); + tblclmnExecutionContainer.setWidth(100); + tblclmnExecutionContainer.setText("Execution Container"); + + final TableColumn tblclmnComponent = new TableColumn(this.table, SWT.NONE); + tblclmnComponent.setWidth(100); + tblclmnComponent.setText("Component"); + + final TableColumn tblclmnOperation = new TableColumn(this.table, SWT.NONE); + tblclmnOperation.setWidth(100); + tblclmnOperation.setText("Operation"); + + final TableColumn tblclmnNumberOfCalls = new TableColumn(this.table, SWT.NONE); + tblclmnNumberOfCalls.setWidth(100); + tblclmnNumberOfCalls.setText("Number of Calls"); + + final TableColumn tblclmnMinimalDuration = new TableColumn(this.table, SWT.NONE); + tblclmnMinimalDuration.setWidth(100); + tblclmnMinimalDuration.setText("Minimal Duration"); + + final TableColumn tblclmnMeanDuration = new TableColumn(this.table, SWT.NONE); + tblclmnMeanDuration.setWidth(100); + tblclmnMeanDuration.setText("Mean Duration"); + + final TableColumn tblclmnMedianDuration = new TableColumn(this.table, SWT.NONE); + tblclmnMedianDuration.setWidth(100); + tblclmnMedianDuration.setText("Median Duration"); + + final TableColumn tblclmnTotalDuration = new TableColumn(this.table, SWT.NONE); + tblclmnTotalDuration.setWidth(100); + tblclmnTotalDuration.setText("Total Duration"); + + this.detailComposite = new Composite(sashForm, SWT.BORDER); + this.detailComposite.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + this.detailComposite.setLayout(new GridLayout(2, false)); + + final Label lblExecutionContainer = new Label(this.detailComposite, SWT.NONE); + lblExecutionContainer.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + lblExecutionContainer.setText("Execution Container:"); + + this.lblExecutionContainerDisplay = new Label(this.detailComposite, SWT.NONE); + this.lblExecutionContainerDisplay.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + this.lblExecutionContainerDisplay.setText(View.N_A); + + final Label lblComponent = new Label(this.detailComposite, SWT.NONE); + lblComponent.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + lblComponent.setText("Component:"); + + this.lblComponentDisplay = new Label(this.detailComposite, SWT.NONE); + this.lblComponentDisplay.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + this.lblComponentDisplay.setText(View.N_A); + + final Label lblOperation = new Label(this.detailComposite, SWT.NONE); + lblOperation.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + lblOperation.setText("Operation:"); + + this.lblOperationDisplay = new Label(this.detailComposite, SWT.NONE); + this.lblOperationDisplay.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + this.lblOperationDisplay.setText(View.N_A); + + final Label lblNumberOfCalls = new Label(this.detailComposite, SWT.NONE); + lblNumberOfCalls.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + lblNumberOfCalls.setText("Number of Calls:"); + + this.lblNumberOfCallsDisplay = new Label(this.detailComposite, SWT.NONE); + this.lblNumberOfCallsDisplay.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + this.lblNumberOfCallsDisplay.setText(View.N_A); + + final Label lblMinimalDuration = new Label(this.detailComposite, SWT.NONE); + lblMinimalDuration.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + lblMinimalDuration.setText("Minimal Duration:"); + + this.lblMinimalDurationDisplay = new Label(this.detailComposite, SWT.NONE); + this.lblMinimalDurationDisplay.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + this.lblMinimalDurationDisplay.setText(View.N_A); + + final Label lblAverageDuration = new Label(this.detailComposite, SWT.NONE); + lblAverageDuration.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + lblAverageDuration.setText("Mean Duration:"); + + this.lblAverageDurationDisplay = new Label(this.detailComposite, SWT.NONE); + this.lblAverageDurationDisplay.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + this.lblAverageDurationDisplay.setText(View.N_A); + + final Label lblMeanDuration = new Label(this.detailComposite, SWT.NONE); + lblMeanDuration.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + lblMeanDuration.setText("Median Duration:"); + + this.lblMeanDurationDisplay = new Label(this.detailComposite, SWT.NONE); + this.lblMeanDurationDisplay.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + this.lblMeanDurationDisplay.setText(View.N_A); + + final Label lblMaximalDuration = new Label(this.detailComposite, SWT.NONE); + lblMaximalDuration.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + lblMaximalDuration.setText("Maximal Duration:"); + + this.lblMaximalDurationDisplay = new Label(this.detailComposite, SWT.NONE); + this.lblMaximalDurationDisplay.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + this.lblMaximalDurationDisplay.setText(View.N_A); + + final Label lblTotalDuration = new Label(this.detailComposite, SWT.NONE); + lblTotalDuration.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + lblTotalDuration.setText("Total Duration:"); + + this.lblTotalDurationDisplay = new Label(this.detailComposite, SWT.NONE); + this.lblTotalDurationDisplay.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + this.lblTotalDurationDisplay.setText(View.N_A); + + this.lblFailed = new Label(this.detailComposite, SWT.NONE); + this.lblFailed.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + this.lblFailed.setText("Failed:"); + + this.lblFailedDisplay = new Label(this.detailComposite, SWT.NONE); + this.lblFailedDisplay.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + this.lblFailedDisplay.setText(View.N_A); + sashForm.setWeights(new int[] { 2, 1 }); + + this.statusBar = new Composite(this.composite, SWT.NONE); + this.statusBar.setLayout(new GridLayout(1, false)); + + this.lblTraceEquivalence = new Label(this.statusBar, SWT.NONE); + this.lblTraceEquivalence.setText("0 Aggregated Operation Calls"); + } + + @Override + public Composite getComposite() { + return this.composite; + } + + @Override + public void update(final Observable arg0, final Object arg1) { + // TODO Auto-generated method stub + + } + +} diff --git a/src/main/java/kieker/diagnosis/subview/aggregatedtraces/Controller.java b/src/main/java/kieker/diagnosis/subview/aggregatedtraces/Controller.java index 32b653ba..cc36b267 100644 --- a/src/main/java/kieker/diagnosis/subview/aggregatedtraces/Controller.java +++ b/src/main/java/kieker/diagnosis/subview/aggregatedtraces/Controller.java @@ -22,6 +22,7 @@ import kieker.diagnosis.common.domain.AggregatedOperationCall; import kieker.diagnosis.common.domain.AggregatedTrace; import kieker.diagnosis.common.model.DataModel; import kieker.diagnosis.common.model.PropertiesModel; +import kieker.diagnosis.subview.Filter; import kieker.diagnosis.subview.ISubController; import kieker.diagnosis.subview.ISubView; import kieker.diagnosis.subview.util.AbstractDataModelProxy; @@ -60,19 +61,15 @@ public final class Controller implements ISubController, SelectionListener { } private static IModel<AggregatedTrace> createModelProxy(final DataModel dataModel, final Filter filter) { - if (filter == Filter.JUST_FAILED_TRACES) { + if (filter == Filter.JUST_FAILED) { return new FailedTracesModelProxy(dataModel); } - if (filter == Filter.JUST_FAILURE_CONTAINING_TRACES) { + if (filter == Filter.JUST_FAILURE_CONTAINING) { return new FailureContainingTracesModelProxy(dataModel); } return new TracesModelProxy(dataModel); } - public enum Filter { - NONE, JUST_FAILED_TRACES, JUST_FAILURE_CONTAINING_TRACES - } - private static final class TracesModelProxy extends AbstractDataModelProxy<AggregatedTrace> { public TracesModelProxy(final DataModel dataModel) { diff --git a/src/main/java/kieker/diagnosis/subview/aggregatedtraces/View.java b/src/main/java/kieker/diagnosis/subview/aggregatedtraces/View.java index e1d673b9..8c2e358d 100644 --- a/src/main/java/kieker/diagnosis/subview/aggregatedtraces/View.java +++ b/src/main/java/kieker/diagnosis/subview/aggregatedtraces/View.java @@ -136,11 +136,11 @@ public final class View implements Observer, ISubView { final TreeColumn trclmnAverageDuration = new TreeColumn(this.tree, SWT.RIGHT); trclmnAverageDuration.setWidth(100); - trclmnAverageDuration.setText("Average Duration"); + trclmnAverageDuration.setText("Mean Duration"); final TreeColumn trclmnMeanDuration = new TreeColumn(this.tree, SWT.RIGHT); trclmnMeanDuration.setWidth(100); - trclmnMeanDuration.setText("Mean Duration"); + trclmnMeanDuration.setText("Median Duration"); final TreeColumn trclmnMaximalDuration = new TreeColumn(this.tree, SWT.RIGHT); trclmnMaximalDuration.setWidth(100); @@ -196,7 +196,7 @@ public final class View implements Observer, ISubView { final Label lblAverageDuration = new Label(this.detailComposite, SWT.NONE); lblAverageDuration.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); - lblAverageDuration.setText("Average Duration:"); + lblAverageDuration.setText("Mean Duration:"); this.lblAverageDurationDisplay = new Label(this.detailComposite, SWT.NONE); this.lblAverageDurationDisplay.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); @@ -204,7 +204,7 @@ public final class View implements Observer, ISubView { final Label lblMeanDuration = new Label(this.detailComposite, SWT.NONE); lblMeanDuration.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); - lblMeanDuration.setText("Mean Duration:"); + lblMeanDuration.setText("Median Duration:"); this.lblMeanDurationDisplay = new Label(this.detailComposite, SWT.NONE); this.lblMeanDurationDisplay.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); diff --git a/src/main/java/kieker/diagnosis/subview/calls/Controller.java b/src/main/java/kieker/diagnosis/subview/calls/Controller.java new file mode 100644 index 00000000..f751546a --- /dev/null +++ b/src/main/java/kieker/diagnosis/subview/calls/Controller.java @@ -0,0 +1,96 @@ +/*************************************************************************** + * 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.diagnosis.subview.calls; + +import java.util.List; + +import kieker.diagnosis.common.domain.OperationCall; +import kieker.diagnosis.common.model.DataModel; +import kieker.diagnosis.common.model.PropertiesModel; +import kieker.diagnosis.subview.Filter; +import kieker.diagnosis.subview.ISubController; +import kieker.diagnosis.subview.ISubView; +import kieker.diagnosis.subview.util.AbstractDataModelProxy; +import kieker.diagnosis.subview.util.IModel; + +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; + +public final class Controller implements ISubController, SelectionListener { + + private final ISubView view; + private final Model model; + + public Controller(final Filter filter, final DataModel dataModel, final PropertiesModel propertiesModel) { + final IModel<OperationCall> modelProxy = Controller.createModelProxy(dataModel, filter); + this.model = new Model(); + + this.view = new View(modelProxy, this.model, propertiesModel, this); + } + + @Override + public ISubView getView() { + return this.view; + } + + @Override + public void widgetSelected(final SelectionEvent e) { + if (e.item.getData() instanceof OperationCall) { + this.model.setCurrentActiveCall((OperationCall) e.item.getData()); + } + } + + @Override + public void widgetDefaultSelected(final SelectionEvent e) { + // Just implemented for the interface + } + + private static IModel<OperationCall> createModelProxy(final DataModel dataModel, final Filter filter) { + if (filter == Filter.JUST_FAILED) { + return new FailedOperationCallsModelProxy(dataModel); + } else { + return new OperationCallsModelProxy(dataModel); + } + } + + private static final class FailedOperationCallsModelProxy extends AbstractDataModelProxy<OperationCall> { + + public FailedOperationCallsModelProxy(final DataModel dataModel) { + super(dataModel); + } + + @Override + public List<OperationCall> getContent() { + return super.getDataModel().getFailedOperationCalls(); + } + + } + + private static final class OperationCallsModelProxy extends AbstractDataModelProxy<OperationCall> { + + public OperationCallsModelProxy(final DataModel dataModel) { + super(dataModel); + } + + @Override + public List<OperationCall> getContent() { + return super.getDataModel().getOperationCalls(); + } + + } + +} diff --git a/src/main/java/kieker/diagnosis/subview/calls/Model.java b/src/main/java/kieker/diagnosis/subview/calls/Model.java new file mode 100644 index 00000000..f339c25f --- /dev/null +++ b/src/main/java/kieker/diagnosis/subview/calls/Model.java @@ -0,0 +1,38 @@ +/*************************************************************************** + * 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.diagnosis.subview.calls; + +import java.util.Observable; + +import kieker.diagnosis.common.domain.OperationCall; + +public final class Model extends Observable { + + private OperationCall operationCall; + + public OperationCall getCurrentActiveCall() { + return this.operationCall; + } + + public void setCurrentActiveCall(final OperationCall operationCall) { + this.operationCall = operationCall; + + this.setChanged(); + this.notifyObservers(); + } + +} diff --git a/src/main/java/kieker/diagnosis/subview/calls/View.java b/src/main/java/kieker/diagnosis/subview/calls/View.java new file mode 100644 index 00000000..fb0318c3 --- /dev/null +++ b/src/main/java/kieker/diagnosis/subview/calls/View.java @@ -0,0 +1,273 @@ +package kieker.diagnosis.subview.calls; + +import java.util.List; +import java.util.Observable; +import java.util.Observer; + +import kieker.diagnosis.common.domain.OperationCall; +import kieker.diagnosis.common.model.PropertiesModel; +import kieker.diagnosis.common.model.PropertiesModel.ComponentNames; +import kieker.diagnosis.common.model.PropertiesModel.OperationNames; +import kieker.diagnosis.subview.ISubView; +import kieker.diagnosis.subview.calls.util.ComponentSortListener; +import kieker.diagnosis.subview.calls.util.ContainerSortListener; +import kieker.diagnosis.subview.calls.util.DurationSortListener; +import kieker.diagnosis.subview.calls.util.OperationSortListener; +import kieker.diagnosis.subview.calls.util.TraceIDSortListener; +import kieker.diagnosis.subview.util.IModel; +import kieker.diagnosis.subview.util.NameConverter; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.SashForm; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.TableItem; +import org.eclipse.wb.swt.SWTResourceManager; + +public class View implements ISubView, Observer { + + private static final String N_A = "N/A"; + private Composite composite; + private Composite detailComposite; + private Label lblComponentDisplay; + private Label lblOperationDisplay; + private Label lblMinimalDurationDisplay; + private Label lblFailedDisplay; + private Label lblExecutionContainerDisplay; + private Label lblFailed; + private Composite statusBar; + private Label lblTraceEquivalence; + private Table table; + private final IModel<OperationCall> modelProxy; + private final PropertiesModel propertiesModel; + private final Model model; + private final Controller controller; + + public View(final IModel<OperationCall> modelProxy, final Model model, final PropertiesModel propertiesModel, final Controller controller) { + this.modelProxy = modelProxy; + this.model = model; + this.propertiesModel = propertiesModel; + this.controller = controller; + + modelProxy.addObserver(this); + model.addObserver(this); + propertiesModel.addObserver(this); + } + + /** + * @wbp.parser.entryPoint + */ + @Override + public void createComposite(final Composite parent) { // NOPMD (This method violates some metrics) + System.out.println("create!"); + if (this.composite != null) { + this.composite.dispose(); + } + + this.composite = new Composite(parent, SWT.NONE); + final GridLayout gl_composite = new GridLayout(1, false); + gl_composite.verticalSpacing = 0; + gl_composite.marginHeight = 0; + gl_composite.marginWidth = 0; + gl_composite.horizontalSpacing = 0; + this.composite.setLayout(gl_composite); + + final SashForm sashForm = new SashForm(this.composite, SWT.VERTICAL); + sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); + + this.table = new Table(sashForm, SWT.BORDER | SWT.FULL_SELECTION | SWT.VIRTUAL); + this.table.setHeaderVisible(true); + this.table.setLinesVisible(true); + + final TableColumn tblclmnExecutionContainer = new TableColumn(this.table, SWT.NONE); + tblclmnExecutionContainer.setWidth(100); + tblclmnExecutionContainer.setText("Execution Container"); + + final TableColumn tblclmnComponent = new TableColumn(this.table, SWT.NONE); + tblclmnComponent.setWidth(100); + tblclmnComponent.setText("Component"); + + final TableColumn tblclmnOperation = new TableColumn(this.table, SWT.NONE); + tblclmnOperation.setWidth(100); + tblclmnOperation.setText("Operation"); + + final TableColumn tblclmnMinimalDuration = new TableColumn(this.table, SWT.NONE); + tblclmnMinimalDuration.setWidth(100); + tblclmnMinimalDuration.setText("Duration"); + + final TableColumn tblclmnTotalDuration = new TableColumn(this.table, SWT.NONE); + tblclmnTotalDuration.setWidth(100); + tblclmnTotalDuration.setText("Trace ID"); + + this.detailComposite = new Composite(sashForm, SWT.BORDER); + this.detailComposite.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + this.detailComposite.setLayout(new GridLayout(2, false)); + + final Label lblExecutionContainer = new Label(this.detailComposite, SWT.NONE); + lblExecutionContainer.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + lblExecutionContainer.setText("Execution Container:"); + + this.lblExecutionContainerDisplay = new Label(this.detailComposite, SWT.NONE); + this.lblExecutionContainerDisplay.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + this.lblExecutionContainerDisplay.setText(View.N_A); + + final Label lblComponent = new Label(this.detailComposite, SWT.NONE); + lblComponent.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + lblComponent.setText("Component:"); + + this.lblComponentDisplay = new Label(this.detailComposite, SWT.NONE); + this.lblComponentDisplay.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + this.lblComponentDisplay.setText(View.N_A); + + final Label lblOperation = new Label(this.detailComposite, SWT.NONE); + lblOperation.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + lblOperation.setText("Operation:"); + + this.lblOperationDisplay = new Label(this.detailComposite, SWT.NONE); + this.lblOperationDisplay.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + this.lblOperationDisplay.setText(View.N_A); + + final Label lblMinimalDuration = new Label(this.detailComposite, SWT.NONE); + lblMinimalDuration.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + lblMinimalDuration.setText("Duration:"); + + this.lblMinimalDurationDisplay = new Label(this.detailComposite, SWT.NONE); + this.lblMinimalDurationDisplay.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + this.lblMinimalDurationDisplay.setText(View.N_A); + + this.lblFailed = new Label(this.detailComposite, SWT.NONE); + this.lblFailed.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + this.lblFailed.setText("Failed:"); + + this.lblFailedDisplay = new Label(this.detailComposite, SWT.NONE); + this.lblFailedDisplay.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + this.lblFailedDisplay.setText(View.N_A); + sashForm.setWeights(new int[] { 2, 1 }); + + this.statusBar = new Composite(this.composite, SWT.NONE); + this.statusBar.setLayout(new GridLayout(1, false)); + + this.lblTraceEquivalence = new Label(this.statusBar, SWT.NONE); + this.lblTraceEquivalence.setText("0 Operation Calls"); + + this.table.addListener(SWT.SetData, new DataProvider()); + this.table.addSelectionListener(this.controller); + + tblclmnComponent.addSelectionListener(new ComponentSortListener()); + tblclmnExecutionContainer.addSelectionListener(new ContainerSortListener()); + tblclmnOperation.addSelectionListener(new OperationSortListener()); + tblclmnMinimalDuration.addSelectionListener(new DurationSortListener()); + tblclmnTotalDuration.addSelectionListener(new TraceIDSortListener()); + } + + @Override + public Composite getComposite() { + return this.composite; + } + + @Override + public void update(final Observable observable, final Object obj) { + if (observable == this.modelProxy) { + this.updateTable(); + this.updateStatusBar(); + } + if (observable == this.model) { + this.updateDetailComposite(); + } + if (observable == this.propertiesModel) { + this.clearTable(); + } + } + + private void updateDetailComposite() { + final OperationCall call = this.model.getCurrentActiveCall(); + + final String duration = (call.getDuration() + " " + this.modelProxy.getShortTimeUnit()).trim(); + + this.lblMinimalDurationDisplay.setText(duration); + + this.lblExecutionContainerDisplay.setText(call.getContainer()); + this.lblComponentDisplay.setText(call.getComponent()); + this.lblOperationDisplay.setText(call.getOperation()); + + if (call.isFailed()) { + this.lblFailedDisplay.setText("Yes (" + call.getFailedCause() + ")"); + this.lblFailedDisplay.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); + this.lblFailed.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); + } else { + this.lblFailedDisplay.setText("No"); + this.lblFailedDisplay.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); + this.lblFailed.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); + } + + this.detailComposite.layout(); + } + + private void updateStatusBar() { + this.lblTraceEquivalence.setText(this.modelProxy.getContent().size() + " Operation Call(s)"); + this.statusBar.getParent().layout(); + } + + private void updateTable() { + final List<OperationCall> calls = this.modelProxy.getContent(); + + this.table.setData(calls); + this.table.setItemCount(calls.size()); + this.clearTable(); + } + + private void clearTable() { + this.table.clearAll(); + + for (final TableColumn column : this.table.getColumns()) { + column.pack(); + } + } + + private class DataProvider implements Listener { + + @Override + @SuppressWarnings("unchecked") + public void handleEvent(final Event event) { + // Get the necessary information from the event + final Table table = (Table) event.widget; + final TableItem item = (TableItem) event.item; + final int tableIndex = event.index; + + // Get the data for the current row + final List<OperationCall> calls = (List<OperationCall>) table.getData(); + final OperationCall call = calls.get(tableIndex); + + // Get the data to display + String componentName = call.getComponent(); + if (View.this.propertiesModel.getComponentNames() == ComponentNames.SHORT) { + componentName = NameConverter.toShortComponentName(componentName); + } + String operationString = call.getOperation(); + if (View.this.propertiesModel.getOperationNames() == OperationNames.SHORT) { + operationString = NameConverter.toShortOperationName(operationString); + } + + final String shortTimeUnit = View.this.modelProxy.getShortTimeUnit().trim(); + item.setText(new String[] { call.getContainer(), componentName, operationString, Long.toString(call.getDuration()) + " " + shortTimeUnit, + Long.toString(call.getTraceID()) }); + + if (call.isFailed()) { + final Color colorRed = Display.getCurrent().getSystemColor(SWT.COLOR_RED); + item.setForeground(colorRed); + } + + item.setData(call); + } + + } + +} diff --git a/src/main/java/kieker/diagnosis/subview/calls/util/ComponentSortListener.java b/src/main/java/kieker/diagnosis/subview/calls/util/ComponentSortListener.java new file mode 100644 index 00000000..3db3d6f9 --- /dev/null +++ b/src/main/java/kieker/diagnosis/subview/calls/util/ComponentSortListener.java @@ -0,0 +1,15 @@ +package kieker.diagnosis.subview.calls.util; + +import kieker.diagnosis.common.domain.OperationCall; +import kieker.diagnosis.subview.util.AbstractCallTableColumnSortListener; + +public class ComponentSortListener extends AbstractCallTableColumnSortListener<OperationCall> { + + private static final long serialVersionUID = 1L; + + @Override + protected int compare(final OperationCall fstCall, final OperationCall sndCall) { + return fstCall.getComponent().compareTo(sndCall.getComponent()); + } + +} diff --git a/src/main/java/kieker/diagnosis/subview/calls/util/ContainerSortListener.java b/src/main/java/kieker/diagnosis/subview/calls/util/ContainerSortListener.java new file mode 100644 index 00000000..56ed25a8 --- /dev/null +++ b/src/main/java/kieker/diagnosis/subview/calls/util/ContainerSortListener.java @@ -0,0 +1,15 @@ +package kieker.diagnosis.subview.calls.util; + +import kieker.diagnosis.common.domain.OperationCall; +import kieker.diagnosis.subview.util.AbstractCallTableColumnSortListener; + +public class ContainerSortListener extends AbstractCallTableColumnSortListener<OperationCall> { + + private static final long serialVersionUID = 1L; + + @Override + protected int compare(final OperationCall fstCall, final OperationCall sndCall) { + return fstCall.getContainer().compareTo(sndCall.getContainer()); + } + +} diff --git a/src/main/java/kieker/diagnosis/subview/calls/util/DurationSortListener.java b/src/main/java/kieker/diagnosis/subview/calls/util/DurationSortListener.java new file mode 100644 index 00000000..d11ea753 --- /dev/null +++ b/src/main/java/kieker/diagnosis/subview/calls/util/DurationSortListener.java @@ -0,0 +1,15 @@ +package kieker.diagnosis.subview.calls.util; + +import kieker.diagnosis.common.domain.OperationCall; +import kieker.diagnosis.subview.util.AbstractCallTableColumnSortListener; + +public class DurationSortListener extends AbstractCallTableColumnSortListener<OperationCall> { + + private static final long serialVersionUID = 1L; + + @Override + protected int compare(final OperationCall fstCall, final OperationCall sndCall) { + return Long.compare(fstCall.getDuration(), sndCall.getDuration()); + } + +} diff --git a/src/main/java/kieker/diagnosis/subview/calls/util/OperationSortListener.java b/src/main/java/kieker/diagnosis/subview/calls/util/OperationSortListener.java new file mode 100644 index 00000000..bc7a9da5 --- /dev/null +++ b/src/main/java/kieker/diagnosis/subview/calls/util/OperationSortListener.java @@ -0,0 +1,15 @@ +package kieker.diagnosis.subview.calls.util; + +import kieker.diagnosis.common.domain.OperationCall; +import kieker.diagnosis.subview.util.AbstractCallTableColumnSortListener; + +public class OperationSortListener extends AbstractCallTableColumnSortListener<OperationCall> { + + private static final long serialVersionUID = 1L; + + @Override + protected int compare(final OperationCall fstCall, final OperationCall sndCall) { + return fstCall.getOperation().compareTo(sndCall.getOperation()); + } + +} diff --git a/src/main/java/kieker/diagnosis/subview/calls/util/TraceIDSortListener.java b/src/main/java/kieker/diagnosis/subview/calls/util/TraceIDSortListener.java new file mode 100644 index 00000000..473e0b1c --- /dev/null +++ b/src/main/java/kieker/diagnosis/subview/calls/util/TraceIDSortListener.java @@ -0,0 +1,15 @@ +package kieker.diagnosis.subview.calls.util; + +import kieker.diagnosis.common.domain.OperationCall; +import kieker.diagnosis.subview.util.AbstractCallTableColumnSortListener; + +public class TraceIDSortListener extends AbstractCallTableColumnSortListener<OperationCall> { + + private static final long serialVersionUID = 1L; + + @Override + protected int compare(final OperationCall fstCall, final OperationCall sndCall) { + return Long.compare(fstCall.getTraceID(), sndCall.getTraceID()); + } + +} diff --git a/src/main/java/kieker/diagnosis/subview/traces/Controller.java b/src/main/java/kieker/diagnosis/subview/traces/Controller.java index aeb42dc5..8699a58b 100644 --- a/src/main/java/kieker/diagnosis/subview/traces/Controller.java +++ b/src/main/java/kieker/diagnosis/subview/traces/Controller.java @@ -22,6 +22,7 @@ import kieker.diagnosis.common.domain.OperationCall; import kieker.diagnosis.common.domain.Trace; import kieker.diagnosis.common.model.DataModel; import kieker.diagnosis.common.model.PropertiesModel; +import kieker.diagnosis.subview.Filter; import kieker.diagnosis.subview.ISubController; import kieker.diagnosis.subview.ISubView; import kieker.diagnosis.subview.util.AbstractDataModelProxy; @@ -32,7 +33,7 @@ import org.eclipse.swt.events.SelectionListener; /** * The sub-controller responsible for the sub-view presenting the available traces. - * + * * @author Nils Christian Ehmke */ public final class Controller implements ISubController, SelectionListener { @@ -40,7 +41,7 @@ public final class Controller implements ISubController, SelectionListener { private final ISubView view; private final Model model; - public Controller(final Type filter, final DataModel dataModel, final PropertiesModel propertiesModel) { + public Controller(final Filter filter, final DataModel dataModel, final PropertiesModel propertiesModel) { final IModel<Trace> modelProxy = Controller.createModelProxy(dataModel, filter); this.model = new Model(); @@ -64,20 +65,16 @@ public final class Controller implements ISubController, SelectionListener { // Just implemented for the interface } - private static IModel<Trace> createModelProxy(final DataModel dataModel, final Type filter) { - if (filter == Type.JUST_FAILED_TRACES) { + private static IModel<Trace> createModelProxy(final DataModel dataModel, final Filter filter) { + if (filter == Filter.JUST_FAILED) { return new FailedTracesModelProxy(dataModel); } - if (filter == Type.JUST_FAILURE_CONTAINING_TRACES) { + if (filter == Filter.JUST_FAILURE_CONTAINING) { return new FailureContainingTracesModelProxy(dataModel); } return new TracesModelProxy(dataModel); } - public enum Type { - NONE, JUST_FAILED_TRACES, JUST_FAILURE_CONTAINING_TRACES - } - private static final class TracesModelProxy extends AbstractDataModelProxy<Trace> { public TracesModelProxy(final DataModel dataModel) { diff --git a/src/main/java/kieker/diagnosis/subview/util/AbstractCallTableColumnSortListener.java b/src/main/java/kieker/diagnosis/subview/util/AbstractCallTableColumnSortListener.java new file mode 100644 index 00000000..63d228d5 --- /dev/null +++ b/src/main/java/kieker/diagnosis/subview/util/AbstractCallTableColumnSortListener.java @@ -0,0 +1,86 @@ +/*************************************************************************** + * 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.diagnosis.subview.util; + +import java.io.Serializable; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +import kieker.diagnosis.common.domain.AbstractOperationCall; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; + +public abstract class AbstractCallTableColumnSortListener<T extends AbstractOperationCall<?>> extends SelectionAdapter implements Serializable { + + private static final long serialVersionUID = 1L; + + private final CallComparator comparator = new CallComparator(); + private int direction; + + @Override + @SuppressWarnings("unchecked") + public final void widgetSelected(final SelectionEvent event) { + // Get the necessary information from the event + final TableColumn currentColumn = (TableColumn) event.widget; + final Table table = currentColumn.getParent(); + final TableColumn sortColumn = table.getSortColumn(); + + // Determine new sort column and direction + this.direction = table.getSortDirection(); + if (sortColumn == currentColumn) { + this.direction = ((this.direction == SWT.UP) ? SWT.DOWN : SWT.UP); + } else { + table.setSortColumn(currentColumn); + this.direction = SWT.UP; + } + + // Sort the data + final List<T> entries = (List<T>) table.getData(); + Collections.sort(entries, this.comparator); + + // Update the data displayed in the table + table.setSortDirection(this.direction); + table.clearAll(); + } + + protected abstract int compare(final T fstCall, final T sndCall); + + private final class CallComparator implements Comparator<T>, Serializable { + + private static final long serialVersionUID = 1L; + + @Override + public int compare(final T fstCall, final T sndCall) { + int result; + + if (AbstractCallTableColumnSortListener.this.direction == SWT.DOWN) { + result = AbstractCallTableColumnSortListener.this.compare(fstCall, sndCall); + } else { + result = AbstractCallTableColumnSortListener.this.compare(sndCall, fstCall); + } + + return result; + } + + } + +} -- GitLab