analysis : Introduce buildAnalysisSegments() in Segment Store analysis
authorJean-Christian Kouame <jean-christian.kouame@ericsson.com>
Fri, 15 Jan 2016 16:29:05 +0000 (11:29 -0500)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Wed, 16 Mar 2016 14:11:26 +0000 (10:11 -0400)
This abstract method helps the analysis decide how the segment store
will be built.

For instance, the segment store could be built using a request or using
segments generated by a prerequisite analysis.

Change-Id: I68c6b5d35ff71d8c06c5b4881bcbce25404b5581
Signed-off-by: Jean-Christian Kouame <jean-christian.kouame@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/64592
Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Tested-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-by: Hudson CI
analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/latency/SystemCallLatencyAnalysis.java
analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/AbstractSegmentStoreAnalysisEventBasedModule.java [new file with mode: 0644]
analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/AbstractSegmentStoreAnalysisModule.java

index 9db321fa6abe7185b4e6cbb8839877bc0b630416..e4790a39df85dfb9d881c58dfd6ee6f4300c799f 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2015 EfficiOS Inc., Ericsson
+ * Copyright (c) 2015, 2016 EfficiOS Inc., Ericsson
  *
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
@@ -25,7 +25,7 @@ import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelTidAspect;
 import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout;
 import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelTrace;
-import org.eclipse.tracecompass.analysis.timing.core.segmentstore.AbstractSegmentStoreAnalysisModule;
+import org.eclipse.tracecompass.analysis.timing.core.segmentstore.AbstractSegmentStoreAnalysisEventBasedModule;
 import org.eclipse.tracecompass.segmentstore.core.ISegment;
 import org.eclipse.tracecompass.segmentstore.core.ISegmentStore;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
@@ -37,7 +37,7 @@ import com.google.common.collect.ImmutableList;
  * @author Alexandre Montplaisir
  * @since 2.0
  */
