/**
* Returns all the listeners
+ *
* @return latency listeners
*/
protected Iterable<IAnalysisProgressListener> getListeners() {
* Return the pre-defined set of segment aspects exposed by this analysis.
*
* It should not be null, but could be empty.
+ *
* @return The segment aspects for this analysis
*/
public Iterable<ISegmentAspect> getSegmentAspects() {
/**
* Returns the file name for storing segment store
- * @return segment store fine name
+ *
+ * @return segment store fine name, or null if you don't want a file
*/
- protected abstract String getDataFileName();
+ protected @Nullable String getDataFileName() {
+ return null;
+ }
/**
* Returns the analysis request for creating the segment store
+ *
* @param segmentStore
- * a segment store to fill
+ * a segment store to fill
* @return the segment store analysis request implementation
*/
protected abstract AbstractSegmentStoreAnalysisRequest createAnalysisRequest(ISegmentStore<ISegment> segmentStore);
/**
* Returns the result in a from the analysis in a ISegmentStore
+ *
* @return Results from the analysis in a ISegmentStore
*/
public @Nullable ISegmentStore<ISegment> getResults() {
protected boolean executeAnalysis(IProgressMonitor monitor) throws TmfAnalysisException {
ITmfTrace trace = checkNotNull(getTrace());
- /* See if the data file already exists on disk */
- String dir = TmfTraceManager.getSupplementaryFileDir(trace);
- final Path file = Paths.get(dir, getDataFileName());
-
- if (Files.exists(file)) {
- /* Attempt to read the existing file */
- try (ObjectInputStream ois = new ObjectInputStream(Files.newInputStream(file))) {
- Object[] segmentArray = readObject(ois);
- final ISegmentStore<ISegment> store = new TreeMapStore<>();
- for (Object element : segmentArray) {
- if (element instanceof ISegment) {
- ISegment segment = (ISegment) element;
- store.add(segment);
+ final @Nullable String dataFileName = getDataFileName();
+ if (dataFileName != null) {
+ /* See if the data file already exists on disk */
+ String dir = TmfTraceManager.getSupplementaryFileDir(trace);
+ final Path file = Paths.get(dir, dataFileName);
+
+ if (Files.exists(file)) {
+ /* Attempt to read the existing file */
+ try (ObjectInputStream ois = new ObjectInputStream(Files.newInputStream(file))) {
+ Object[] segmentArray = readObject(ois);
+ final ISegmentStore<ISegment> store = new TreeMapStore<>();
+ for (Object element : segmentArray) {
+ if (element instanceof ISegment) {
+ ISegment segment = (ISegment) element;
+ store.add(segment);
+ }
+ }
+ fSegmentStore = store;
+ for (IAnalysisProgressListener listener : getListeners()) {
+ listener.onComplete(this, store);
+ }
+ return true;
+ } catch (IOException | ClassNotFoundException | ClassCastException e) {
+ /*
+ * We did not manage to read the file successfully, we will
+ * just fall-through to rebuild a new one.
+ */
+ try {
+ Files.delete(file);
+ } catch (IOException e1) {
}
- }
- fSegmentStore = store;
- for (IAnalysisProgressListener listener : getListeners()) {
- listener.onComplete(this, store);
- }
- return true;
- } catch (IOException | ClassNotFoundException | ClassCastException e) {
- /*
- * We did not manage to read the file successfully, we will just
- * fall-through to rebuild a new one.
- */
- try {
- Files.delete(file);
- } catch (IOException e1) {
}
}
}
-
- ISegmentStore<ISegment> syscalls = new TreeMapStore<>();
+ ISegmentStore<ISegment> segmentStore = new TreeMapStore<>();
/* Cancel an ongoing request */
ITmfEventRequest req = fOngoingRequest;
}
/* Create a new request */
- req = createAnalysisRequest(syscalls);
+ req = createAnalysisRequest(segmentStore);
fOngoingRequest = req;
trace.sendRequest(req);
}
/* The request will fill 'syscalls' */
- fSegmentStore = syscalls;
+ fSegmentStore = segmentStore;
+
+ if (dataFileName != null) {
+ String dir = TmfTraceManager.getSupplementaryFileDir(trace);
+ final Path file = Paths.get(dir, dataFileName);
- /* Serialize the collections to disk for future usage */
- try (ObjectOutputStream oos = new ObjectOutputStream(Files.newOutputStream(file))) {
- oos.writeObject(syscalls.toArray());
- } catch (IOException e) {
- /* Didn't work, oh well. We will just re-read the trace next time */
+ /* Serialize the collections to disk for future usage */
+ try (ObjectOutputStream oos = new ObjectOutputStream(Files.newOutputStream(file))) {
+ oos.writeObject(segmentStore.toArray());
+ } catch (IOException e) {
+ /*
+ * Didn't work, oh well. We will just re-read the trace next
+ * time
+ */
+ }
}
for (IAnalysisProgressListener listener : getListeners()) {
- listener.onComplete(this, syscalls);
+ listener.onComplete(this, segmentStore);
}
return true;
/**
* Returns the segment store
+ *
* @return the segment store
*/
public ISegmentStore<ISegment> getSegmentStore() {