Skip to content

Commit

Permalink
server: read first event when opening a trace
Browse files Browse the repository at this point in the history
This will initialize the start time of the trace object which is needed
when initializing a state system.

[Fixed] Uninitialized start time of trace in trace server

Change-Id: If6236e7fd28e30e7a1d58c84b4b69f130652c380
Signed-off-by: Bernd Hufmann <Bernd.Hufmann@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/150955
Tested-by: CI Bot
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
  • Loading branch information
bhufmann committed Oct 15, 2019
1 parent ef3924c commit 93691f9
Showing 1 changed file with 6 additions and 1 deletion.
Expand Up @@ -50,6 +50,7 @@
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
import org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal;
import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal;
import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
import org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment;
Expand Down Expand Up @@ -130,6 +131,11 @@ private ITmfTrace put(String path, String name, String typeID)
ITmfTrace trace = helper.getTraceClass().newInstance();
trace.initTrace(resource, path, ITmfEvent.class, name, typeID);
trace.indexTrace(false);
// read first event to make sure start time is initialized
ITmfContext ctx = trace.seekEvent(0);
trace.getNext(ctx);
ctx.dispose();

TmfSignalManager.dispatchSignal(new TmfTraceOpenedSignal(this, trace, null));
return trace;
}
Expand Down Expand Up @@ -212,7 +218,6 @@ public Response deleteTrace(@PathParam("uuid") @NotNull UUID uuid) {
return Response.status(Status.NOT_FOUND).build();
}
TmfSignalManager.dispatchSignal(new TmfTraceClosedSignal(this, trace));
TmfTraceManager.deleteSupplementaryFolder(trace);
trace.dispose();
try {
IResource resource = trace.getResource();
Expand Down

0 comments on commit 93691f9

Please sign in to comment.