import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
import org.eclipse.tracecompass.tmf.core.io.BufferedRandomAccessFile;
import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTxtTraceDefinition.InputLine;
+import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler;
+import org.eclipse.tracecompass.tmf.core.signal.TmfTraceRangeUpdatedSignal;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
import org.eclipse.tracecompass.tmf.core.trace.TmfContext;
@Override
public void initTrace(final IResource resource, final String path, final Class<? extends ITmfEvent> eventType) throws TmfTraceException {
super.initTrace(resource, path, eventType);
+ initFile();
+ }
+
+ private void initFile() throws TmfTraceException {
+ closeFile();
try {
fFile = new BufferedRandomAccessFile(getPath(), "r"); //$NON-NLS-1$
} catch (IOException e) {
@Override
public synchronized void dispose() {
super.dispose();
+ closeFile();
+ }
+
+ private void closeFile() {
if (fFile != null) {
try {
fFile.close();
}
return traceTypeId;
}
+
+ @TmfSignalHandler
+ @Override
+ public void traceRangeUpdated(TmfTraceRangeUpdatedSignal signal) {
+ if (signal.getTrace() == this) {
+ try {
+ synchronized (this) {
+ // Reset the file handle in case it has reached the end of the
+ // file already. Otherwise, it will not be able to read new data
+ // pass the previous end.
+ initFile();
+ }
+ } catch (TmfTraceException e) {
+ Activator.logError(e.getLocalizedMessage(), e);
+ }
+ }
+ super.traceRangeUpdated(signal);
+ }
}