tmf: annotate TmfContext#location as nullable
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.core / src / org / eclipse / tracecompass / tmf / core / parsers / custom / CustomTxtTrace.java
CommitLineData
6151d86c 1/*******************************************************************************
53f17e49 2 * Copyright (c) 2010, 2016 Ericsson
6151d86c
PT
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Patrick Tasse - Initial API and implementation
c9b31f60 11 * Bernd Hufmann - Add trace type id handling
6151d86c
PT
12 *******************************************************************************/
13
2bdf0193 14package org.eclipse.tracecompass.tmf.core.parsers.custom;
6151d86c 15
202956f1
AM
16import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
17
eb8ea213 18import java.io.File;
6151d86c
PT
19import java.io.FileNotFoundException;
20import java.io.IOException;
032ecd45 21import java.nio.ByteBuffer;
6151d86c
PT
22import java.util.HashMap;
23import java.util.Iterator;
24import java.util.List;
25import java.util.Map.Entry;
26import java.util.regex.Matcher;
27
28import org.eclipse.core.resources.IProject;
29import org.eclipse.core.resources.IResource;
a94410d9
MK
30import org.eclipse.core.runtime.IStatus;
31import org.eclipse.core.runtime.Status;
c9b31f60 32import org.eclipse.jdt.annotation.NonNull;
2bdf0193 33import org.eclipse.tracecompass.internal.tmf.core.Activator;
b04903a2 34import org.eclipse.tracecompass.internal.tmf.core.parsers.custom.CustomEventAspects;
2bdf0193 35import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
53f17e49 36import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
b04903a2 37import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
2bdf0193
AM
38import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
39import org.eclipse.tracecompass.tmf.core.io.BufferedRandomAccessFile;
40import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTxtTraceDefinition.InputLine;
0bc16991
MAL
41import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler;
42import org.eclipse.tracecompass.tmf.core.signal.TmfTraceRangeUpdatedSignal;
2bdf0193
AM
43import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
44import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
2bdf0193 45import org.eclipse.tracecompass.tmf.core.trace.TmfContext;
c9b31f60 46import org.eclipse.tracecompass.tmf.core.trace.TmfTrace;
d26d67f5 47import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
2bdf0193
AM
48import org.eclipse.tracecompass.tmf.core.trace.TraceValidationStatus;
49import org.eclipse.tracecompass.tmf.core.trace.indexer.ITmfPersistentlyIndexable;
50import org.eclipse.tracecompass.tmf.core.trace.indexer.ITmfTraceIndexer;
51import org.eclipse.tracecompass.tmf.core.trace.indexer.TmfBTreeTraceIndexer;
52import org.eclipse.tracecompass.tmf.core.trace.indexer.checkpoint.ITmfCheckpoint;
53import org.eclipse.tracecompass.tmf.core.trace.indexer.checkpoint.TmfCheckpoint;
54import org.eclipse.tracecompass.tmf.core.trace.location.ITmfLocation;
55import org.eclipse.tracecompass.tmf.core.trace.location.TmfLongLocation;
6151d86c 56
a0a88f65
AM
57/**
58 * Base class for custom plain text traces.
59 *
60 * @author Patrick Tassé
61 */
c9b31f60 62public class CustomTxtTrace extends TmfTrace implements ITmfPersistentlyIndexable {
6151d86c 63
661becf8 64 private static final TmfLongLocation NULL_LOCATION = new TmfLongLocation(-1L);
6151d86c 65 private static final int DEFAULT_CACHE_SIZE = 100;
cd43d683
PT
66 private static final int MAX_LINES = 100;
67 private static final int MAX_CONFIDENCE = 100;
6151d86c
PT
68
69 private final CustomTxtTraceDefinition fDefinition;
53f17e49 70 private final ITmfEventField fRootField;
6151d86c 71 private BufferedRandomAccessFile fFile;
53f17e49 72 private final @NonNull String fTraceTypeId;
c9b31f60
BH
73
74 private static final char SEPARATOR = ':';
75 private static final String CUSTOM_TXT_TRACE_TYPE_PREFIX = "custom.txt.trace" + SEPARATOR; //$NON-NLS-1$
76 private static final String LINUX_TOOLS_CUSTOM_TXT_TRACE_TYPE_PREFIX = "org.eclipse.linuxtools.tmf.core.parsers.custom.CustomTxtTrace" + SEPARATOR; //$NON-NLS-1$
77 private static final String EARLY_TRACE_COMPASS_CUSTOM_TXT_TRACE_TYPE_PREFIX = "org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTxtTrace" + SEPARATOR; //$NON-NLS-1$
6151d86c 78
a0a88f65
AM
79 /**
80 * Basic constructor.
81 *
82 * @param definition
83 * Text trace definition
84 */
6151d86c
PT
85 public CustomTxtTrace(final CustomTxtTraceDefinition definition) {
86 fDefinition = definition;
53f17e49 87 fRootField = CustomEventType.getRootField(definition);
c9b31f60 88 fTraceTypeId = buildTraceTypeId(definition.categoryName, definition.definitionName);
6151d86c
PT
89 setCacheSize(DEFAULT_CACHE_SIZE);
90 }
91
a0a88f65
AM
92 /**
93 * Full constructor.
94 *
95 * @param resource
96 * Trace's resource.
97 * @param definition
98 * Text trace definition
99 * @param path
100 * Path to the trace file
101 * @param cacheSize
102 * Cache size to use
103 * @throws TmfTraceException
104 * If we couldn't open the trace at 'path'
105 */
106 public CustomTxtTrace(final IResource resource,
107 final CustomTxtTraceDefinition definition, final String path,
108 final int cacheSize) throws TmfTraceException {
6151d86c
PT
109 this(definition);
110 setCacheSize((cacheSize > 0) ? cacheSize : DEFAULT_CACHE_SIZE);
111 initTrace(resource, path, CustomTxtEvent.class);
112 }
113
114 @Override
115 public void initTrace(final IResource resource, final String path, final Class<? extends ITmfEvent> eventType) throws TmfTraceException {
116 super.initTrace(resource, path, eventType);
0bc16991
MAL
117 initFile();
118 }
119
120 private void initFile() throws TmfTraceException {
121 closeFile();
6151d86c
PT
122 try {
123 fFile = new BufferedRandomAccessFile(getPath(), "r"); //$NON-NLS-1$
124 } catch (IOException e) {
125 throw new TmfTraceException(e.getMessage(), e);
126 }
6151d86c
PT
127 }
128
129 @Override
130 public synchronized void dispose() {
131 super.dispose();
0bc16991
MAL
132 closeFile();
133 }
134
135 private void closeFile() {
6151d86c
PT
136 if (fFile != null) {
137 try {
138 fFile.close();
139 } catch (IOException e) {
140 } finally {
141 fFile = null;
142 }
143 }
144 }
145
b0422293
PT
146 @Override
147 public ITmfTraceIndexer getIndexer() {
148 return super.getIndexer();
149 }
150
b04903a2 151 @Override
ec48d248 152 public Iterable<ITmfEventAspect<?>> getEventAspects() {
b04903a2
AM
153 return CustomEventAspects.generateAspects(fDefinition);
154 }
155
6151d86c
PT
156 @Override
157 public synchronized TmfContext seekEvent(final ITmfLocation location) {
158 final CustomTxtTraceContext context = new CustomTxtTraceContext(NULL_LOCATION, ITmfContext.UNKNOWN_RANK);
159 if (NULL_LOCATION.equals(location) || fFile == null) {
160 return context;
161 }
162 try {
163 if (location == null) {
164 fFile.seek(0);
165 } else if (location.getLocationInfo() instanceof Long) {
166 fFile.seek((Long) location.getLocationInfo());
167 }
6151d86c 168 long rawPos = fFile.getFilePointer();
cd43d683
PT
169 String line = fFile.getNextLine();
170 while (line != null) {
6151d86c
PT
171 for (final InputLine input : getFirstLines()) {
172 final Matcher matcher = input.getPattern().matcher(line);
03e9dbb7 173 if (matcher.matches()) {
6151d86c
PT
174 context.setLocation(new TmfLongLocation(rawPos));
175 context.firstLineMatcher = matcher;
176 context.firstLine = line;
177 context.nextLineLocation = fFile.getFilePointer();
178 context.inputLine = input;
179 return context;
180 }
181 }
182 rawPos = fFile.getFilePointer();
cd43d683 183 line = fFile.getNextLine();
6151d86c
PT
184 }
185 return context;
186 } catch (final FileNotFoundException e) {
47aafe74 187 Activator.logError("Error seeking event. File not found: " + getPath(), e); //$NON-NLS-1$
6151d86c
PT
188 return context;
189 } catch (final IOException e) {
47aafe74 190 Activator.logError("Error seeking event. File: " + getPath(), e); //$NON-NLS-1$
6151d86c
PT
191 return context;
192 }
193
194 }
195
196 @Override
197 public synchronized TmfContext seekEvent(final double ratio) {
198 if (fFile == null) {
199 return new CustomTxtTraceContext(NULL_LOCATION, ITmfContext.UNKNOWN_RANK);
200 }
201 try {
91f6e587 202 long pos = Math.round(ratio * fFile.length());
6151d86c
PT
203 while (pos > 0) {
204 fFile.seek(pos - 1);
205 if (fFile.read() == '\n') {
206 break;
207 }
208 pos--;
209 }
210 final ITmfLocation location = new TmfLongLocation(pos);
211 final TmfContext context = seekEvent(location);
212 context.setRank(ITmfContext.UNKNOWN_RANK);
213 return context;
214 } catch (final IOException e) {
47aafe74 215 Activator.logError("Error seeking event. File: " + getPath(), e); //$NON-NLS-1$
6151d86c
PT
216 return new CustomTxtTraceContext(NULL_LOCATION, ITmfContext.UNKNOWN_RANK);
217 }
218 }
219
220 @Override
221 public synchronized double getLocationRatio(final ITmfLocation location) {
222 if (fFile == null) {
223 return 0;
224 }
225 try {
226 if (location.getLocationInfo() instanceof Long) {
0126a8ca 227 return ((Long) location.getLocationInfo()).doubleValue() / fFile.length();
6151d86c
PT
228 }
229 } catch (final IOException e) {
47aafe74 230 Activator.logError("Error seeking event. File: " + getPath(), e); //$NON-NLS-1$
6151d86c
PT
231 }
232 return 0;
233 }
234
235 @Override
236 public ITmfLocation getCurrentLocation() {
237 // TODO Auto-generated method stub
238 return null;
239 }
240
241 @Override
242 public synchronized CustomTxtEvent parseEvent(final ITmfContext tmfContext) {
243 ITmfContext context = seekEvent(tmfContext.getLocation());
244 return parse(context);
245 }
246
247 @Override
248 public synchronized CustomTxtEvent getNext(final ITmfContext context) {
4c9f2944 249 final ITmfContext savedContext = new TmfContext(context.getLocation(), context.getRank());
6151d86c
PT
250 final CustomTxtEvent event = parse(context);
251 if (event != null) {
5904c11e 252 updateAttributes(savedContext, event);
6151d86c
PT
253 context.increaseRank();
254 }
255 return event;
256 }
257
258 private synchronized CustomTxtEvent parse(final ITmfContext tmfContext) {
259 if (fFile == null) {
260 return null;
261 }
262 if (!(tmfContext instanceof CustomTxtTraceContext)) {
263 return null;
264 }
265
266 final CustomTxtTraceContext context = (CustomTxtTraceContext) tmfContext;
38db0431
MK
267 ITmfLocation location = context.getLocation();
268 if (location == null || !(location.getLocationInfo() instanceof Long) || NULL_LOCATION.equals(location)) {
6151d86c
PT
269 return null;
270 }
271
272 CustomTxtEvent event = parseFirstLine(context);
273
507b1336 274 final HashMap<InputLine, Integer> countMap = new HashMap<>();
6151d86c
PT
275 InputLine currentInput = null;
276 if (context.inputLine.childrenInputs != null && context.inputLine.childrenInputs.size() > 0) {
277 currentInput = context.inputLine.childrenInputs.get(0);
278 countMap.put(currentInput, 0);
279 }
280
281 try {
282 if (fFile.getFilePointer() != context.nextLineLocation) {
283 fFile.seek(context.nextLineLocation);
284 }
6151d86c 285 long rawPos = fFile.getFilePointer();
cd43d683
PT
286 String line = fFile.getNextLine();
287 while (line != null) {
6151d86c
PT
288 boolean processed = false;
289 if (currentInput == null) {
290 for (final InputLine input : getFirstLines()) {
291 final Matcher matcher = input.getPattern().matcher(line);
03e9dbb7 292 if (matcher.matches()) {
6151d86c
PT
293 context.setLocation(new TmfLongLocation(rawPos));
294 context.firstLineMatcher = matcher;
295 context.firstLine = line;
296 context.nextLineLocation = fFile.getFilePointer();
297 context.inputLine = input;
298 return event;
299 }
300 }
301 } else {
202956f1 302 if (checkNotNull(countMap.get(currentInput)) >= currentInput.getMinCount()) {
6151d86c
PT
303 final List<InputLine> nextInputs = currentInput.getNextInputs(countMap);
304 if (nextInputs.size() == 0 || nextInputs.get(nextInputs.size() - 1).getMinCount() == 0) {
305 for (final InputLine input : getFirstLines()) {
306 final Matcher matcher = input.getPattern().matcher(line);
03e9dbb7 307 if (matcher.matches()) {
6151d86c
PT
308 context.setLocation(new TmfLongLocation(rawPos));
309 context.firstLineMatcher = matcher;
310 context.firstLine = line;
311 context.nextLineLocation = fFile.getFilePointer();
312 context.inputLine = input;
313 return event;
314 }
315 }
316 }
317 for (final InputLine input : nextInputs) {
318 final Matcher matcher = input.getPattern().matcher(line);
03e9dbb7 319 if (matcher.matches()) {
6151d86c
PT
320 event.processGroups(input, matcher);
321 currentInput = input;
322 if (countMap.get(currentInput) == null) {
323 countMap.put(currentInput, 1);
324 } else {
202956f1 325 countMap.put(currentInput, checkNotNull(countMap.get(currentInput)) + 1);
6151d86c
PT
326 }
327 Iterator<InputLine> iter = countMap.keySet().iterator();
328 while (iter.hasNext()) {
329 final InputLine inputLine = iter.next();
330 if (inputLine.level > currentInput.level) {
331 iter.remove();
332 }
333 }
334 if (currentInput.childrenInputs != null && currentInput.childrenInputs.size() > 0) {
335 currentInput = currentInput.childrenInputs.get(0);
336 countMap.put(currentInput, 0);
202956f1 337 } else if (checkNotNull(countMap.get(currentInput)) >= currentInput.getMaxCount()) {
6151d86c
PT
338 if (currentInput.getNextInputs(countMap).size() > 0) {
339 currentInput = currentInput.getNextInputs(countMap).get(0);
340 if (countMap.get(currentInput) == null) {
341 countMap.put(currentInput, 0);
342 }
343 iter = countMap.keySet().iterator();
344 while (iter.hasNext()) {
345 final InputLine inputLine = iter.next();
346 if (inputLine.level > currentInput.level) {
347 iter.remove();
348 }
349 }
350 } else {
351 currentInput = null;
352 }
353 }
354 processed = true;
355 break;
356 }
357 }
358 }
3dca7aa5 359 if (!processed && currentInput != null) {
6151d86c 360 final Matcher matcher = currentInput.getPattern().matcher(line);
03e9dbb7 361 if (matcher.matches()) {
6151d86c 362 event.processGroups(currentInput, matcher);
202956f1 363 countMap.put(currentInput, checkNotNull(countMap.get(currentInput)) + 1);
6151d86c
PT
364 if (currentInput.childrenInputs != null && currentInput.childrenInputs.size() > 0) {
365 currentInput = currentInput.childrenInputs.get(0);
366 countMap.put(currentInput, 0);
202956f1 367 } else if (checkNotNull(countMap.get(currentInput)) >= currentInput.getMaxCount()) {
6151d86c
PT
368 if (currentInput.getNextInputs(countMap).size() > 0) {
369 currentInput = currentInput.getNextInputs(countMap).get(0);
370 if (countMap.get(currentInput) == null) {
371 countMap.put(currentInput, 0);
372 }
373 final Iterator<InputLine> iter = countMap.keySet().iterator();
374 while (iter.hasNext()) {
375 final InputLine inputLine = iter.next();
376 if (inputLine.level > currentInput.level) {
377 iter.remove();
378 }
379 }
380 } else {
381 currentInput = null;
382 }
383 }
384 }
eab78906 385 ((StringBuffer) event.getContentValue()).append("\n").append(line); //$NON-NLS-1$
6151d86c
PT
386 }
387 }
388 rawPos = fFile.getFilePointer();
cd43d683 389 line = fFile.getNextLine();
6151d86c
PT
390 }
391 } catch (final IOException e) {
47aafe74 392 Activator.logError("Error seeking event. File: " + getPath(), e); //$NON-NLS-1$
6151d86c
PT
393 }
394 for (final Entry<InputLine, Integer> entry : countMap.entrySet()) {
395 if (entry.getValue() < entry.getKey().getMinCount()) {
396 event = null;
397 }
398 }
399 context.setLocation(NULL_LOCATION);
400 return event;
401 }
402
a0a88f65
AM
403 /**
404 * @return The first few lines of the text file
405 */
6151d86c
PT
406 public List<InputLine> getFirstLines() {
407 return fDefinition.inputs;
408 }
409
a0a88f65
AM
410 /**
411 * Parse the first line of the trace (to recognize the type).
412 *
413 * @param context
414 * Trace context
415 * @return The first event
416 */
6151d86c 417 public CustomTxtEvent parseFirstLine(final CustomTxtTraceContext context) {
53f17e49
GB
418 CustomTxtEventType eventType = new CustomTxtEventType(checkNotNull(fDefinition.definitionName), fRootField);
419 final CustomTxtEvent event = new CustomTxtEvent(fDefinition, this, TmfTimestamp.ZERO, eventType);
6151d86c
PT
420 event.processGroups(context.inputLine, context.firstLineMatcher);
421 event.setContent(new CustomEventContent(event, new StringBuffer(context.firstLine)));
422 return event;
423 }
424
a0a88f65
AM
425 /**
426 * Get the trace definition.
427 *
428 * @return The trace definition
429 */
6151d86c
PT
430 public CustomTraceDefinition getDefinition() {
431 return fDefinition;
432 }
433
cd43d683
PT
434 /**
435 * {@inheritDoc}
436 * <p>
437 * The default implementation computes the confidence as the percentage of
438 * lines in the first 100 lines of the file which match any of the root
439 * input line patterns.
440 */
6151d86c 441 @Override
a94410d9 442 public IStatus validate(IProject project, String path) {
eb8ea213 443 File file = new File(path);
cd43d683
PT
444 if (!file.exists() || !file.isFile() || !file.canRead()) {
445 return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.CustomTrace_FileNotFound + ": " + path); //$NON-NLS-1$
446 }
447 int confidence = 0;
d26d67f5
BH
448 try {
449 if (!TmfTraceUtils.isText(file)) {
450 return new TraceValidationStatus(confidence, Activator.PLUGIN_ID);
451 }
452 } catch (IOException e) {
453 Activator.logError("Error validating file: " + path, e); //$NON-NLS-1$
454 return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "IOException validating file: " + path, e); //$NON-NLS-1$
455 }
cd43d683
PT
456 try (BufferedRandomAccessFile rafile = new BufferedRandomAccessFile(path, "r")) { //$NON-NLS-1$
457 int lineCount = 0;
918551aa 458 double matches = 0.0;
cd43d683 459 String line = rafile.getNextLine();
d26d67f5 460
cd43d683
PT
461 while ((line != null) && (lineCount++ < MAX_LINES)) {
462 for (InputLine inputLine : fDefinition.inputs) {
463 Matcher matcher = inputLine.getPattern().matcher(line);
03e9dbb7 464 if (matcher.matches()) {
918551aa
BH
465 int groupCount = matcher.groupCount();
466 matches += (1.0 + groupCount / ((double) groupCount + 1));
cd43d683
PT
467 break;
468 }
469 }
918551aa 470 confidence = (int) (MAX_CONFIDENCE * matches / lineCount);
cd43d683
PT
471 line = rafile.getNextLine();
472 }
473 } catch (IOException e) {
474 return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "IOException validating file: " + path, e); //$NON-NLS-1$
a94410d9 475 }
cd43d683 476 return new TraceValidationStatus(confidence, Activator.PLUGIN_ID);
6151d86c 477 }
032ecd45
MAL
478
479 private static int fCheckpointSize = -1;
480
481 @Override
482 public synchronized int getCheckpointSize() {
483 if (fCheckpointSize == -1) {
484 TmfCheckpoint c = new TmfCheckpoint(TmfTimestamp.ZERO, new TmfLongLocation(0L), 0);
485 ByteBuffer b = ByteBuffer.allocate(ITmfCheckpoint.MAX_SERIALIZE_SIZE);
486 b.clear();
487 c.serialize(b);
488 fCheckpointSize = b.position();
489 }
490
491 return fCheckpointSize;
492 }
493
494 @Override
495 public ITmfLocation restoreLocation(ByteBuffer bufferIn) {
496 return new TmfLongLocation(bufferIn);
497 }
498
499 @Override
500 protected ITmfTraceIndexer createIndexer(int interval) {
501 return new TmfBTreeTraceIndexer(this, interval);
502 }
c9b31f60
BH
503
504 @Override
505 public String getTraceTypeId() {
506 return fTraceTypeId;
507 }
508
509 /**
510 * Build the trace type id for a custom text trace
511 *
512 * @param category
513 * the category
514 * @param definitionName
515 * the definition name
516 * @return the trace type id
517 */
518 public static @NonNull String buildTraceTypeId(String category, String definitionName) {
519 return CUSTOM_TXT_TRACE_TYPE_PREFIX + category + SEPARATOR + definitionName;
520 }
521
522 /**
523 * Checks whether the given trace type ID is a custom text trace type ID
524 *
525 * @param traceTypeId
526 * the trace type ID to check
527 * @return <code>true</code> if it's a custom text trace type ID else <code>false</code>
528 */
529 public static boolean isCustomTraceTypeId(@NonNull String traceTypeId) {
530 return traceTypeId.startsWith(CUSTOM_TXT_TRACE_TYPE_PREFIX);
531 }
532
533 /**
534 * This methods builds a trace type ID from a given ID taking into
535 * consideration any format changes that were done for the IDs of custom
536 * text traces. For example, such format change took place when moving to
537 * Trace Compass. Trace type IDs that are part of the plug-in extension for
538 * trace types won't be changed.
539 *
540 * This method is useful for IDs that were persisted in the workspace before
541 * the format changes (e.g. in the persistent properties of a trace
542 * resource).
543 *
544 * It ensures backwards compatibility of the workspace for custom text
545 * traces.
546 *
547 * @param traceTypeId
548 * the legacy trace type ID
549 * @return the trace type id in Trace Compass format
550 */
551 public static @NonNull String buildCompatibilityTraceTypeId(@NonNull String traceTypeId) {
552 // Handle early Trace Compass custom text trace type IDs
553 if (traceTypeId.startsWith(EARLY_TRACE_COMPASS_CUSTOM_TXT_TRACE_TYPE_PREFIX)) {
554 return CUSTOM_TXT_TRACE_TYPE_PREFIX + traceTypeId.substring(EARLY_TRACE_COMPASS_CUSTOM_TXT_TRACE_TYPE_PREFIX.length());
555 }
556
557 // Handle Linux Tools custom text trace type IDs (with and without category)
558 int index = traceTypeId.lastIndexOf(SEPARATOR);
559 if ((index != -1) && (traceTypeId.startsWith(LINUX_TOOLS_CUSTOM_TXT_TRACE_TYPE_PREFIX))) {
560 String definitionName = index < traceTypeId.length() ? traceTypeId.substring(index + 1) : ""; //$NON-NLS-1$
561 if (traceTypeId.contains(CustomTxtTrace.class.getSimpleName() + SEPARATOR) && traceTypeId.indexOf(SEPARATOR) == index) {
562 return buildTraceTypeId(CustomTxtTraceDefinition.CUSTOM_TXT_CATEGORY, definitionName);
563 }
564 return CUSTOM_TXT_TRACE_TYPE_PREFIX + traceTypeId.substring(LINUX_TOOLS_CUSTOM_TXT_TRACE_TYPE_PREFIX.length());
565 }
566 return traceTypeId;
567 }
0bc16991
MAL
568
569 @TmfSignalHandler
570 @Override
571 public void traceRangeUpdated(TmfTraceRangeUpdatedSignal signal) {
572 if (signal.getTrace() == this) {
573 try {
574 synchronized (this) {
575 // Reset the file handle in case it has reached the end of the
576 // file already. Otherwise, it will not be able to read new data
577 // pass the previous end.
578 initFile();
579 }
580 } catch (TmfTraceException e) {
581 Activator.logError(e.getLocalizedMessage(), e);
582 }
583 }
584 super.traceRangeUpdated(signal);
585 }
6151d86c 586}
This page took 0.120374 seconds and 5 git commands to generate.