private final Thread fEventHandlerThread;
private boolean fStateSystemAssigned;
-
/** State system in which to insert the state changes */
private @Nullable ITmfStateSystemBuilder fSS = null;
+ /* The last safe time at which this state provider can be queried */
+ private volatile long fSafeTime;
+
/**
* Instantiate a new state provider plugin.
*
fTrace = trace;
fEventsQueue = new BufferedBlockingQueue<>(DEFAULT_EVENTS_QUEUE_SIZE, DEFAULT_EVENTS_CHUNK_SIZE);
fStateSystemAssigned = false;
+ // set the safe time to before the trace start, the analysis has not yet started
+ fSafeTime = trace.getStartTime().toNanos() - 1;
fEventHandlerThread = new Thread(new EventProcessor(), id + " Event Handler"); //$NON-NLS-1$
}
return fTrace.getStartTime().toNanos();
}
+ /**
+ * @since 2.0
+ */
+ @Override
+ public long getLatestSafeTime() {
+ return fSafeTime;
+ }
+
@Override
public void assignTargetStateSystem(ITmfStateSystemBuilder ssb) {
fSS = ssb;
continue;
}
currentEvent = event;
+ fSafeTime = event.getTimestamp().toNanos() - 1;
eventHandle(event);
event = fEventsQueue.take();
}
*/
long getStartTime();
+ /**
+ * Return the last time at which it is safe to query the state system under
+ * construction, ie not the current end time of the underlying state system,
+ * but the time just before the latest event that has been processed.
+ *
+ * @return The last timestamp at which it is safe to query the state system
+ * underneath
+ * @since 2.0
+ */
+ long getLatestSafeTime();
+
/**
* Assign the target state system where this SCI will insert its state
* changes. Because of dependencies issues, this can normally not be done at
private final CountDownLatch fInitialized = new CountDownLatch(1);
private final Object fRequestSyncObj = new Object();
- @Nullable private ITmfStateSystemBuilder fStateSystem;
- @Nullable private ITmfStateProvider fStateProvider;
- @Nullable private IStateHistoryBackend fHtBackend;
- @Nullable private ITmfEventRequest fRequest;
- @Nullable private TmfTimeRange fTimeRange = null;
+ private @Nullable ITmfStateSystemBuilder fStateSystem;
+ private @Nullable IStateHistoryBackend fHtBackend;
+ private @Nullable ITmfEventRequest fRequest;
+ private @Nullable TmfTimeRange fTimeRange = null;
private int fNbRead = 0;
private boolean fInitializationSucceeded;
+ private volatile @Nullable ITmfStateProvider fStateProvider;
+
/**
* State system backend types
*
return fInitializationSucceeded;
}
+ /**
+ * @since 2.0
+ */
+ @Override
+ public boolean isQueryable(long ts) {
+ /* Return true if there is no state provider available (the analysis is not being built) */
+ ITmfStateProvider provider = fStateProvider;
+ if (provider == null) {
+ return true;
+ }
+ return ts <= provider.getLatestSafeTime();
+ }
+
// ------------------------------------------------------------------------
// TmfAbstractAnalysisModule
// ------------------------------------------------------------------------
/* Get the state system according to backend */
StateSystemBackendType backend = getBackendType();
-
ITmfTrace trace = getTrace();
if (trace == null) {
// Analysis was cancelled in the meantime
if (provider != null) {
provider.dispose();
}
+ fStateProvider = null;
if (deleteFiles && (fHtBackend != null)) {
fHtBackend.removeFiles();
}
@Override
public void handleCancel() {
super.handleCancel();
- if (isCompleteTrace(trace)) {
- disposeProvider(true);
- }
+ disposeProvider(true);
}
@Override