From 05bd33186b0192c2dc3a3a04c3ec938312a4e363 Mon Sep 17 00:00:00 2001 From: Francois Chouinard Date: Fri, 11 Mar 2011 13:50:58 -0500 Subject: [PATCH] Fix for Bug337872 --- .../lttng/trace/LTTngTextTrace.java | 2 +- .../linuxtools/lttng/trace/LTTngTrace.java | 2 +- .../tmf/experiment/TmfExperiment.java | 28 +++++++++- .../linuxtools/tmf/trace/TmfTrace.java | 52 ++++++++++++++++++- 4 files changed, 79 insertions(+), 5 deletions(-) diff --git a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngTextTrace.java b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngTextTrace.java index 955c34bfba..e2e8c4e890 100644 --- a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngTextTrace.java +++ b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngTextTrace.java @@ -59,7 +59,7 @@ public class LTTngTextTrace extends TmfTrace implements ITmfTrace { } public LTTngTextTrace(String path, boolean skipIndexing) throws Exception { - super(path, LttngEvent.class, path, 1); + super(path, LttngEvent.class, path, 1, !skipIndexing); tracepath = path; traceTypes = new HashMap(); diff --git a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngTrace.java b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngTrace.java index 25c330ecf2..8d2e6701fe 100644 --- a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngTrace.java +++ b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngTrace.java @@ -144,7 +144,7 @@ public class LTTngTrace extends TmfTrace { */ public LTTngTrace(String path, boolean waitForCompletion, boolean bypassIndexing) throws Exception { - super(path, LttngEvent.class, path, CHECKPOINT_PAGE_SIZE); + super(path, LttngEvent.class, path, CHECKPOINT_PAGE_SIZE, false); try { currentJniTrace = JniTraceFactory.getJniTrace(path, SHOW_LTT_DEBUG_DEFAULT); diff --git a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/experiment/TmfExperiment.java b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/experiment/TmfExperiment.java index 6b5d036790..ef3d5f90e8 100644 --- a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/experiment/TmfExperiment.java +++ b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/experiment/TmfExperiment.java @@ -15,6 +15,10 @@ package org.eclipse.linuxtools.tmf.experiment; import java.util.Collections; import java.util.Vector; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; import org.eclipse.linuxtools.tmf.component.TmfEventProvider; import org.eclipse.linuxtools.tmf.event.TmfEvent; import org.eclipse.linuxtools.tmf.event.TmfTimeRange; @@ -665,7 +669,23 @@ public class TmfExperiment extends TmfEventProvider imple // } @SuppressWarnings("unchecked") - private void indexExperiment(boolean waitForCompletion) { + protected void indexExperiment(boolean waitForCompletion) { + + final Job job = new Job("Indexing " + getName() + "...") { //$NON-NLS-1$ //$NON-NLS-2$ + @Override + protected IStatus run(IProgressMonitor monitor) { + while (!monitor.isCanceled()) { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + return Status.OK_STATUS; + } + } + monitor.done(); + return Status.OK_STATUS; + } + }; + job.schedule(); fCheckpoints.clear(); @@ -708,6 +728,12 @@ public class TmfExperiment extends TmfEventProvider imple super.handleSuccess(); } + @Override + public void handleCompleted() { + job.cancel(); + super.handleCompleted(); + } + private void updateExperiment() { int nbRead = getNbRead(); if (nbRead != 0) { diff --git a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfTrace.java b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfTrace.java index 27496a78e5..9df74bdeec 100644 --- a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfTrace.java +++ b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfTrace.java @@ -17,6 +17,10 @@ import java.io.FileNotFoundException; import java.util.Collections; import java.util.Vector; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; import org.eclipse.linuxtools.tmf.component.TmfEventProvider; import org.eclipse.linuxtools.tmf.event.TmfEvent; import org.eclipse.linuxtools.tmf.event.TmfTimeRange; @@ -89,7 +93,7 @@ public abstract class TmfTrace extends TmfEventProvider i * @throws FileNotFoundException */ protected TmfTrace(String name, Class type, String path) throws FileNotFoundException { - this(name, type, path, DEFAULT_INDEX_PAGE_SIZE); + this(name, type, path, DEFAULT_INDEX_PAGE_SIZE, true); } /** @@ -98,12 +102,34 @@ public abstract class TmfTrace extends TmfEventProvider i * @throws FileNotFoundException */ protected TmfTrace(String name, Class type, String path, int cacheSize) throws FileNotFoundException { + this(name, type, path, cacheSize, true); + } + + /** + * @param path + * @param indexTrace + * @throws FileNotFoundException + */ + protected TmfTrace(String name, Class type, String path, boolean indexTrace) throws FileNotFoundException { + this(name, type, path, DEFAULT_INDEX_PAGE_SIZE, indexTrace); + } + + /** + * @param path + * @param cacheSize + * @param indexTrace + * @throws FileNotFoundException + */ + protected TmfTrace(String name, Class type, String path, int cacheSize, boolean indexTrace) throws FileNotFoundException { super(name, type); int sep = path.lastIndexOf(File.separator); String simpleName = (sep >= 0) ? path.substring(sep + 1) : path; setName(simpleName); fPath = path; fIndexPageSize = (cacheSize > 0) ? cacheSize : DEFAULT_INDEX_PAGE_SIZE; +// if (indexTrace) { +// indexTrace(false); +// } } /* (non-Javadoc) @@ -402,7 +428,23 @@ public abstract class TmfTrace extends TmfEventProvider i @SuppressWarnings({ "unchecked" }) private void indexTrace(boolean waitForCompletion) { - fCheckpoints.clear(); + final Job job = new Job("Indexing " + getName() + "...") { //$NON-NLS-1$ //$NON-NLS-2$ + @Override + protected IStatus run(IProgressMonitor monitor) { + while (!monitor.isCanceled()) { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + return Status.OK_STATUS; + } + } + monitor.done(); + return Status.OK_STATUS; + } + }; + job.schedule(); + + fCheckpoints.clear(); ITmfEventRequest request = new TmfEventRequest(TmfEvent.class, TmfTimeRange.Eternity, TmfDataRequest.ALL_DATA, 1, ITmfDataRequest.ExecutionType.BACKGROUND) { @@ -429,6 +471,12 @@ public abstract class TmfTrace extends TmfEventProvider i updateTrace(); } + @Override + public void handleCompleted() { + job.cancel(); + super.handleCompleted(); + } + private void updateTrace() { int nbRead = getNbRead(); if (nbRead != 0) { -- 2.34.1