import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.btf.core.Activator;
import org.eclipse.tracecompass.btf.core.event.BtfEvent;
import org.eclipse.tracecompass.btf.core.event.BtfEventType;
import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
import org.eclipse.tracecompass.tmf.core.io.BufferedRandomAccessFile;
import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTxtTraceContext;
+import org.eclipse.tracecompass.tmf.core.project.model.ITmfPropertiesProvider;
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.ITmfTraceProperties;
import org.eclipse.tracecompass.tmf.core.trace.TmfContext;
import org.eclipse.tracecompass.tmf.core.trace.TmfTrace;
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
*
* @author Matthew Khouzam
*/
-public class BtfTrace extends TmfTrace implements ITmfPersistentlyIndexable, ITmfTraceProperties {
+public class BtfTrace extends TmfTrace implements ITmfPersistentlyIndexable, ITmfPropertiesProvider {
private static final int MAX_FIELDS = 7;
private static int fCheckpointSize = -1;
- private final Map<String, String> fProperties = new HashMap<>();
+ private final @NonNull Map<String, String> fProperties = new HashMap<>();
- private final Map<Integer, String> fEntityTable = new TreeMap<>();
- private final Map<BtfEventType, String> fEntityTypeTable = new HashMap<>();
- private final Map<Integer, BtfEventType> fEntityTypes = new TreeMap<>();
+ private final @NonNull Map<Integer, String> fEntityTable = new TreeMap<>();
+ private final @NonNull Map<BtfEventType, String> fEntityTypeTable = new HashMap<>();
+ private final @NonNull Map<Integer, BtfEventType> fEntityTypes = new TreeMap<>();
private String fVersion;
private String fCreator;
fProperties.put(CREATIONDATE, fCreationDate);
try {
- // DateFormats are inherently unsafe for multithreaded use so we can't make this a field. Just in case.
+ // DateFormats are inherently unsafe for multithreaded use
+ // so we can't make this a field. Just in case.
final SimpleDateFormat ISO8601DATEFORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX"); //$NON-NLS-1$
Date dateTime = ISO8601DATEFORMAT.parse(fCreationDate);
fTsOffset = dateTime.getTime() * MICROSECONDS_IN_A_SECOND;
}
final TmfContext context = (TmfContext) tmfContext;
- if (context.getLocation() == null
- || !(context.getLocation().getLocationInfo() instanceof Long)
- || NULL_LOCATION.equals(context.getLocation())) {
+ ITmfLocation location = context.getLocation();
+ if (location == null
+ || !(location.getLocationInfo() instanceof Long)
+ || NULL_LOCATION.equals(location)) {
return null;
}
* @return the event from a given line
*/
private ITmfEvent parseLine(TmfContext context) {
- try {
- if (!context.getLocation().getLocationInfo().equals(fFileInput.getFilePointer())) {
- seekEvent(context.getLocation());
+ ITmfLocation location = context.getLocation();
+ if (location != null) {
+ try {
+ if (!location.getLocationInfo().equals(fFileInput.getFilePointer())) {
+ seekEvent(location);
+ }
+ } catch (IOException e1) {
+ seekEvent(location);
}
- } catch (IOException e1) {
- seekEvent(context.getLocation());
- }
- String line;
- try {
- line = fFileInput.readLine();
- return parseLine(context.getRank(), line);
+ String line;
+ try {
+ line = fFileInput.readLine();
+ return parseLine(context.getRank(), line);
- } catch (IOException e) {
+ } catch (IOException e) {
+ Activator.logError(e.getMessage(), e);
+ }
}
-
return null;
}
return new TmfBTreeTraceIndexer(this, interval);
}
+ /**
+ * @since 2.0
+ */
@Override
- public Map<String, String> getTraceProperties() {
+ public Map<String, String> getProperties() {
return ImmutableMap.copyOf(fProperties);
}
@Override
- public Iterable<ITmfEventAspect> getEventAspects() {
+ public Iterable<ITmfEventAspect<?>> getEventAspects() {
return BtfEventAspects.getAspects();
}
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.
+ /*
+ * 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) {