tmf: Support child entries with different state systems in TimeGraphView
authorPatrick Tasse <patrick.tasse@gmail.com>
Tue, 25 Apr 2017 19:31:02 +0000 (15:31 -0400)
committerPatrick Tasse <patrick.tasse@gmail.com>
Tue, 2 May 2017 17:35:24 +0000 (13:35 -0400)
Decouple the roots of the AbstractTimeGraphView with the entries
associated with a state system in AbstractStateSystemTimeGraphView.

This allows, for example, a 'trace' entry to be root of the graph, that
has independent branches of children whose event lists, links and
markers are populated using their own, separate, state systems.

Change-Id: Ied2a2f91d6661e4cff76f07c06ba9e2eb5c4e25c
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-on: https://git.eclipse.org/r/95730
Reviewed-by: Jean-Christian Kouame <jean-christian.kouame@ericsson.com>
Tested-by: Jean-Christian Kouame <jean-christian.kouame@ericsson.com>
Reviewed-by: Hudson CI
analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/controlflow/ControlFlowView.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/AbstractStateSystemTimeGraphView.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/AbstractTimeGraphView.java

index 2712167716bed9edb2b35571ee4630ac6fbcebec..55c70df97e0cf6b28ca585c149eb4afd38d1d54e 100644 (file)
@@ -361,12 +361,15 @@ public class ControlFlowView extends AbstractStateSystemTimeGraphView {
                     fFlatTraces.remove(parentTrace);
                     for (ITmfTrace trace : TmfTraceManager.getTraceSet(parentTrace)) {
                         final ITmfStateSystem ss = TmfStateSystemAnalysisModule.getStateSystem(trace, KernelAnalysisModule.ID);
-                        for (TimeGraphEntry traceEntry : getEntryList(ss)) {
-                            List<ControlFlowEntry> currentRootList = traceEntry.getChildren().stream()
-                                    .filter(e -> e instanceof ControlFlowEntry)
-                                    .map(e -> (ControlFlowEntry) e)
-                                    .collect(Collectors.toList());
-                            addEntriesToHierarchicalTree(currentRootList, traceEntry);
+                        List<@NonNull TimeGraphEntry> entryList = getEntryList(ss);
+                        if (entryList != null) {
+                            for (TimeGraphEntry traceEntry : entryList) {
+                                List<ControlFlowEntry> currentRootList = traceEntry.getChildren().stream()
+                                        .filter(e -> e instanceof ControlFlowEntry)
+                                        .map(e -> (ControlFlowEntry) e)
+                                        .collect(Collectors.toList());
+                                addEntriesToHierarchicalTree(currentRootList, traceEntry);
+                            }
                         }
                     }
                 }
@@ -464,6 +467,9 @@ public class ControlFlowView extends AbstractStateSystemTimeGraphView {
             List<ILinkEvent> arrows = getTimeGraphViewer().getTimeGraphControl().getArrows();
             final ITmfStateSystem ss = TmfStateSystemAnalysisModule.getStateSystem(trace, KernelAnalysisModule.ID);
             List<TimeGraphEntry> currentList = getEntryList(ss);
+            if (currentList == null) {
+                return;
+            }
 
             Map<Integer, Long> orderedTidMap = getUpdatedSchedulingColumn().apply(arrows);
 
index 7ad0c23e18684e8d4fc9757621ca2e55e0d001ff..8ea3230725530840c0e3c45b6e9be76a90fda21d 100644 (file)
@@ -16,8 +16,10 @@ import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
 
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -241,31 +243,36 @@ public abstract class AbstractStateSystemTimeGraphView extends AbstractTimeGraph
     // ------------------------------------------------------------------------
 
     /**
-     * Gets the entry list for a state system
+     * Gets the entry list for a state system. These entries, and their
+     * recursive children, will have their event lists computed using the
+     * provided state system.
      *
      * @param ss
      *            the state system
      *
-     * @return the entry list map
+     * @return the entry list
      */
-    protected List<@NonNull TimeGraphEntry> getEntryList(ITmfStateSystem ss) {
+    protected @Nullable List<@NonNull TimeGraphEntry> getEntryList(ITmfStateSystem ss) {
         synchronized (fSSEntryListMap) {
             return fSSEntryListMap.get(ss);
         }
     }
 
     /**
-     * Adds a trace entry list to the entry list map
+     * Sets the entry list for a state system. These entries, and their
+     * recursive children, will have their event lists computed using the
+     * provided state system. The root of each entry (or the entry itself if it
+     * is a root) will be added to the parent trace's entry list.
      *
      * @param trace
-     *            the trace
+     *            the parent trace
      * @param ss
      *            the state system
      * @param list
      *            the list of time graph entries
      */
     protected void putEntryList(ITmfTrace trace, ITmfStateSystem ss, List<@NonNull TimeGraphEntry> list) {
-        super.putEntryList(trace, list);
+        super.addToEntryList(trace, getRootEntries(list));
         synchronized (fSSEntryListMap) {
             fSSEntryListMap.put(ss, new CopyOnWriteArrayList<>(list));
             fTraceSSMap.put(trace, ss);
@@ -273,17 +280,21 @@ public abstract class AbstractStateSystemTimeGraphView extends AbstractTimeGraph
     }
 
     /**
-     * Adds a list of entries to a trace's entry list
+     * Adds a list of entries to the entry list for a state system. These
+     * entries, and their recursive children, will have their event lists
+     * computed using the provided state system. The root of each entry (or the
+     * entry itself if it is a root) will be added to the parent trace's entry
+     * list.
      *
      * @param trace
-     *            the trace
+     *            the parent trace
      * @param ss
      *            the state system
      * @param list
      *            the list of time graph entries to add
      */
     protected void addToEntryList(ITmfTrace trace, ITmfStateSystem ss, List<@NonNull TimeGraphEntry> list) {
-        super.addToEntryList(trace, list);
+        super.addToEntryList(trace, getRootEntries(list));
         synchronized (fSSEntryListMap) {
             List<@NonNull TimeGraphEntry> entryList = fSSEntryListMap.get(ss);
             if (entryList == null) {
@@ -296,10 +307,13 @@ public abstract class AbstractStateSystemTimeGraphView extends AbstractTimeGraph
     }
 
     /**
-     * Removes a list of entries from a trace's entry list
+     * Removes a list of entries from the entry list for a state system. These
+     * entries, and their recursive children, will no longer have their event
+     * lists computed using the provided state system. Each entry that is itself
+     * a root will be removed from the parent trace's entry list.
      *
      * @param trace
-     *            the trace
+     *            the parent trace
      * @param ss
      *            the state system
      * @param list
@@ -318,6 +332,18 @@ public abstract class AbstractStateSystemTimeGraphView extends AbstractTimeGraph
         }
     }
 
+    private static List<@NonNull TimeGraphEntry> getRootEntries(List<@NonNull TimeGraphEntry> list) {
+        Set<@NonNull TimeGraphEntry> roots = new LinkedHashSet<>();
+        for (@NonNull TimeGraphEntry entry : list) {
+            TimeGraphEntry root = entry;
+            while (root.getParent() != null) {
+                root = root.getParent();
+            }
+            roots.add(root);
+        }
+        return new ArrayList<>(roots);
+    }
+
     @Override
     protected @Nullable ZoomThread createZoomThread(long startTime, long endTime, long resolution, boolean restart) {
         List<ITmfStateSystem> ssList = null;
@@ -442,49 +468,6 @@ public abstract class AbstractStateSystemTimeGraphView extends AbstractTimeGraph
         return new ArrayList<>();
     }
 
-    /**
-     * @deprecated The subclass should call
-     *             {@link #getEntryList(ITmfStateSystem)} instead.
-     */
-    @Deprecated
-    @Override
-    protected final List<TimeGraphEntry> getEntryList(ITmfTrace trace) {
-        throw new UnsupportedOperationException();
-    }
-
-    /**
-     * @deprecated The subclass should call
-     *             {@link #addToEntryList(ITmfTrace, ITmfStateSystem, List)}
-     *             instead.
-     */
-    @Deprecated
-    @Override
-    protected final void addToEntryList(ITmfTrace trace, List<TimeGraphEntry> list) {
-        throw new UnsupportedOperationException();
-    }
-
-    /**
-     * @deprecated The subclass should call
-     *             {@link #putEntryList(ITmfTrace, ITmfStateSystem, List)}
-     *             instead.
-     */
-    @Deprecated
-    @Override
-    protected final void putEntryList(ITmfTrace trace, List<TimeGraphEntry> list) {
-        throw new UnsupportedOperationException();
-    }
-
-    /**
-     * @deprecated The subclass should call
-     *             {@link #removeFromEntryList(ITmfTrace, ITmfStateSystem, List)}
-     *             instead.
-     */
-    @Deprecated
-    @Override
-    protected final void removeFromEntryList(ITmfTrace trace, List<TimeGraphEntry> list) {
-        throw new UnsupportedOperationException();
-    }
-
     /**
      * @deprecated The subclass should implement
      *             {@link #getEventList(TimeGraphEntry, ITmfStateSystem, List, List, IProgressMonitor)}
@@ -492,7 +475,7 @@ public abstract class AbstractStateSystemTimeGraphView extends AbstractTimeGraph
      */
     @Deprecated
     @Override
-    protected final List<ITimeEvent> getEventList(TimeGraphEntry entry, long startTime, long endTime, long resolution, IProgressMonitor monitor) {
+    protected final @Nullable List<@NonNull ITimeEvent> getEventList(TimeGraphEntry entry, long startTime, long endTime, long resolution, IProgressMonitor monitor) {
         throw new UnsupportedOperationException();
     }
 
@@ -503,7 +486,7 @@ public abstract class AbstractStateSystemTimeGraphView extends AbstractTimeGraph
      */
     @Deprecated
     @Override
-    protected final List<ILinkEvent> getLinkList(long startTime, long endTime, long resolution, IProgressMonitor monitor) {
+    protected final @Nullable List<@NonNull ILinkEvent> getLinkList(long startTime, long endTime, long resolution, IProgressMonitor monitor) {
         throw new UnsupportedOperationException();
     }
 
@@ -514,7 +497,7 @@ public abstract class AbstractStateSystemTimeGraphView extends AbstractTimeGraph
      */
     @Deprecated
     @Override
-    protected final List<IMarkerEvent> getViewMarkerList(long startTime, long endTime, long resolution, IProgressMonitor monitor) {
+    protected final @NonNull List<IMarkerEvent> getViewMarkerList(long startTime, long endTime, long resolution, IProgressMonitor monitor) {
         throw new UnsupportedOperationException();
     }
 
index f8c8dd8e3c9b732eae0fb2fea4f559035dcbf5a3..3bbf4438866401b2b1cccdecd1e47fd113428a69 100644 (file)
@@ -841,7 +841,7 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
      *
      * @return the entry list map
      */
-    protected List<TimeGraphEntry> getEntryList(ITmfTrace trace) {
+    protected @Nullable List<TimeGraphEntry> getEntryList(ITmfTrace trace) {
         synchronized (fEntryListMap) {
             return fEntryListMap.get(trace);
         }
@@ -875,7 +875,11 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
             if (entryList == null) {
                 fEntryListMap.put(trace, new CopyOnWriteArrayList<>(list));
             } else {
-                entryList.addAll(list);
+                for (TimeGraphEntry entry : list) {
+                    if (!entryList.contains(entry)) {
+                        entryList.add(entry);
+                    }
+                }
             }
         }
     }
This page took 0.030179 seconds and 5 git commands to generate.