Search in sources :

Example 86 with TmfTimeRange

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();
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) IndexResponse(org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.IndexResponse) TmfTraceRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceRangeUpdatedSignal) StreamResponse(org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.StreamResponse) ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) List(java.util.List) IOException(java.io.IOException) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)

Example 87 with TmfTimeRange

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);
}
Also used : TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) Test(org.junit.Test)

Example 88 with TmfTimeRange

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());
}
Also used : TmfWindowRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) Test(org.junit.Test)

Example 89 with TmfTimeRange

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());
}
Also used : TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) Test(org.junit.Test)

Example 90 with TmfTimeRange

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());
}
Also used : TmfExperiment(org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment) ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) Test(org.junit.Test)

Aggregations

TmfTimeRange (org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)168 Test (org.junit.Test)98 ITmfTimestamp (org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp)53 TmfWindowRangeUpdatedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal)29 ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)24 TmfEventRequest (org.eclipse.tracecompass.tmf.core.request.TmfEventRequest)24 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)21 TmfSignalHandler (org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)20 TmfSelectionRangeUpdatedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal)19 ITmfEventRequest (org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest)16 SWTBotTimeGraph (org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotTimeGraph)16 Vector (java.util.Vector)13 SWTBotView (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)12 TmfTraceManager (org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager)10 ITmfEventProvider (org.eclipse.tracecompass.tmf.core.component.ITmfEventProvider)9 AbstractTimeGraphView (org.eclipse.tracecompass.tmf.ui.views.timegraph.AbstractTimeGraphView)9 TmfTraceContext (org.eclipse.tracecompass.tmf.core.trace.TmfTraceContext)8 TmfExperiment (org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment)8 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)8 Point (org.eclipse.swt.graphics.Point)7