critical path: Change relationship with graph builders
authorGeneviève Bastien <gbastien+lttng@versatic.net>
Tue, 9 May 2017 01:44:50 +0000 (21:44 -0400)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Mon, 15 May 2017 19:55:48 +0000 (15:55 -0400)
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 <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/96666
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-by: Hudson CI
analysis/org.eclipse.tracecompass.analysis.graph.core/META-INF/MANIFEST.MF
analysis/org.eclipse.tracecompass.analysis.graph.core/plugin.xml
analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/analysis/graph/core/building/TmfGraphBuilderModule.java
analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/analysis/graph/core/criticalpath/CriticalPathModule.java
analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/analysis/graph/core/criticalpath/ICriticalPathProvider.java [new file with mode: 0644]
analysis/org.eclipse.tracecompass.analysis.graph.ui/plugin.xml
analysis/org.eclipse.tracecompass.analysis.graph.ui/src/org/eclipse/tracecompass/internal/analysis/graph/ui/criticalpath/view/CriticalPathBaseEntry.java
analysis/org.eclipse.tracecompass.analysis.graph.ui/src/org/eclipse/tracecompass/internal/analysis/graph/ui/criticalpath/view/CriticalPathModuleListener.java [new file with mode: 0644]
analysis/org.eclipse.tracecompass.analysis.graph.ui/src/org/eclipse/tracecompass/internal/analysis/graph/ui/criticalpath/view/CriticalPathView.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/TmfAbstractAnalysisParamProvider.java

index 8add462dcb7c9220da7e86bc374cabf6deccbbc4..60a2084b1413d2019ab1f6fec1fcc4c7fc784acc 100644 (file)
@@ -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
index 909bb21de49dcd273dfff7f73a186631ba886403..67cc3485945d915f47d53bb63cf450b9189af395 100644 (file)
@@ -17,9 +17,6 @@
          <parameter
                name="algorithm">
          </parameter>
-         <tracetype
-               class="org.eclipse.tracecompass.tmf.core.trace.TmfTrace">
-         </tracetype>
       </module>
    </extension>
 </plugin>
index e63a9364ccbdd1592a30d9217710e5539bc21669..56304fa6e5e5e1531caf17e7e77055328a796dbe 100644 (file)
 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();
+    }
+
 }
index b0cf581630ed1144b3349d30238eba7a9b1be2da..0ec7cce779da3dabd30fa788af965ab9d93ce760 100644 (file)
@@ -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 (file)
index 0000000..269d8c2
--- /dev/null
@@ -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();
+
+}
index 47224b33cc6d1b49f7fa4e117283e99561eb43e5..fba00bb4a1edfcb2a41542d194e32d59837b5a2c 100644 (file)
@@ -22,5 +22,8 @@
                class="org.eclipse.tracecompass.analysis.graph.core.criticalpath.CriticalPathModule">
          </analysisModuleClass>
       </output>
+      <listener
+            class="org.eclipse.tracecompass.internal.analysis.graph.ui.criticalpath.view.CriticalPathModuleListener">
+      </listener>
    </extension>
 </plugin>
index 8087289444af2bc18b4b58e205adf89350964f6c..bdb72e15482a4772805448e7570d4c20f5e830b3 100644 (file)
@@ -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 (file)
index 0000000..7efad59
--- /dev/null
@@ -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()));
+        }
+    }
+
+}
index b1b16d443531d0689e08eeeccdfaf86d44a39a18..aa46ba60f2b4033a717b6ea3083f5085f7ce73f1 100644 (file)
@@ -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<TimeGraphEntry> list = Collections.singletonList(tge);
         putEntryList(trace, list);
         refresh();
index caae475db6bee4095555754bd050687d7ab9c6d4..2255211cd911b61a758c32dbfd67c8abe387eb90 100644 (file)
@@ -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;
         }
     }
This page took 0.031194 seconds and 5 git commands to generate.