lttng: provide a system call column for in Latency Table
authorBernd Hufmann <Bernd.Hufmann@ericsson.com>
Tue, 6 Oct 2015 12:59:55 +0000 (08:59 -0400)
committerBernd Hufmann <bernd.hufmann@ericsson.com>
Fri, 23 Oct 2015 12:55:35 +0000 (08:55 -0400)
It uses the newly created ISegmentAspect interface

Change-Id: I6bcdf746b396a4a79f10a22233d5cd994d778ad6
Signed-off-by: Bernd Hufmann <Bernd.Hufmann@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/57515
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/latency/LatencyAnalysis.java
analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/latency/Messages.java [new file with mode: 0644]
analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/latency/messages.properties [new file with mode: 0644]
analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/LatencyTableViewer.java
analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/AbstractSegmentStoreAnalysisModule.java

index 50865cd13a3b78e3b0bfcc5f02e760c8fdab72d8..a58f8910f407903c26e982744e5343b67d6f4e35 100644 (file)
@@ -13,6 +13,7 @@ import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
 
 import java.io.IOException;
 import java.io.ObjectInputStream;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -25,9 +26,11 @@ import org.eclipse.tracecompass.common.core.NonNullUtils;
 import org.eclipse.tracecompass.segmentstore.core.ISegment;
 import org.eclipse.tracecompass.segmentstore.core.ISegmentStore;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
+import org.eclipse.tracecompass.tmf.core.segment.ISegmentAspect;
 
 import com.google.common.base.Function;
 import com.google.common.collect.FluentIterable;
+import com.google.common.collect.ImmutableList;
 
 /**
  * @author Alexandre Montplaisir
@@ -42,11 +45,20 @@ public class LatencyAnalysis extends AbstractSegmentStoreAnalysisModule {
 
     private static final String DATA_FILENAME = "latency-analysis.dat"; //$NON-NLS-1$
 
+    private static final Collection<ISegmentAspect> BASE_ASPECTS =
+            checkNotNull(ImmutableList.of(SyscallNameAspect.INSTANCE));
+
+
     @Override
     public String getId() {
         return ID;
     }
 
+    @Override
+    public Iterable<ISegmentAspect> getSegmentAspects() {
+        return BASE_ASPECTS;
+    }
+
     @Override
     public String getDataFileName() {
         return DATA_FILENAME;
@@ -136,4 +148,26 @@ public class LatencyAnalysis extends AbstractSegmentStoreAnalysisModule {
         }
     }
 
+    private static class SyscallNameAspect implements ISegmentAspect {
+        public static final ISegmentAspect INSTANCE = new SyscallNameAspect();
+
+        private SyscallNameAspect() { }
+
+        @Override
+        public String getHelpText() {
+            return checkNotNull(Messages.SegmentAspectHelpText_SystemCall);
+        }
+        @Override
+        public String getName() {
+            return checkNotNull(Messages.SegmentAspectName_SystemCall);
+        }
+        @Override
+        public @Nullable String resolve(ISegment segment) {
+            if (segment instanceof SystemCall) {
+                return ((SystemCall) segment).getName();
+            }
+            return EMPTY_STRING;
+        }
+    }
+
 }
diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/latency/Messages.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/latency/Messages.java
new file mode 100644 (file)
index 0000000..dabf9ea
--- /dev/null
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Ericsson
+ *
+ * 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.os.linux.core.latency;
+
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Messages for Syscall latency analysis.
+ * @since 2.0
+ */
+public class Messages extends NLS {
+
+    private static final String BUNDLE_NAME = "org.eclipse.tracecompass.analysis.os.linux.core.latency.messages"; //$NON-NLS-1$
+
+    /** System Call latency analysis aspect name */
+    public static @Nullable String SegmentAspectName_SystemCall;
+
+    /** System Call latency analysis aspect help text */
+    public static @Nullable String SegmentAspectHelpText_SystemCall;
+
+    static {
+        NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+    }
+
+    private Messages() {
+    }
+
+    /**
+     * Helper method to expose externalized strings as non-null objects.
+     */
+    static String getMessage(@Nullable String msg) {
+        if (msg == null) {
+            return ""; //$NON-NLS-1$
+        }
+        return msg;
+    }
+}
diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/latency/messages.properties b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/latency/messages.properties
new file mode 100644 (file)
index 0000000..f1692c1
--- /dev/null
@@ -0,0 +1,12 @@
+###############################################################################
+# Copyright (c) 2015 Ericsson
+#
+# 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
+###############################################################################
+
+SegmentAspectName_SystemCall=System Call
+
+SegmentAspectHelpText_SystemCall=The name of the system call.
index 58c05e3dce124220470a7631cab9290e801e5693..1904f8040a7419ee8042eac16677a211ab68d67e 100644 (file)
@@ -30,6 +30,7 @@ import org.eclipse.tracecompass.common.core.NonNullUtils;
 import org.eclipse.tracecompass.segmentstore.core.ISegment;
 import org.eclipse.tracecompass.segmentstore.core.ISegmentStore;
 import org.eclipse.tracecompass.segmentstore.core.SegmentComparators;
+import org.eclipse.tracecompass.tmf.core.segment.ISegmentAspect;
 import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal;
 import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler;
 import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
@@ -68,17 +69,17 @@ public class LatencyTableViewer extends TmfSimpleTableViewer {
                 /* Doubles as a null check */
                 return ""; //$NON-NLS-1$
             }
