From: Jean-Christian Kouame Date: Wed, 24 Feb 2016 19:10:33 +0000 (-0500) Subject: tmf : Move initialization steps of modules into analysisReady() method X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=fa6e786910771f64aca6982371ea08b45ba50c1e;p=deliverable%2Ftracecompass.git tmf : Move initialization steps of modules into analysisReady() method This method will set the module available and set whether the initialization succeeded or not. Change-Id: I6988bfdced259f6b92d318edd09652e3d72e8a5d Signed-off-by: Jean-Christian Kouame Reviewed-on: https://git.eclipse.org/r/67286 Reviewed-by: Hudson CI Reviewed-by: Genevieve Bastien Tested-by: Genevieve Bastien Reviewed-by: Matthew Khouzam --- diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statesystem/TmfStateSystemAnalysisModule.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statesystem/TmfStateSystemAnalysisModule.java index b53cfcd7ae..fc7a41d540 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statesystem/TmfStateSystemAnalysisModule.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statesystem/TmfStateSystemAnalysisModule.java @@ -206,8 +206,7 @@ public abstract class TmfStateSystemAnalysisModule extends TmfAbstractAnalysisMo ITmfTrace trace = getTrace(); if (trace == null) { // Analysis was cancelled in the meantime - fInitializationSucceeded = false; - fInitialized.countDown(); + analysisReady(false); return false; } switch (backend) { @@ -237,13 +236,25 @@ public abstract class TmfStateSystemAnalysisModule extends TmfAbstractAnalysisMo break; } } catch (TmfTraceException e) { - fInitializationSucceeded = false; - fInitialized.countDown(); + analysisReady(false); return false; } return !mon.isCanceled(); } + /** + * Make the module available and set whether the initialization succeeded or + * not. If not, no state system is available and + * {@link #waitForInitialization()} should return false. + * + * @param success + * True if the initialization succeeded, false otherwise + */ + private void analysisReady(boolean succeeded) { + fInitializationSucceeded = succeeded; + fInitialized.countDown(); + } + @Override protected void canceling() { ITmfEventRequest req = fRequest; @@ -283,8 +294,7 @@ public abstract class TmfStateSystemAnalysisModule extends TmfAbstractAnalysisMo id, htFile, version); fHtBackend = backend; fStateSystem = StateSystemFactory.newStateSystem(backend, false); - fInitializationSucceeded = true; - fInitialized.countDown(); + analysisReady(true); return; } catch (IOException e) { /* @@ -449,8 +459,7 @@ public abstract class TmfStateSystemAnalysisModule extends TmfAbstractAnalysisMo * The state system object is now created, we can consider this module * "initialized" (components can retrieve it and start doing queries). */ - fInitializationSucceeded = true; - fInitialized.countDown(); + analysisReady(true); /* * Block the executeAnalysis() construction is complete (so that the diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statistics/TmfStatisticsModule.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statistics/TmfStatisticsModule.java index 5755f15082..297a0f2a4a 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statistics/TmfStatisticsModule.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statistics/TmfStatisticsModule.java @@ -118,8 +118,7 @@ public class TmfStatisticsModule extends TmfAbstractAnalysisModule ITmfTrace trace = getTrace(); if (trace == null) { /* This analysis was cancelled in the meantime */ - fInitializationSucceeded = false; - fInitialized.countDown(); + analysisReady(false); return false; } @@ -127,15 +126,13 @@ public class TmfStatisticsModule extends TmfAbstractAnalysisModule IStatus status2 = eventTypesModule.schedule(); if (!(status1.isOK() && status2.isOK())) { cancelSubAnalyses(); - fInitializationSucceeded = false; - fInitialized.countDown(); + analysisReady(false); return false; } /* Wait until the two modules are initialized */ if (!totalsModule.waitForInitialization() || !eventTypesModule.waitForInitialization()) { - fInitializationSucceeded = false; - fInitialized.countDown(); + analysisReady(false); return false; } @@ -144,16 +141,14 @@ public class TmfStatisticsModule extends TmfAbstractAnalysisModule if (totalsSS == null || eventTypesSS == null) { /* This analysis was cancelled in the meantime */ - fInitializationSucceeded = false; - fInitialized.countDown(); + analysisReady(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(); + analysisReady(true); /* * The rest of this "execute" will encompass the "execute" of the two @@ -166,6 +161,19 @@ public class TmfStatisticsModule extends TmfAbstractAnalysisModule return true; } + /** + * Make the module available and set whether the initialization went well or + * not. If not, no state system is available and + * {@link #waitForInitialization()} should return false. + * + * @param success + * True if the initialization went well, false otherwise + */ + private void analysisReady(boolean succeeded) { + fInitializationSucceeded = succeeded; + fInitialized.countDown(); + } + @Override protected void canceling() { /*