ss: add a wrapper for the state system delete files
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Sun, 18 Sep 2016 03:54:44 +0000 (23:54 -0400)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Tue, 4 Oct 2016 19:49:26 +0000 (15:49 -0400)
This removes the need for the backend to be stored in the analysis

Change-Id: I32f4b1ceb99e4babf5ffe7e25731318ad8faa976
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/81298
Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Reviewed-by: Hudson CI
Reviewed-by: Alexandre Montplaisir <alexmonthy@efficios.com>
statesystem/org.eclipse.tracecompass.statesystem.core/META-INF/MANIFEST.MF
statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/StateSystem.java
statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/ITmfStateSystemBuilder.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statesystem/TmfStateSystemAnalysisModule.java

index 12476fe8866eaa4c3551d1d0c50e4e6afe742bf5..36b4ebb4f3fda6d8dbe4bb7801d9ade0d6686074 100644 (file)
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %Bundle-Name
 Bundle-Vendor: %Bundle-Vendor
-Bundle-Version: 2.0.1.qualifier
+Bundle-Version: 2.1.0.qualifier
 Bundle-Localization: plugin
 Bundle-SymbolicName: org.eclipse.tracecompass.statesystem.core;singleton:=true
 Bundle-Activator: org.eclipse.tracecompass.internal.statesystem.core.Activator
index eabedb5bce7920e5a816ff97bf87a61c1a0eee20..81b7feada9a820309077da1f1226ec4dc8395a9a 100644 (file)
@@ -602,6 +602,11 @@ public class StateSystem implements ITmfStateSystemBuilder {
         return ret;
     }
 
+    @Override
+    public void removeFiles() {
+        backend.removeFiles();
+    }
+
     //--------------------------------------------------------------------------
     //        Debug methods
     //--------------------------------------------------------------------------
index 70ee1308599b14b4b2a190097f42f470f1a5ff4b..817a6f2da906c547665cab3e616c14fd84f287b1 100644 (file)
@@ -235,4 +235,21 @@ public interface ITmfStateSystemBuilder extends ITmfStateSystem {
      *             know how to handle it.
      */
     void closeHistory(long endTime);
+
+    /**
+     * Delete any generated files or anything that might have been created by
+     * the history backend (either temporary or save files). By calling this, we
+     * return to the state as it was before ever building the history.
+     *
+     * You might not want to call automatically if, for example, you want an
+     * index file to persist on disk. This could be limited to actions
+     * originating from the user.
+     *
+     * FIXME Change to abstract for 3.0
+     *
+     * @since 2.1
+     */
+    default void removeFiles() {
+        // FIXME Change to abstract for 3.0
+    }
 }
index 9b2c3fb6dd774c3c8100924225dd39776ef90dc4..dfc25c7f94ee7048cf44740c39040c9f6d5b974f 100644 (file)
@@ -67,7 +67,6 @@ public abstract class TmfStateSystemAnalysisModule extends TmfAbstractAnalysisMo
     private final Object fRequestSyncObj = new Object();
 
     private @Nullable ITmfStateSystemBuilder fStateSystem;
-    private @Nullable IStateHistoryBackend fHtBackend;
     private @Nullable ITmfEventRequest fRequest;
     private @Nullable TmfTimeRange fTimeRange = null;
 
@@ -301,7 +300,6 @@ public abstract class TmfStateSystemAnalysisModule extends TmfAbstractAnalysisMo
             try {
                 IStateHistoryBackend backend = StateHistoryBackendFactory.createHistoryTreeBackendExistingFile(
                         id, htFile, version);
-                fHtBackend = backend;
                 fStateSystem = StateSystemFactory.newStateSystem(backend, false);
                 analysisReady(true);
                 return;
@@ -320,7 +318,6 @@ public abstract class TmfStateSystemAnalysisModule extends TmfAbstractAnalysisMo
         try {
             IStateHistoryBackend backend = StateHistoryBackendFactory.createHistoryTreeBackendNewFile(
                     id, htFile, provider.getVersion(), provider.getStartTime(), QUEUE_SIZE);
-            fHtBackend = backend;
             fStateSystem = StateSystemFactory.newStateSystem(backend);
             provider.assignTargetStateSystem(fStateSystem);
             build(provider);
@@ -401,7 +398,6 @@ public abstract class TmfStateSystemAnalysisModule extends TmfAbstractAnalysisMo
         provider.assignTargetStateSystem(realSS);
 
         /* 7 */
-        fHtBackend = partialBackend;
         fStateSystem = realSS;
 
         build(provider);
@@ -414,7 +410,6 @@ public abstract class TmfStateSystemAnalysisModule extends TmfAbstractAnalysisMo
      */
     private void createNullHistory(String id, ITmfStateProvider provider) {
         IStateHistoryBackend backend = StateHistoryBackendFactory.createNullBackend(id);
-        fHtBackend = backend;
         fStateSystem = StateSystemFactory.newStateSystem(backend);
         provider.assignTargetStateSystem(fStateSystem);
         build(provider);
@@ -427,7 +422,6 @@ public abstract class TmfStateSystemAnalysisModule extends TmfAbstractAnalysisMo
      */
     private void createInMemoryHistory(String id, ITmfStateProvider provider) {
         IStateHistoryBackend backend = StateHistoryBackendFactory.createInMemoryBackend(id, provider.getStartTime());
-        fHtBackend = backend;
         fStateSystem = StateSystemFactory.newStateSystem(backend);
         provider.assignTargetStateSystem(fStateSystem);
         build(provider);
@@ -439,13 +433,13 @@ public abstract class TmfStateSystemAnalysisModule extends TmfAbstractAnalysisMo
             provider.dispose();
         }
         fStateProvider = null;
-        if (deleteFiles && (fHtBackend != null)) {
-            fHtBackend.removeFiles();
+        if (deleteFiles && (fStateSystem != null)) {
+            fStateSystem.removeFiles();
         }
     }
 
     private void build(ITmfStateProvider provider) {
-        if ((fStateSystem == null) || (fHtBackend == null)) {
+        if (fStateSystem == null) {
             throw new IllegalArgumentException();
         }
 
This page took 0.027482 seconds and 5 git commands to generate.