tmf : Move initialization steps of modules into analysisReady() method
authorJean-Christian Kouame <jean-christian.kouame@ericsson.com>
Wed, 24 Feb 2016 19:10:33 +0000 (14:10 -0500)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Wed, 2 Mar 2016 21:51:42 +0000 (16:51 -0500)
This method will set the module available and set whether the
initialization succeeded or not.

Change-Id: I6988bfdced259f6b92d318edd09652e3d72e8a5d
Signed-off-by: Jean-Christian Kouame <jean-christian.kouame@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/67286
Reviewed-by: Hudson CI
Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Tested-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statesystem/TmfStateSystemAnalysisModule.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statistics/TmfStatisticsModule.java

index b53cfcd7ae493fed25e8c282fb423ecb9a1025d2..fc7a41d540a255811378e819ff81c94d4e1f989d 100644 (file)
@@ -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
index 5755f15082a4676e6909030b9ab62c96b57c520d..297a0f2a4aa411548447fe8e71e6541433ae49ba 100644 (file)
@@ -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() {
         /*
This page took 0.028099 seconds and 5 git commands to generate.