X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=analysis%2Forg.eclipse.tracecompass.analysis.timing.core%2Fsrc%2Forg%2Feclipse%2Ftracecompass%2Fanalysis%2Ftiming%2Fcore%2Fsegmentstore%2FAbstractSegmentStoreAnalysisModule.java;h=ece3c75d89ae3cc314617a344ef4fd5a752e80d5;hb=65a4afc0db5bc361abd410fa114f97cd98adee4a;hp=f5db4dde2fc00d245305c0b88c733a834de0cc28;hpb=c91f009609349f5dbe16bcc971a736159f12b07b;p=deliverable%2Ftracecompass.git diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/AbstractSegmentStoreAnalysisModule.java b/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/AbstractSegmentStoreAnalysisModule.java index f5db4dde2f..ece3c75d89 100644 --- a/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/AbstractSegmentStoreAnalysisModule.java +++ b/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/AbstractSegmentStoreAnalysisModule.java @@ -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 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 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 segmentStore, IProgressMonitor monitor) throws TmfAnalysisException; + @Override public @Nullable ISegmentStore 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 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 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 fFullLatencyStore; - - /** - * Constructor - * - * @param latencyStore - * a latency segment store to fill - */ - public AbstractSegmentStoreAnalysisRequest(ISegmentStore 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 getSegmentStore() { - return fFullLatencyStore; - } - } } \ No newline at end of file