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