-public class SystemCallLatencyAnalysis extends AbstractSegmentStoreAnalysisModule {
+public class SystemCallLatencyAnalysis extends AbstractSegmentStoreAnalysisEventBasedModule {
 
     /**
      * The ID of this analysis
diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/AbstractSegmentStoreAnalysisEventBasedModule.java b/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/AbstractSegmentStoreAnalysisEventBasedModule.java
new file mode 100644 (file)
index 0000000..b620c75
--- /dev/null
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) 2016 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.timing.core.segmentstore;
+
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.annotation.Nullable;
+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.exceptions.TmfAnalysisException;
+import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest;
+import org.eclipse.tracecompass.tmf.core.request.TmfEventRequest;
+import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
+
+/**
+ * Abstract class to create an event base segment store analysis. It uses an
+ * event request to define how events will generate segments.
+ *
+ * @author Jean-Christian Kouame
+ *
+ */
+public abstract class AbstractSegmentStoreAnalysisEventBasedModule extends AbstractSegmentStoreAnalysisModule {
+
+    private @Nullable ITmfEventRequest fOngoingRequest = null;
+
+    /**
+     * Returns the analysis request for creating the segment store
+     *
+     * @param segmentStore
+     *            a segment store to fill
+     * @return the segment store analysis request implementation
+     */
+    protected abstract AbstractSegmentStoreAnalysisRequest createAnalysisRequest(ISegmentStore<ISegment> segmentStore);
+
+    @Override
+    protected void canceling() {
+        ITmfEventRequest req = fOngoingRequest;
+        if ((req != null) && (!req.isCompleted())) {
+            req.cancel();
+        }
+    }
+
+    @Override
+    protected boolean buildAnalysisSegments(ISegmentStore<ISegment> segmentStore, IProgressMonitor monitor) throws TmfAnalysisException {
+        ITmfTrace trace = checkNotNull(getTrace());
+        /* Cancel an ongoing request */
+        ITmfEventRequest req = fOngoingRequest;
+        if ((req != null) && (!req.isCompleted())) {
+            req.cancel();
+        }
+
+        /* Create a new request */
+        req = createAnalysisRequest(segmentStore);
+        fOngoingRequest = req;
+        trace.sendRequest(req);
+
+        try {
+            req.waitForCompletion();
+        } catch (InterruptedException e) {
+        }
+
+        /* Do not process the results if the request was cancelled */
+        if (req.isCancelled() || req.isFailed()) {
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Abstract event request to fill a a segment store
+     */
+    protected static abstract class AbstractSegmentStoreAnalysisRequest extends TmfEventRequest {
+
+        private final ISegmentStore<ISegment> fSegmentStore;
+
+        /**
+         * Constructor
+         *
+         * @param segmentStore
+         *            a segment store to fill
+         */
+        public AbstractSegmentStoreAnalysisRequest(ISegmentStore<ISegment> segmentStore) {
+            super(ITmfEvent.class, 0, ITmfEventRequest.ALL_DATA, ExecutionType.BACKGROUND);
+            /*
+             * We do NOT make a copy here! We want to modify the list that was
+             * passed in parameter.
+             */
+            fSegmentStore = segmentStore;
+        }
+
+        /**
+         * Returns the segment store
+         *
+         * @return the segment store
+         */
+        public ISegmentStore<ISegment> getSegmentStore() {
+            return fSegmentStore;
+        }
+    }
+}
index f5db4dde2fc00d245305c0b88c733a834de0cc28..ece3c75d89ae3cc314617a344ef4fd5a752e80d5 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2015 Ericsson
+ * Copyright (c) 2015, 2016 Ericsson
  *
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
@@ -27,10 +27,7 @@ import org.eclipse.tracecompass.segmentstore.core.ISegment;
 import org.eclipse.tracecompass.segmentstore.core.ISegmentStore;
 import org.eclipse.tracecompass.segmentstore.core.treemap.TreeMapStore;
 import org.eclipse.tracecompass.tmf.core.analysis.TmfAbstractAnalysisModule;
-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;
@@ -50,8 +47,6 @@ public abstract class AbstractSegmentStoreAnalysisModule extends TmfAbstractAnal
 
     private @Nullable ISegmentStore<ISegment> fSegmentStore;
 
-    private @Nullable ITmfEventRequest fOngoingRequest = null;
-
     @Override
     public void addListener(IAnalysisProgressListener listener) {
         fListeners.add(listener);
@@ -91,15 +86,6 @@ public abstract class AbstractSegmentStoreAnalysisModule extends TmfAbstractAnal
         return null;
     }
 
-    /**
-     * Returns the analysis request for creating the segment store
-     *
-     * @param segmentStore
-     *            a segment store to fill
-     * @return the segment store analysis request implementation
-     */
-    protected abstract AbstractSegmentStoreAnalysisRequest createAnalysisRequest(ISegmentStore<ISegment> segmentStore);
-
     /**
      * Read an object from the ObjectInputStream.
      *
@@ -113,19 +99,27 @@ public abstract class AbstractSegmentStoreAnalysisModule extends TmfAbstractAnal
      */
     protected abstract Object[] readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException;
 
+    /**
+     * Fills the segment store. This is the main method that children classes
+     * need to implement to build the segment store. For example, if the
+     * segments are found by parsing the events of a trace, the event request
+     * would be done in this method.
+     *
+     * @param segmentStore
+     *            The segment store to fill
+     * @param monitor
+     *            Progress monitor
+     * @return Whether the segments was resolved successfully or not
+     * @throws TmfAnalysisException
+     *             Method may throw an analysis exception
+     */
+    protected abstract boolean buildAnalysisSegments(ISegmentStore<ISegment> segmentStore, IProgressMonitor monitor) throws TmfAnalysisException;
+
     @Override
     public @Nullable ISegmentStore<ISegment> getSegmentStore() {
         return fSegmentStore;
     }
 
-    @Override
-    protected void canceling() {
-        ITmfEventRequest req = fOngoingRequest;
-        if ((req != null) && (!req.isCompleted())) {
-            req.cancel();
-        }
-    }
-
     @Override
     public void dispose() {
         super.dispose();
@@ -173,30 +167,12 @@ public abstract class AbstractSegmentStoreAnalysisModule extends TmfAbstractAnal
                 }
             }
         }
-        ISegmentStore<ISegment> segmentStore = new TreeMapStore<>();
-
-        /* Cancel an ongoing request */
-        ITmfEventRequest req = fOngoingRequest;
-        if ((req != null) && (!req.isCompleted())) {
-            req.cancel();
-        }
-
-        /* Create a new request */
-        req = createAnalysisRequest(segmentStore);
-        fOngoingRequest = req;
-        trace.sendRequest(req);
 
-        try {
-            req.waitForCompletion();
-        } catch (InterruptedException e) {
-        }
-
-        /* Do not process the results if the request was cancelled */
-        if (req.isCancelled() || req.isFailed()) {
+        ISegmentStore<ISegment> segmentStore = new TreeMapStore<>();
+        boolean completed = buildAnalysisSegments(segmentStore, monitor);
+        if (!completed) {
             return false;
         }
-
-        /* The request will fill 'syscalls' */
         fSegmentStore = segmentStore;
 
         if (dataFileName != null) {
@@ -220,36 +196,4 @@ public abstract class AbstractSegmentStoreAnalysisModule extends TmfAbstractAnal
 
         return true;
     }
-
-    /**
-     * Abstract event request to fill a a segment store
-     */
-    protected static abstract class AbstractSegmentStoreAnalysisRequest extends TmfEventRequest {
-
-        private final ISegmentStore<ISegment> fFullLatencyStore;
-
-        /**
-         * Constructor
-         *
-         * @param latencyStore
-         *            a latency segment store to fill
-         */
-        public AbstractSegmentStoreAnalysisRequest(ISegmentStore<ISegment> latencyStore) {
-            super(ITmfEvent.class, 0, ITmfEventRequest.ALL_DATA, ExecutionType.BACKGROUND);
-            /*
-             * We do NOT make a copy here! We want to modify the list that was
-             * passed in parameter.
-             */
-            fFullLatencyStore = latencyStore;
-        }
-
-        /**
-         * Returns the segment store
-         *
-         * @return the segment store
-         */
-        public ISegmentStore<ISegment> getSegmentStore() {
-            return fFullLatencyStore;
-        }
-    }
 }
\ No newline at end of file
This page took 0.029254 seconds and 5 git commands to generate.