/** The trace's statistics */
private ITmfStatistics fStatistics = null;
+ private boolean fInitializationSucceeded;
private final TmfStateSystemAnalysisModule totalsModule = new TmfStatisticsTotalsModule();
private final TmfStateSystemAnalysisModule eventTypesModule = new TmfStatisticsEventTypesModule();
/**
* Wait until the analyses/state systems underneath are ready to be queried.
+ * @since 2.0
*/
- public void waitForInitialization() {
+ @Override
+ public boolean waitForInitialization() {
try {
fInitialized.await();
- } catch (InterruptedException e) {}
+ } catch (InterruptedException e) {
+ return false;
+ }
+ return fInitializationSucceeded;
}
// ------------------------------------------------------------------------
ITmfTrace trace = getTrace();
if (trace == null) {
/* This analysis was cancelled in the meantime */
+ fInitializationSucceeded = false;
fInitialized.countDown();
return false;
}
IStatus status2 = eventTypesModule.schedule();
if (!(status1.isOK() && status2.isOK())) {
cancelSubAnalyses();
+ fInitializationSucceeded = false;
fInitialized.countDown();
return false;
}
/* Wait until the two modules are initialized */
- totalsModule.waitForInitialization();
- eventTypesModule.waitForInitialization();
+ if (!totalsModule.waitForInitialization() || !eventTypesModule.waitForInitialization()) {
+ fInitializationSucceeded = false;
+ fInitialized.countDown();
+ return false;
+ }
ITmfStateSystem totalsSS = totalsModule.getStateSystem();
ITmfStateSystem eventTypesSS = eventTypesModule.getStateSystem();
if (totalsSS == null || eventTypesSS == null) {
/* This analysis was cancelled in the meantime */
+ fInitializationSucceeded = false;
fInitialized.countDown();
- return false;
+ throw new IllegalStateException("TmfStatisticsModule : Sub-modules initialization succeeded but there is a null state system."); //$NON-NLS-1$
}
fStatistics = new TmfStateStatistics(totalsSS, eventTypesSS);
/* fStatistics is now set, consider this module initialized */
+ fInitializationSucceeded = true;
fInitialized.countDown();
/*
}
@Override
- public Iterable<ITmfStateSystem> getStateSystems() {
- List<ITmfStateSystem> list = new LinkedList<>();
- list.add(totalsModule.getStateSystem());
- list.add(eventTypesModule.getStateSystem());
+ public @NonNull Iterable<@NonNull ITmfStateSystem> getStateSystems() {
+ List<@NonNull ITmfStateSystem> list = new LinkedList<>();
+ ITmfStateSystem totalsStateSystem = totalsModule.getStateSystem();
+ if (totalsStateSystem != null) {
+ list.add(totalsStateSystem);
+ }
+ ITmfStateSystem eventTypesStateSystem = eventTypesModule.getStateSystem();
+ if (eventTypesStateSystem != null) {
+ list.add(eventTypesStateSystem);
+ }
return list;
}
}