From 925f06a21bcbfc97587a2bc5f8db81d969922d43 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Genevi=C3=A8ve=20Bastien?= Date: Mon, 8 May 2017 21:44:50 -0400 Subject: [PATCH] critical path: Change relationship with graph builders MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This adds the critical path module as a child of the graph builder module. It also creates the view output under the graph builder and the view will open with the right execution graph selected. Change-Id: Ibee665489f1e618dcf478e4ea092ae6c3f9d92e2 Signed-off-by: Geneviève Bastien Reviewed-on: https://git.eclipse.org/r/96666 Reviewed-by: Matthew Khouzam Tested-by: Matthew Khouzam Reviewed-by: Hudson CI --- .../META-INF/MANIFEST.MF | 2 +- .../plugin.xml | 3 -- .../core/building/TmfGraphBuilderModule.java | 35 +++++++++++++++++- .../core/criticalpath/CriticalPathModule.java | 6 ++- .../criticalpath/ICriticalPathProvider.java | 28 ++++++++++++++ .../plugin.xml | 3 ++ .../view/CriticalPathBaseEntry.java | 16 +++++++- .../view/CriticalPathModuleListener.java | 37 +++++++++++++++++++ .../criticalpath/view/CriticalPathView.java | 32 ++++++++-------- .../TmfAbstractAnalysisParamProvider.java | 7 +++- 10 files changed, 143 insertions(+), 26 deletions(-) create mode 100644 analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/analysis/graph/core/criticalpath/ICriticalPathProvider.java create mode 100644 analysis/org.eclipse.tracecompass.analysis.graph.ui/src/org/eclipse/tracecompass/internal/analysis/graph/ui/criticalpath/view/CriticalPathModuleListener.java diff --git a/analysis/org.eclipse.tracecompass.analysis.graph.core/META-INF/MANIFEST.MF b/analysis/org.eclipse.tracecompass.analysis.graph.core/META-INF/MANIFEST.MF index 8add462dcb..60a2084b14 100644 --- a/analysis/org.eclipse.tracecompass.analysis.graph.core/META-INF/MANIFEST.MF +++ b/analysis/org.eclipse.tracecompass.analysis.graph.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-Vendor: %Bundle-Vendor -Bundle-Version: 1.0.1.qualifier +Bundle-Version: 1.1.0.qualifier Bundle-Localization: plugin Bundle-SymbolicName: org.eclipse.tracecompass.analysis.graph.core;singleton:=true Bundle-Activator: org.eclipse.tracecompass.internal.analysis.graph.core.Activator diff --git a/analysis/org.eclipse.tracecompass.analysis.graph.core/plugin.xml b/analysis/org.eclipse.tracecompass.analysis.graph.core/plugin.xml index 909bb21de4..67cc348594 100644 --- a/analysis/org.eclipse.tracecompass.analysis.graph.core/plugin.xml +++ b/analysis/org.eclipse.tracecompass.analysis.graph.core/plugin.xml @@ -17,9 +17,6 @@ - - diff --git a/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/analysis/graph/core/building/TmfGraphBuilderModule.java b/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/analysis/graph/core/building/TmfGraphBuilderModule.java index e63a9364cc..56304fa6e5 100644 --- a/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/analysis/graph/core/building/TmfGraphBuilderModule.java +++ b/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/analysis/graph/core/building/TmfGraphBuilderModule.java @@ -10,15 +10,20 @@ package org.eclipse.tracecompass.analysis.graph.core.building; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; import org.eclipse.tracecompass.analysis.graph.core.base.TmfGraph; +import org.eclipse.tracecompass.analysis.graph.core.criticalpath.CriticalPathModule; +import org.eclipse.tracecompass.analysis.graph.core.criticalpath.ICriticalPathProvider; import org.eclipse.tracecompass.internal.analysis.graph.core.Activator; import org.eclipse.tracecompass.tmf.core.analysis.TmfAbstractAnalysisModule; import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; import org.eclipse.tracecompass.tmf.core.event.TmfEvent; +import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException; import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest; import org.eclipse.tracecompass.tmf.core.request.TmfEventRequest; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; +import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; /** * Base class for all modules building graphs @@ -26,10 +31,11 @@ import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; * @author Francis Giraldeau * @author Geneviève Bastien */ -public abstract class TmfGraphBuilderModule extends TmfAbstractAnalysisModule { +public abstract class TmfGraphBuilderModule extends TmfAbstractAnalysisModule implements ICriticalPathProvider { private @Nullable TmfGraph fGraph; private @Nullable ITmfEventRequest fRequest; + private final CriticalPathModule fCriticalPathModule = new CriticalPathModule(); /** * Gets the graph provider to build this graph @@ -68,6 +74,19 @@ public abstract class TmfGraphBuilderModule extends TmfAbstractAnalysisModule { return !monitor.isCanceled(); } + @Override + public boolean setTrace(@NonNull ITmfTrace trace) throws TmfAnalysisException { + boolean ret = super.setTrace(trace); + if (!ret) { + return ret; + } + ret = fCriticalPathModule.setTrace(trace); + if (ret) { + fCriticalPathModule.setParameter(CriticalPathModule.PARAM_GRAPH, getId()); + } + return ret; + } + @Override protected void canceling() { ITmfEventRequest req = fRequest; @@ -76,6 +95,12 @@ public abstract class TmfGraphBuilderModule extends TmfAbstractAnalysisModule { } } + @Override + public void dispose() { + fCriticalPathModule.dispose(); + super.dispose(); + } + // ------------------------------------------------------------------------ // Graph creation methods // ------------------------------------------------------------------------ @@ -147,4 +172,12 @@ public abstract class TmfGraphBuilderModule extends TmfAbstractAnalysisModule { } + /** + * @since 1.1 + */ + @Override + public @Nullable TmfGraph getCriticalPath() { + return fCriticalPathModule.getCriticalPath(); + } + } diff --git a/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/analysis/graph/core/criticalpath/CriticalPathModule.java b/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/analysis/graph/core/criticalpath/CriticalPathModule.java index b0cf581630..0ec7cce779 100644 --- a/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/analysis/graph/core/criticalpath/CriticalPathModule.java +++ b/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/analysis/graph/core/criticalpath/CriticalPathModule.java @@ -33,7 +33,7 @@ import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils; * @author Francis Giraldeau * @author Geneviève Bastien */ -public class CriticalPathModule extends TmfAbstractAnalysisModule { +public class CriticalPathModule extends TmfAbstractAnalysisModule implements ICriticalPathProvider { /** * Analysis ID for this module @@ -55,6 +55,9 @@ public class CriticalPathModule extends TmfAbstractAnalysisModule { */ public CriticalPathModule() { super(); + addParameter(PARAM_GRAPH); + addParameter(PARAM_WORKER); + setId(ANALYSIS_ID); } @Override @@ -188,6 +191,7 @@ public class CriticalPathModule extends TmfAbstractAnalysisModule { * * @return The critical path graph */ + @Override public @Nullable TmfGraph getCriticalPath() { return fCriticalPath; } diff --git a/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/analysis/graph/core/criticalpath/ICriticalPathProvider.java b/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/analysis/graph/core/criticalpath/ICriticalPathProvider.java new file mode 100644 index 0000000000..269d8c2e50 --- /dev/null +++ b/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/analysis/graph/core/criticalpath/ICriticalPathProvider.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2017 École Polytechnique de Montréal + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.eclipse.tracecompass.analysis.graph.core.criticalpath; + +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.tracecompass.analysis.graph.core.base.TmfGraph; + +/** + * @author Geneviève Bastien + * @since 1.1 + */ +public interface ICriticalPathProvider { + + /** + * Get the critical path + * + * @return The critical path + */ + public @Nullable TmfGraph getCriticalPath(); + +} diff --git a/analysis/org.eclipse.tracecompass.analysis.graph.ui/plugin.xml b/analysis/org.eclipse.tracecompass.analysis.graph.ui/plugin.xml index 47224b33cc..fba00bb4a1 100644 --- a/analysis/org.eclipse.tracecompass.analysis.graph.ui/plugin.xml +++ b/analysis/org.eclipse.tracecompass.analysis.graph.ui/plugin.xml @@ -22,5 +22,8 @@ class="org.eclipse.tracecompass.analysis.graph.core.criticalpath.CriticalPathModule"> + + diff --git a/analysis/org.eclipse.tracecompass.analysis.graph.ui/src/org/eclipse/tracecompass/internal/analysis/graph/ui/criticalpath/view/CriticalPathBaseEntry.java b/analysis/org.eclipse.tracecompass.analysis.graph.ui/src/org/eclipse/tracecompass/internal/analysis/graph/ui/criticalpath/view/CriticalPathBaseEntry.java index 8087289444..bdb72e1548 100644 --- a/analysis/org.eclipse.tracecompass.analysis.graph.ui/src/org/eclipse/tracecompass/internal/analysis/graph/ui/criticalpath/view/CriticalPathBaseEntry.java +++ b/analysis/org.eclipse.tracecompass.analysis.graph.ui/src/org/eclipse/tracecompass/internal/analysis/graph/ui/criticalpath/view/CriticalPathBaseEntry.java @@ -10,6 +10,7 @@ package org.eclipse.tracecompass.internal.analysis.graph.ui.criticalpath.view; import org.eclipse.tracecompass.analysis.graph.core.base.IGraphWorker; +import org.eclipse.tracecompass.analysis.graph.core.criticalpath.CriticalPathModule; import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry; /** @@ -21,16 +22,20 @@ import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry; public class CriticalPathBaseEntry extends TimeGraphEntry { private final IGraphWorker fWorker; + private final CriticalPathModule fModule; /** * Constructor * * @param worker * The worker associated with this entry + * @param module + * The critical path module associated with this entry */ - public CriticalPathBaseEntry(IGraphWorker worker) { + public CriticalPathBaseEntry(IGraphWorker worker, CriticalPathModule module) { super("Base entry", Long.MIN_VALUE, Long.MAX_VALUE); //$NON-NLS-1$ fWorker = worker; + fModule = module; } /** @@ -42,4 +47,13 @@ public class CriticalPathBaseEntry extends TimeGraphEntry { return fWorker; } + /** + * Get the critical path module associated with this entry + * + * @return The critical path module + */ + public CriticalPathModule getModule() { + return fModule; + } + } diff --git a/analysis/org.eclipse.tracecompass.analysis.graph.ui/src/org/eclipse/tracecompass/internal/analysis/graph/ui/criticalpath/view/CriticalPathModuleListener.java b/analysis/org.eclipse.tracecompass.analysis.graph.ui/src/org/eclipse/tracecompass/internal/analysis/graph/ui/criticalpath/view/CriticalPathModuleListener.java new file mode 100644 index 0000000000..7efad596ee --- /dev/null +++ b/analysis/org.eclipse.tracecompass.analysis.graph.ui/src/org/eclipse/tracecompass/internal/analysis/graph/ui/criticalpath/view/CriticalPathModuleListener.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2017 École Polytechnique de Montréal + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.eclipse.tracecompass.internal.analysis.graph.ui.criticalpath.view; + +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.tracecompass.analysis.graph.core.building.TmfGraphBuilderModule; +import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule; +import org.eclipse.tracecompass.tmf.core.analysis.ITmfNewAnalysisModuleListener; +import org.eclipse.tracecompass.tmf.ui.analysis.TmfAnalysisViewOutput; + +/** + * @author Geneviève Bastien + */ +public class CriticalPathModuleListener implements ITmfNewAnalysisModuleListener { + + /** + * Constructor + */ + public CriticalPathModuleListener() { + + } + + @Override + public void moduleCreated(@Nullable IAnalysisModule module) { + if (module instanceof TmfGraphBuilderModule) { + module.registerOutput(new TmfAnalysisViewOutput(CriticalPathView.ID, module.getId())); + } + } + +} diff --git a/analysis/org.eclipse.tracecompass.analysis.graph.ui/src/org/eclipse/tracecompass/internal/analysis/graph/ui/criticalpath/view/CriticalPathView.java b/analysis/org.eclipse.tracecompass.analysis.graph.ui/src/org/eclipse/tracecompass/internal/analysis/graph/ui/criticalpath/view/CriticalPathView.java index b1b16d4435..aa46ba60f2 100644 --- a/analysis/org.eclipse.tracecompass.analysis.graph.ui/src/org/eclipse/tracecompass/internal/analysis/graph/ui/criticalpath/view/CriticalPathView.java +++ b/analysis/org.eclipse.tracecompass.analysis.graph.ui/src/org/eclipse/tracecompass/internal/analysis/graph/ui/criticalpath/view/CriticalPathView.java @@ -33,6 +33,7 @@ import org.eclipse.tracecompass.analysis.graph.core.base.TmfGraph; import org.eclipse.tracecompass.analysis.graph.core.base.TmfVertex; import org.eclipse.tracecompass.analysis.graph.core.building.TmfGraphBuilderModule; import org.eclipse.tracecompass.analysis.graph.core.criticalpath.CriticalPathModule; +import org.eclipse.tracecompass.analysis.graph.core.criticalpath.ICriticalPathProvider; import org.eclipse.tracecompass.common.core.NonNullUtils; import org.eclipse.tracecompass.internal.analysis.graph.core.base.TmfGraphStatistics; import org.eclipse.tracecompass.internal.analysis.graph.core.base.TmfGraphVisitor; @@ -195,24 +196,19 @@ public class CriticalPathView extends AbstractTimeGraphView { } private class BuildThread extends Thread { - private final ITmfTrace fBuildTrace; + private final CriticalPathModule fModule; private final IProgressMonitor fMonitor; - public BuildThread(final ITmfTrace trace) { + public BuildThread(final CriticalPathModule module) { super("Critical path view build"); //$NON-NLS-1$ - fBuildTrace = trace; + fModule = module; fMonitor = new NullProgressMonitor(); } @Override public void run() { try { - CriticalPathModule module = Iterables.<@Nullable CriticalPathModule> getFirst( - TmfTraceUtils.getAnalysisModulesOfClass(fBuildTrace, CriticalPathModule.class), - null); - if (module == null) { - return; - } + CriticalPathModule module = fModule; module.schedule(); if (module.waitForCompletion(fMonitor)) { // Module is completed, set the start and end time of @@ -320,8 +316,8 @@ public class CriticalPathView extends AbstractTimeGraphView { } private @Nullable TmfGraph getGraph(final ITmfTrace trace) { - CriticalPathModule module = Iterables.<@Nullable CriticalPathModule> getFirst( - TmfTraceUtils.getAnalysisModulesOfClass(trace, CriticalPathModule.class), + ICriticalPathProvider module = Iterables.<@Nullable ICriticalPathProvider> getFirst( + TmfTraceUtils.getAnalysisModulesOfClass(trace, ICriticalPathProvider.class), null); if (module == null) { throw new IllegalStateException("View requires an analysis module"); //$NON-NLS-1$ @@ -349,8 +345,8 @@ public class CriticalPathView extends AbstractTimeGraphView { return getLinksInRange(links, startTime, endTime); } - CriticalPathModule module = Iterables.<@Nullable CriticalPathModule> getFirst( - TmfTraceUtils.getAnalysisModulesOfClass(trace, CriticalPathModule.class), null); + ICriticalPathProvider module = Iterables.<@Nullable ICriticalPathProvider> getFirst( + TmfTraceUtils.getAnalysisModulesOfClass(trace, ICriticalPathProvider.class), null); if (module == null) { throw new IllegalStateException("View requires an analysis module"); //$NON-NLS-1$ } @@ -411,10 +407,12 @@ public class CriticalPathView extends AbstractTimeGraphView { if (list.isEmpty()) { return; } - final ITmfTrace trace = getTrace(); - if (trace == null) { + + Object first = list.get(0); + if (!(first instanceof CriticalPathBaseEntry)) { return; } + CriticalPathModule module = ((CriticalPathBaseEntry) first).getModule(); fSyncLock.lock(); try { @@ -422,7 +420,7 @@ public class CriticalPathView extends AbstractTimeGraphView { if (buildThread != null) { buildThread.cancel(); } - buildThread = new BuildThread(trace); + buildThread = new BuildThread(module); buildThread.start(); fBuildThread = buildThread; } finally { @@ -600,7 +598,7 @@ public class CriticalPathView extends AbstractTimeGraphView { } IGraphWorker worker = (IGraphWorker) obj; - TimeGraphEntry tge = new CriticalPathBaseEntry(worker); + TimeGraphEntry tge = new CriticalPathBaseEntry(worker, module); List list = Collections.singletonList(tge); putEntryList(trace, list); refresh(); diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/TmfAbstractAnalysisParamProvider.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/TmfAbstractAnalysisParamProvider.java index caae475db6..2255211cd9 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/TmfAbstractAnalysisParamProvider.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/TmfAbstractAnalysisParamProvider.java @@ -40,8 +40,11 @@ public abstract class TmfAbstractAnalysisParamProvider implements IAnalysisParam return; } IAnalysisModule selectedModule = selectedTrace.getAnalysisModule(module.getId()); - /* register only if the module is for the currently selected trace */ - if (selectedModule == module) { + /* + * register only if the module is for the currently selected trace or + * the current trace has no such module + */ + if (selectedModule == null || selectedModule == module) { fModule = module; } } -- 2.34.1