Search in sources :

Example 11 with ITmfEventRequest

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

the class PartialHistoryBackend method doQuery.

@Override
public void doQuery(List<@Nullable ITmfStateInterval> currentStateInfo, long t) throws TimeRangeException, StateSystemDisposedException {
    /* Wait for required steps to be done */
    waitForCheckpoints();
    fPartialSS.getUpstreamSS().waitUntilBuilt();
    if (!checkValidTime(t)) {
        // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        throw new TimeRangeException(fSSID + " Time:" + t + ", Start:" + getStartTime() + ", End:" + getEndTime());
    }
    /* Reload the previous checkpoint */
    long checkpointTime = fCheckpoints.floorKey(t);
    fInnerHistory.doQuery(currentStateInfo, checkpointTime);
    /*
         * Set the initial contents of the partial state system (which is the
         * contents of the query at the checkpoint).
         */
    List<@NonNull ITmfStateInterval> filledStateInfo = checkNotNullContents(currentStateInfo.stream()).collect(Collectors.toList());
    fPartialSS.takeQueryLock();
    fPartialSS.replaceOngoingState(filledStateInfo);
    /* Send an event request to update the state system to the target time. */
    TmfTimeRange range = new TmfTimeRange(/*
                 * The state at the checkpoint already includes any state change
                 * caused by the event(s) happening exactly at 'checkpointTime',
                 * if any. We must not include those events in the query.
                 */
    TmfTimestamp.fromNanos(checkpointTime + 1), TmfTimestamp.fromNanos(t));
    ITmfEventRequest request = new PartialStateSystemRequest(fPartialInput, range);
    fPartialInput.getTrace().sendRequest(request);
    try {
        request.waitForCompletion();
    } catch (InterruptedException e) {
    // Do nothing
    }
    /*
         * Now the partial state system should have the ongoing time we are
         * looking for. However, the method expects a List of *state intervals*,
         * not state values, so we'll create intervals with a dummy end time.
         */
    for (int i = 0; i < currentStateInfo.size(); i++) {
        long start = 0;
        start = ((ITmfStateSystem) fPartialSS).getOngoingStartTime(i);
        @Nullable Object val = ((ITmfStateSystem) fPartialSS).queryOngoing(i);
        ITmfStateInterval interval = new TmfStateInterval(start, t, i, val);
        currentStateInfo.set(i, interval);
    }
    fPartialSS.releaseQueryLock();
}
Also used : ITmfStateInterval(org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval) TmfStateInterval(org.eclipse.tracecompass.statesystem.core.interval.TmfStateInterval) TimeRangeException(org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException) ITmfStateInterval(org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) ITmfEventRequest(org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest) Nullable(org.eclipse.jdt.annotation.Nullable) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)

Example 12 with ITmfEventRequest

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

the class TmfCoalescedEventRequest method addRequest.

// ------------------------------------------------------------------------
// Management
// ------------------------------------------------------------------------
/**
 * Add a request to this one.
 *
 * @param request
 *            The request to add
 */
public void addRequest(ITmfEventRequest request) {
    // If it is a coalesced request only add the sub-requests
    if (request instanceof TmfCoalescedEventRequest) {
        TmfCoalescedEventRequest otherRequest = (TmfCoalescedEventRequest) request;
        for (ITmfEventRequest subRequest : otherRequest.fRequests) {
            fRequests.add(subRequest);
            merge(subRequest);
        }
    } else {
        fRequests.add(request);
        merge(request);
    }
}
Also used : ITmfEventRequest(org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest)

Example 13 with ITmfEventRequest

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

the class TmfCoalescedEventRequest method handleData.

// ------------------------------------------------------------------------
// ITmfEventRequest
// ------------------------------------------------------------------------
@Override
public void handleData(ITmfEvent data) {
    super.handleData(data);
    long index = getIndex() + getNbRead() - 1;
    String traceName = data.getTrace().getName();
    Set<ITmfEventRequest> requests = fRequestsCache.get(traceName);
    if (requests == null) {
        // Populate requests cache
        requests = new HashSet<>();
        for (ITmfEventRequest myRequest : fRequests) {
            if (myRequest.getProviderFilter().matches(data)) {
                requests.add(myRequest);
            }
        }
        fRequestsCache.put(traceName, requests);
    }
    // dispatch event to relevant requests
    for (ITmfEventRequest request : requests) {
        long start = request.getIndex();
        if (!request.isCompleted() && index >= start && request.getNbRead() < request.getNbRequested()) {
            ITmfTimestamp ts = data.getTimestamp();
            if (request.getRange().contains(ts)) {
                if (request.getDataType().isInstance(data)) {
                    try {
                        request.handleData(data);
                    } catch (Exception e) {
                        /*
                             * We don't usually catch all exception, but here it
                             * is important because this will cause the request
                             * thread to hang forever and the other requests to
                             * be stopped. This should properly cancel the
                             * request with the exception and let the rest
                             * continue.
                             */
                        // $NON-NLS-1$//$NON-NLS-2$
                        Activator.logError("An uncaught exception happened on request " + request + ": " + e.getMessage());
                        request.fail(e);
                    }
                }
            }
        }
    }
}
Also used : ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) ITmfEventRequest(org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest)

Example 14 with ITmfEventRequest

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

the class TmfUml2SDSyncLoader method traceClosed.

/**
 * Signal handler for the trace closed signal.
 *
 * @param signal
 *            The trace closed signal
 */
@TmfSignalHandler
public void traceClosed(TmfTraceClosedSignal signal) {
    if (signal.getTrace() != fTrace) {
        return;
    }
    ITmfEventRequest indexRequest = null;
    fLock.lock();
    try {
        indexRequest = fIndexRequest;
        fIndexRequest = null;
        cancelOngoingRequests();
        if (fFilterCriteria != null) {
            fFilterCriteria.clear();
        }
        FilterListDialog.deactivateSavedGlobalFilters();
    } finally {
        fTrace = null;
        fLock.unlock();
    }
    if (indexRequest != null && !indexRequest.isCompleted()) {
        indexRequest.cancel();
    }
    resetLoader();
}
Also used : ITmfEventRequest(org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest) TmfSignalHandler(org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)

Example 15 with ITmfEventRequest

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

the class TmfUml2SDSyncLoader method waitForCompletion.

/**
 * Waits for the page request to be completed
 */
public void waitForCompletion() {
    fLock.lock();
    ITmfEventRequest request = fPageRequest;
    fLock.unlock();
    if (request != null) {
        try {
            request.waitForCompletion();
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
        }
    }
}
Also used : 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