use of org.eclipse.tracecompass.tmf.core.component.ITmfEventProvider in project tracecompass by tracecompass.
the class TmfTrace method traceOpened.
// ------------------------------------------------------------------------
// Signal handlers
// ------------------------------------------------------------------------
/**
* Handler for the Trace Opened signal
*
* @param signal
* The incoming signal
*/
@TmfSignalHandler
public void traceOpened(TmfTraceOpenedSignal signal) {
boolean signalIsForUs = false;
ITmfEventProvider provider = this;
while (provider != null) {
if (provider == signal.getTrace()) {
signalIsForUs = true;
break;
}
provider = provider.getParent();
}
if (!signalIsForUs) {
return;
}
/*
* The signal is either for this trace, or for a parent of this trace.
*/
IStatus status = executeAnalysis();
if (!status.isOK()) {
Activator.log(status);
}
/* Refresh supplementary files in separate thread to prevent deadlock */
new // $NON-NLS-1$
Thread(// $NON-NLS-1$
"Refresh supplementary files") {
@Override
public void run() {
TmfTraceManager.refreshSupplementaryFiles(TmfTrace.this);
}
}.start();
if (signal.getTrace() == this) {
/* Additionally, the signal is directly for this trace. */
if (getNbEvents() == 0) {
return;
}
/* For a streaming trace, the range updated signal should be sent
* by the subclass when a new safe time is determined.
*/
if (getStreamingInterval() > 0) {
return;
}
if (isComplete()) {
final TmfTimeRange timeRange = new TmfTimeRange(getStartTime(), TmfTimestamp.BIG_CRUNCH);
final TmfTraceRangeUpdatedSignal rangeUpdatedsignal = new TmfTraceRangeUpdatedSignal(this, this, timeRange);
// Broadcast in separate thread to prevent deadlock
broadcastAsync(rangeUpdatedsignal);
}
return;
}
}
use of org.eclipse.tracecompass.tmf.core.component.ITmfEventProvider in project tracecompass by tracecompass.
the class TmfTraceTest method testProcessDataRequestForSomeEvents.
@Test
public void testProcessDataRequestForSomeEvents() throws InterruptedException {
final int startIndex = 100;
final int nbEvents = 1000;
final Vector<ITmfEvent> requestedEvents = new Vector<>();
final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class, TmfTimeRange.ETERNITY, startIndex, nbEvents, TmfEventRequest.ExecutionType.FOREGROUND) {
@Override
public void handleData(final ITmfEvent event) {
super.handleData(event);
requestedEvents.add(event);
}
};
final ITmfEventProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class, TmfTraceStub.class);
providers[0].sendRequest(request);
request.waitForCompletion();
assertEquals("nbEvents", nbEvents, requestedEvents.size());
assertTrue("isCompleted", request.isCompleted());
assertFalse("isCancelled", request.isCancelled());
// Don't go overboard: we are not validating the stub!
for (int i = 0; i < nbEvents; i++) {
assertEquals("Distinct events", startIndex + 1 + i, requestedEvents.get(i).getTimestamp().getValue());
}
}
use of org.eclipse.tracecompass.tmf.core.component.ITmfEventProvider in project tracecompass by tracecompass.
the class TmfTraceTest method testProcessEventRequestForAllEvents.
// ------------------------------------------------------------------------
// processRequest
// ------------------------------------------------------------------------
@Test
public void testProcessEventRequestForAllEvents() throws InterruptedException {
final Vector<ITmfEvent> requestedEvents = new Vector<>();
final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class, range, 0, NB_EVENTS, ExecutionType.FOREGROUND) {
@Override
public void handleData(final ITmfEvent event) {
super.handleData(event);
requestedEvents.add(event);
}
};
final ITmfEventProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class, TmfTraceStub.class);
providers[0].sendRequest(request);
request.waitForCompletion();
assertEquals("nbEvents", NB_EVENTS, requestedEvents.size());
assertTrue("isCompleted", request.isCompleted());
assertFalse("isCancelled", request.isCancelled());
// Don't go overboard: we are not validating the stub!
for (int i = 0; i < NB_EVENTS; i++) {
assertEquals("Distinct events", i + 1, requestedEvents.get(i).getTimestamp().getValue());
}
}
use of org.eclipse.tracecompass.tmf.core.component.ITmfEventProvider in project tracecompass by tracecompass.
the class TmfTraceTest method testProcessEventRequestForSomeEvents.
@Test
public void testProcessEventRequestForSomeEvents() throws InterruptedException {
final long startTime = 100;
final int nbEvents = 1000;
final Vector<ITmfEvent> requestedEvents = new Vector<>();
final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.create(startTime, SCALE), TmfTimestamp.BIG_CRUNCH);
final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class, range, 0, nbEvents, ExecutionType.FOREGROUND) {
@Override
public void handleData(final ITmfEvent event) {
super.handleData(event);
requestedEvents.add(event);
}
};
final ITmfEventProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class, TmfTraceStub.class);
providers[0].sendRequest(request);
request.waitForCompletion();
assertEquals("nbEvents", nbEvents, requestedEvents.size());
assertTrue("isCompleted", request.isCompleted());
assertFalse("isCancelled", request.isCancelled());
// Don't go overboard: we are not validating the stub!
for (int i = 0; i < nbEvents; i++) {
assertEquals("Distinct events", startTime + i, requestedEvents.get(i).getTimestamp().getValue());
}
}
Aggregations