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();
}
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);
}
}
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);
}
}
}
}
}
}
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();
}
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();
}
}
}
Aggregations