Search in sources :

Example 1 with TmfTraceRangeUpdatedSignal

use of org.eclipse.tracecompass.tmf.core.signal.TmfTraceRangeUpdatedSignal in project tracecompass by tracecompass.

the class TmfStatisticsViewImpl method traceSelected.

/**
 * Handler called when an trace is selected. Checks if the trace
 * has changed and requests the selected trace if it has not yet been
 * cached.
 *
 * @param signal
 *            Contains the information about the selection.
 */
@TmfSignalHandler
public void traceSelected(TmfTraceSelectedSignal signal) {
    // Does not reload the same trace if already opened
    if (signal.getTrace() != fTrace) {
        /*
             * Dispose the current viewer and adapt the new one to the trace
             * type of the trace selected
             */
        fStatsViewers.clear();
        // Update the current trace
        fTrace = signal.getTrace();
        createStatisticsViewers();
        fStatsViewers.layout();
        TmfTraceRangeUpdatedSignal updateSignal = new TmfTraceRangeUpdatedSignal(this, fTrace, fTrace.getTimeRange());
        for (ITmfViewer viewer : fStatsViewers.getViewers()) {
            TmfStatisticsViewer statsViewer = (TmfStatisticsViewer) viewer;
            statsViewer.sendPartialRequestOnNextUpdate();
            statsViewer.traceRangeUpdated(updateSignal);
        }
    } else {
        /*
             * If the same trace is reselected, sends a notification to
             * the viewers to make sure they reload correctly their partial
             * event count.
             */
        for (ITmfViewer viewer : fStatsViewers.getViewers()) {
            TmfStatisticsViewer statsViewer = (TmfStatisticsViewer) viewer;
            // Will update the partial event count if needed.
            statsViewer.sendPartialRequestOnNextUpdate();
        }
    }
}
Also used : TmfTraceRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceRangeUpdatedSignal) TmfStatisticsViewer(org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.TmfStatisticsViewer) ITmfViewer(org.eclipse.tracecompass.tmf.ui.viewers.ITmfViewer) TmfSignalHandler(org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)

Example 2 with TmfTraceRangeUpdatedSignal

use of org.eclipse.tracecompass.tmf.core.signal.TmfTraceRangeUpdatedSignal in project tracecompass by tracecompass.

the class RefreshTraceContentHandler method refreshTrace.

private static void refreshTrace(ITmfTrace trace) {
    TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
    TmfTraceRangeUpdatedSignal signal = new TmfTraceRangeUpdatedSignal(trace, trace, range);
    trace.broadcastAsync(signal);
}
Also used : TmfTraceRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceRangeUpdatedSignal) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)

Example 3 with TmfTraceRangeUpdatedSignal

use of org.eclipse.tracecompass.tmf.core.signal.TmfTraceRangeUpdatedSignal 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 4 with TmfTraceRangeUpdatedSignal

use of org.eclipse.tracecompass.tmf.core.signal.TmfTraceRangeUpdatedSignal in project tracecompass by tracecompass.

the class TmfExperiment method initializeStreamingMonitor.

// ------------------------------------------------------------------------
// Streaming support
// ------------------------------------------------------------------------
private synchronized void initializeStreamingMonitor() {
    if (fInitialized) {
        return;
    }
    fInitialized = true;
    if (getStreamingInterval() == 0) {
        final ITmfContext context = seekEvent(0);
        final ITmfEvent event = getNext(context);
        context.dispose();
        if (event == null) {
            return;
        }
        final TmfTimeRange timeRange = new TmfTimeRange(event.getTimestamp(), TmfTimestamp.BIG_CRUNCH);
        final TmfTraceRangeUpdatedSignal signal = new TmfTraceRangeUpdatedSignal(this, this, timeRange);
        // Broadcast in separate thread to prevent deadlock
        new Thread() {

            @Override
            public void run() {
                broadcast(signal);
            }
        }.start();
        return;
    }
    final Thread thread = new // $NON-NLS-1$
    Thread(// $NON-NLS-1$
    "Streaming Monitor for experiment " + getName()) {

        private ITmfTimestamp safeTimestamp = null;

        private ITmfTimestamp lastSafeTimestamp = null;

        private TmfTimeRange timeRange = null;

        @Override
        public void run() {
            while (!executorIsShutdown()) {
                if (!getIndexer().isIndexing()) {
                    ITmfTimestamp startTimestamp = TmfTimestamp.BIG_CRUNCH;
                    ITmfTimestamp endTimestamp = TmfTimestamp.BIG_BANG;
                    for (final ITmfTrace trace : getChildren(ITmfTrace.class)) {
                        if (trace.getStartTime().compareTo(startTimestamp) < 0) {
                            startTimestamp = trace.getStartTime();
                        }
                        if (trace.getStreamingInterval() != 0 && trace.getEndTime().compareTo(endTimestamp) > 0) {
                            endTimestamp = trace.getEndTime();
                        }
                    }
                    ITmfTimestamp safeTs = safeTimestamp;
                    if (safeTs != null && (lastSafeTimestamp == null || safeTs.compareTo(lastSafeTimestamp) > 0)) {
                        timeRange = new TmfTimeRange(startTimestamp, safeTs);
                        lastSafeTimestamp = safeTs;
                    } else {
                        timeRange = null;
                    }
                    safeTimestamp = endTimestamp;
                    if (timeRange != null) {
                        final TmfTraceRangeUpdatedSignal signal = new TmfTraceRangeUpdatedSignal(TmfExperiment.this, TmfExperiment.this, timeRange);
                        broadcast(signal);
                    }
                }
                try {
                    Thread.sleep(getStreamingInterval());
                } catch (final InterruptedException e) {
                // Do nothing
                }
            }
        }
    };
    thread.start();
}
Also used : ITmfContext(org.eclipse.tracecompass.tmf.core.trace.ITmfContext) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfTraceRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceRangeUpdatedSignal) ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)

Example 5 with TmfTraceRangeUpdatedSignal

use of org.eclipse.tracecompass.tmf.core.signal.TmfTraceRangeUpdatedSignal 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;
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) ITmfEventProvider(org.eclipse.tracecompass.tmf.core.component.ITmfEventProvider) TmfTraceRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceRangeUpdatedSignal) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) TmfSignalHandler(org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)

Aggregations

TmfTraceRangeUpdatedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfTraceRangeUpdatedSignal)5 TmfTimeRange (org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)4 IStatus (org.eclipse.core.runtime.IStatus)2 TmfSignalHandler (org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)2 ITmfTimestamp (org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp)2 IOException (java.io.IOException)1 List (java.util.List)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 Status (org.eclipse.core.runtime.Status)1 IndexResponse (org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.IndexResponse)1 StreamResponse (org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.StreamResponse)1 TmfStatisticsViewer (org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.TmfStatisticsViewer)1 ITmfEventProvider (org.eclipse.tracecompass.tmf.core.component.ITmfEventProvider)1 ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)1 ITmfContext (org.eclipse.tracecompass.tmf.core.trace.ITmfContext)1 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)1 ITmfViewer (org.eclipse.tracecompass.tmf.ui.viewers.ITmfViewer)1