Search in sources :

Example 1 with ITmfEventRequest

use of org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest in project tracecompass by tracecompass.

the class TmfGraphBuilderModule method build.

private void build(ITmfGraphProvider provider) {
    /* Cancel any previous request */
    ITmfEventRequest request = fRequest;
    if ((request != null) && (!request.isCompleted())) {
        request.cancel();
    }
    try {
        request = new TmfGraphBuildRequest(provider);
        fRequest = request;
        provider.getTrace().sendRequest(request);
        request.waitForCompletion();
    } catch (InterruptedException e) {
        // $NON-NLS-1$
        Activator.getInstance().logError("Request interrupted", e);
        Thread.currentThread().interrupt();
    }
}
Also used : ITmfEventRequest(org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest)

Example 2 with ITmfEventRequest

use of org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest in project tracecompass by tracecompass.

the class TmfStateSystemAnalysisModule method traceRangeUpdated.

/**
 * Signal handler for the TmfTraceRangeUpdatedSignal signal
 *
 * @param signal
 *            The incoming signal
 */
@TmfSignalHandler
public void traceRangeUpdated(final TmfTraceRangeUpdatedSignal signal) {
    fTimeRange = signal.getRange();
    ITmfStateProvider stateProvider = fStateProvider;
    synchronized (fRequestSyncObj) {
        if (signal.getTrace() == getTrace() && stateProvider != null && stateProvider.getAssignedStateSystem() != null) {
            ITmfEventRequest request = fRequest;
            if ((request == null) || request.isCompleted()) {
                startRequest();
            }
        }
    }
}
Also used : ITmfEventRequest(org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest) TmfSignalHandler(org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)

Example 3 with ITmfEventRequest

use of org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest in project tracecompass by tracecompass.

the class TmfStateSystemAnalysisModule method build.

private void build(ITmfStateProvider provider) {
    if (fStateSystem == null) {
        throw new IllegalArgumentException();
    }
    /*
         * Note we have to do this before fStateProvider is assigned. After that, the
         * signal listener below will start sending real trace events through the state
         * provider.
         */
    loadInitialState(provider);
    /* Continue on initializing the event request to read trace events. */
    ITmfEventRequest request = fRequest;
    if ((request != null) && (!request.isCompleted())) {
        request.cancel();
    }
    fTimeRange = TmfTimeRange.ETERNITY;
    final ITmfTrace trace = provider.getTrace();
    if (!isCompleteTrace(trace)) {
        fTimeRange = trace.getTimeRange();
    }
    fStateProvider = provider;
    synchronized (fRequestSyncObj) {
        startRequest();
        request = fRequest;
    }
    /*
         * The state system object is now created, we can consider this module
         * "initialized" (components can retrieve it and start doing queries).
         */
    analysisReady(true);
    /*
         * Block the executeAnalysis() construction is complete (so that the progress
         * monitor displays that it is running).
         */
    try {
        if (request != null) {
            request.waitForCompletion();
            if (request.isFailed()) {
                Throwable failureCause = request.getFailureCause();
                if (failureCause != null) {
                    fail(failureCause);
                } else {
                    // $NON-NLS-1$
                    fail(new RuntimeException("Event request failed without a cause"));
                }
            }
        }
    } catch (InterruptedException e) {
        fail(e);
    }
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) ITmfEventRequest(org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest)

Example 4 with ITmfEventRequest

use of org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest in project tracecompass by tracecompass.

the class TmfUml2SDSyncLoader method loadTrace.

/**
 * Method for loading the current selected trace into the view. Sub-class
 * need to override this method to add the view specific implementation.
 */
