use of org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange in project tracecompass by tracecompass.
the class LttngRelaydConsumer method run.
/**
* Run the consumer operation for a give trace.
*
* @param trace
* the trace
*/
public void run(final CtfTmfTrace trace) {
if (fSession == null) {
return;
}
fCtfTmfTrace = trace;
fConsumerJob = new // $NON-NLS-1$
Job(// $NON-NLS-1$
"RelayD consumer") {
@Override
protected IStatus run(final IProgressMonitor monitor) {
try {
while (!monitor.isCanceled()) {
List<StreamResponse> attachedStreams = fSession.getStreamList();
for (StreamResponse stream : attachedStreams) {
if (stream.getMetadataFlag() != 1) {
IndexResponse indexReply = fRelayd.getNextIndex(stream);
if (indexReply.getStatus() == NextIndexReturnCode.VIEWER_INDEX_OK) {
long nanoTimeStamp = fCtfTmfTrace.timestampCyclesToNanos(indexReply.getTimestampEnd());
if (nanoTimeStamp > fTimestampEnd) {
ITmfTimestamp endTime = TmfTimestamp.fromNanos(nanoTimeStamp);
TmfTimeRange range = new TmfTimeRange(fCtfTmfTrace.getStartTime(), endTime);
long currentTime = System.nanoTime();
if (currentTime - fLastSignal > SIGNAL_THROTTLE_NANOSEC) {
TmfTraceRangeUpdatedSignal signal = new TmfTraceRangeUpdatedSignal(LttngRelaydConsumer.this, fCtfTmfTrace, range);
fCtfTmfTrace.broadcastAsync(signal);
fLastSignal = currentTime;
}
fTimestampEnd = nanoTimeStamp;
}
} else if (indexReply.getStatus() == NextIndexReturnCode.VIEWER_INDEX_HUP) {
// The trace is now complete because the trace session was destroyed
fCtfTmfTrace.setComplete(true);
TmfTraceRangeUpdatedSignal signal = new TmfTraceRangeUpdatedSignal(LttngRelaydConsumer.this, fCtfTmfTrace, new TmfTimeRange(fCtfTmfTrace.getStartTime(), TmfTimestamp.fromNanos(fTimestampEnd)));
fCtfTmfTrace.broadcastAsync(signal);
return Status.OK_STATUS;
}
}
}
}
} catch (IOException e) {
// $NON-NLS-1$
Activator.getDefault().logError("Error during live trace reading", e);
// $NON-NLS-1$
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.LttngRelaydConsumer_ErrorLiveReading + (e.getMessage() != null ? e.getMessage() : ""));
}
return Status.OK_STATUS;
}
};
fConsumerJob.setSystem(true);
fConsumerJob.schedule();
}
use of org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange in project tracecompass by tracecompass.
the class PcapTraceTest method testGetTimeRange.
/**
* Run the TmfTimeRange getTimeRange() method test.
*/
@Test
public void testGetTimeRange() {
TmfTimeRange result = fFixture.getTimeRange();
assertNotNull(result);
}
use of org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange in project tracecompass by tracecompass.
the class TmfUml2SDSyncLoaderTimeTest method verifyTimeRangeDifferentPages.
/**
* Test Case: 009
* Description: Verify time range signal (start and end time are across 2 pages)
* Verified Methods: loader.synchToTimeRange(), loader.moveToMessage(), loader.moveToPage()
* Expected result: Move to correct page (=page of start time of range), set focus on start time of range, but no selection of message.
*/
@Test
public void verifyTimeRangeDifferentPages() {
TmfTimeRange range = new TmfTimeRange(TC_009_START_TIME_VALUE, TC_009_END_TIME_VALUE);
fFacility.getTrace().broadcast(new TmfWindowRangeUpdatedSignal(this, range));
fFacility.getLoader().waitForCompletion();
fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
assertEquals("synchToTimeRange", TC_009_PAGE_VALUE, fFacility.getLoader().currentPage());
assertNotNull("synchToTimeRange", fFacility.getLoader().getCurrentTime());
assertEquals("synchToTimeRange", 0, TC_009_TIME_VALUE.compareTo(fFacility.getLoader().getCurrentTime()));
selection = fFacility.getSdView().getSDWidget().getSelection();
// We actually don't want something to be selected!!!
assertNotNull("synchToTimeRange", selection);
assertEquals("synchToTimeRange", 0, selection.size());
}
use of org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange in project tracecompass by tracecompass.
the class TmfSchedulerTest method preemptedForegroundRequest.
/**
* One long foreground request and one short foreground request, the short
* one should finish first
*/
@Test
public void preemptedForegroundRequest() {
ForegroundRequest foreground9 = new ForegroundRequest(TmfTimeRange.ETERNITY);
TmfTimeRange shortTimeRange = new TmfTimeRange(TmfTimestamp.fromNanos(fStartTime), TmfTimestamp.fromNanos(fStartTime + ((fEndTime - fStartTime) / 16)));
ForegroundRequest shortForeground = new ForegroundRequest(shortTimeRange);
fixture.sendRequest(foreground9);
try {
foreground9.waitForStart();
} catch (InterruptedException e) {
fail();
}
fixture.sendRequest(shortForeground);
try {
shortForeground.waitForCompletion();
} catch (InterruptedException e) {
fail();
}
assertFalse(foreground9.isCompleted());
}
use of org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange in project tracecompass by tracecompass.
the class TmfTraceManagerTest method testExperimentTimestampInBetween.
/**
* Test in an experiment when we select a timestamp that is between two
* traces in the experiment.
*
* The experiment's current time should still be updated, since the
* timestamp is valid in the experiment itself.
*/
@Test
public void testExperimentTimestampInBetween() {
TmfExperiment exp = createExperiment(trace1, trace2);
openTrace(exp);
ITmfTimestamp ts = TmfTimestamp.fromNanos(t1end + ONE_SECOND);
selectTimestamp(ts);
/* The experiment's current time should be updated. */
TmfTimeRange selection = tm.getCurrentTraceContext().getSelectionRange();
assertEquals(ts, selection.getStartTime());
assertEquals(ts, selection.getEndTime());
}
Aggregations