-            return getTextFoITimeRange((ISegment) input);
+            return getTextForSegment((ISegment) input);
         }
 
-        public abstract String getTextFoITimeRange(ISegment input);
+        public abstract String getTextForSegment(ISegment input);
     }
 
     /**
      * Listener to update the model with the latency analysis results once the
      * latency analysis is fully completed
      */
-    private final class LatencyListener implements IAnalysisProgressListener {
+    private final class AnalysisProgressListener implements IAnalysisProgressListener {
         @Override
         public void onComplete(AbstractSegmentStoreAnalysisModule activeAnalysis, ISegmentStore<ISegment> data) {
             // Check if the active trace was changed while the analysis was
@@ -111,7 +112,12 @@ public class LatencyTableViewer extends TmfSimpleTableViewer {
     /**
      * Latency analysis completion listener
      */
-    private LatencyListener fListener;
+    private AnalysisProgressListener fListener;
+
+    /**
+     * Flag to create columns once
+     */
+    boolean fColumnsCreated = false;
 
     // ------------------------------------------------------------------------
     // Constructor
@@ -133,7 +139,7 @@ public class LatencyTableViewer extends TmfSimpleTableViewer {
         }
         createColumns();
         getTableViewer().getTable().addSelectionListener(new LatencyTableSelectionListener());
-        fListener = new LatencyListener();
+        fListener = new AnalysisProgressListener();
     }
 
     // ------------------------------------------------------------------------
@@ -141,31 +147,52 @@ public class LatencyTableViewer extends TmfSimpleTableViewer {
     // ------------------------------------------------------------------------
 
     /**
-     * Create columns for start time, end time and duration
+     * Create default columns for start time, end time and duration
      */
     private void createColumns() {
         createColumn(Messages.LatencyTableViewer_startTime, new LatencyTableColumnLabelProvider() {
             @Override
-            public String getTextFoITimeRange(ISegment input) {
+            public String getTextForSegment(ISegment input) {
                 return NonNullUtils.nullToEmptyString(TmfTimestampFormat.getDefaulTimeFormat().format(input.getStart()));
             }
         }, SegmentComparators.INTERVAL_START_COMPARATOR);
 
         createColumn(Messages.LatencyTableViewer_endTime, new LatencyTableColumnLabelProvider() {
             @Override
-            public String getTextFoITimeRange(ISegment input) {
+            public String getTextForSegment(ISegment input) {
                 return NonNullUtils.nullToEmptyString(TmfTimestampFormat.getDefaulTimeFormat().format(input.getEnd()));
             }
         }, SegmentComparators.INTERVAL_END_COMPARATOR);
 
         createColumn(Messages.LatencyTableViewer_duration, new LatencyTableColumnLabelProvider() {
             @Override
-            public String getTextFoITimeRange(ISegment input) {
+            public String getTextForSegment(ISegment input) {
                 return NonNullUtils.nullToEmptyString(Long.toString(input.getLength()));
             }
         }, SegmentComparators.INTERVAL_LENGTH_COMPARATOR);
     }
 
+    /**
+     * Create columns specific to the analysis
+     */
+    private void createAnalysisColumns() {
+        if (!fColumnsCreated) {
+            AbstractSegmentStoreAnalysisModule analysis = getAnalysisModule();
+            if (analysis != null) {
+                for (final ISegmentAspect aspect : analysis.getSegmentAspects()) {
+                    createColumn(aspect.getName(), new LatencyTableColumnLabelProvider() {
+                        @Override
+                        public String getTextForSegment(ISegment input) {
+                            return NonNullUtils.nullToEmptyString(aspect.resolve(input));
+                        }
+                    },
+                    null);
+                }
+            }
+            fColumnsCreated = true;
+        }
+    }
+
     /**
      * Update the data in the table viewer
      *
@@ -209,6 +236,9 @@ public class LatencyTableViewer extends TmfSimpleTableViewer {
             updateModel(null);
             return;
         }
+
+        createAnalysisColumns();
+
         ISegmentStore<ISegment> results = analysis.getResults();
         // If results are not null, then analysis is completed and model can be
         // updated
index 8357c874fa152a259c11c910d43c464d36198600..8642e0f4dbea0659919961658060a353c5cd4cb2 100644 (file)
@@ -16,6 +16,7 @@ import java.io.ObjectOutputStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.util.Collection;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -29,9 +30,12 @@ import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
 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.segment.ISegmentAspect;
 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
 import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
 
+import com.google.common.collect.ImmutableList;
+
 /**
  * Abstract analysis module to generate a segment store. It is a base class that
  * can be used as a shortcut by analysis who just need to build a single segment
@@ -67,6 +71,17 @@ public abstract class AbstractSegmentStoreAnalysisModule extends TmfAbstractAnal
         return fListeners;
     }
 
+    /**
+     * Return the pre-defined set of segment aspects exposed by this analysis.
+     *
+     * It should not be null, but could be empty.
+     * @return The segment aspects for this analysis
+     */
+    public Iterable<ISegmentAspect> getSegmentAspects() {
+        Collection<ISegmentAspect> coll = ImmutableList.of();
+        return checkNotNull(coll);
+    }
+
     /**
      * Returns the file name for storing segment store
      * @return segment store fine name
This page took 0.030117 seconds and 5 git commands to generate.