protected void loadTrace() {
    ITmfEventRequest indexRequest = null;
    fLock.lock();
    try {
        // $NON-NLS-1$ //$NON-NLS-2$
        final Job job = new IndexingJob("Indexing " + getName() + "...");
        job.setUser(false);
        job.schedule();
        indexRequest = fIndexRequest;
        cancelOngoingRequests();
        TmfTimeRange window = TmfTimeRange.ETERNITY;
        fIndexRequest = new TmfEventRequest(ITmfEvent.class, window, 0, ITmfEventRequest.ALL_DATA, ITmfEventRequest.ExecutionType.BACKGROUND) {

            private ITmfTimestamp fFirstTime = null;

            private ITmfTimestamp fLastTime = null;

            private int fNbSeqEvents = 0;

            private final List<ITmfSyncSequenceDiagramEvent> fSdEvents = new ArrayList<>(MAX_NUM_OF_MSG);

            @Override
            public void handleData(ITmfEvent event) {
                super.handleData(event);
                ITmfSyncSequenceDiagramEvent sdEvent = getSequenceDiagramEvent(event);
                ITmfTimestamp firstTime = fFirstTime;
                ITmfTimestamp lastTime = fLastTime;
                if (sdEvent != null) {
                    ++fNbSeqEvents;
                    if (firstTime == null) {
                        firstTime = event.getTimestamp();
                        fFirstTime = firstTime;
                    }
                    lastTime = event.getTimestamp();
                    fLastTime = lastTime;
                    if ((fNbSeqEvents % MAX_NUM_OF_MSG) == 0) {
                        fLock.lock();
                        try {
                            fCheckPoints.add(new TmfTimeRange(firstTime, lastTime));
                            if (fView != null) {
                                fView.updateCoolBar();
                            }
                        } finally {
                            fLock.unlock();
                        }
                        fFirstTime = null;
                    }
                    if (fNbSeqEvents > MAX_NUM_OF_MSG) {
                        // page is full
                        return;
                    }
                    fSdEvents.add(sdEvent);
                    if (fNbSeqEvents == MAX_NUM_OF_MSG) {
                        fillCurrentPage(fSdEvents);
                    }
                }
            }

            @Override
            public void handleSuccess() {
                final ITmfTimestamp firstTime = fFirstTime;
                final ITmfTimestamp lastTime = fLastTime;
                if ((firstTime != null) && (lastTime != null)) {
                    fLock.lock();
                    try {
                        fCheckPoints.add(new TmfTimeRange(firstTime, lastTime));
                        if (fView != null) {
                            fView.updateCoolBar();
                        }
                    } finally {
                        fLock.unlock();
                    }
                }
                if (fNbSeqEvents <= MAX_NUM_OF_MSG) {
                    fillCurrentPage(fSdEvents);
                }
                super.handleSuccess();
            }

            @Override
            public void handleCompleted() {
                if (fEvents.isEmpty()) {
                    fFrame = new Frame();
                    // make sure that view is not null when setting frame
                    SDView sdView;
                    fLock.lock();
                    try {
                        sdView = fView;
                    } finally {
                        fLock.unlock();
                    }
                    if (sdView != null) {
                        sdView.setFrameSync(fFrame);
                    }
                }
                super.handleCompleted();
                job.cancel();
            }
        };
    } finally {
        fLock.unlock();
    }
    if (indexRequest != null && !indexRequest.isCompleted()) {
        indexRequest.cancel();
    }
    resetLoader();
    fTrace.sendRequest(fIndexRequest);
}
Also used : Frame(org.eclipse.tracecompass.tmf.ui.views.uml2sd.core.Frame) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) ITmfSyncSequenceDiagramEvent(org.eclipse.tracecompass.tmf.core.uml2sd.ITmfSyncSequenceDiagramEvent) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) ITmfEventRequest(org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest) ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) Job(org.eclipse.core.runtime.jobs.Job) TmfEventRequest(org.eclipse.tracecompass.tmf.core.request.TmfEventRequest) ITmfEventRequest(org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest) SDView(org.eclipse.tracecompass.tmf.ui.views.uml2sd.SDView)

Example 5 with ITmfEventRequest

use of org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest in project tracecompass by tracecompass.

the class AbstractSegmentStoreAnalysisEventBasedModule method buildAnalysisSegments.

@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, monitor);
    fOngoingRequest = req;
    trace.sendRequest(req);
    try {
        req.waitForCompletion();
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
    }
    /* Do not process the results if the request was cancelled */
    return !(req.isCancelled() || req.isFailed());
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) ITmfEventRequest(org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest)

Aggregations

ITmfEventRequest (org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest)18 ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)4 TmfEventRequest (org.eclipse.tracecompass.tmf.core.request.TmfEventRequest)4 TmfTimeRange (org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)4 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)3 TmfSignalHandler (org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)2 ITmfTimestamp (org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp)2 ArrayList (java.util.ArrayList)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 Job (org.eclipse.core.runtime.jobs.Job)1 Nullable (org.eclipse.jdt.annotation.Nullable)1 TmfCoalescedEventRequest (org.eclipse.tracecompass.internal.tmf.core.request.TmfCoalescedEventRequest)1 PcapEvent (org.eclipse.tracecompass.internal.tmf.pcap.core.event.PcapEvent)1 ITmfStateSystem (org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)1 TimeRangeException (org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException)1 ITmfStateInterval (org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval)1 TmfStateInterval (org.eclipse.tracecompass.statesystem.core.interval.TmfStateInterval)1 ITmfEventProvider (org.eclipse.tracecompass.tmf.core.component.ITmfEventProvider)1