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