use of org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems in project tracecompass by tracecompass.
the class TmfXmlAnalysisOutputSource method moduleCreated.
@Override
public void moduleCreated(IAnalysisModule module) {
if (module instanceof ITmfAnalysisModuleWithStateSystems) {
Multimap<String, XmlOutputElement> outputs = XmlUtils.getXmlOutputElements();
for (Collection<XmlOutputElement> elements : outputs.asMap().values()) {
for (ViewType viewType : ViewType.values()) {
Iterable<XmlOutputElement> filteredElements = Iterables.filter(elements, element -> (element.getXmlElem().equals(viewType.getXmlElem()) && element.getAnalyses().contains(module.getId())));
String viewId = viewType.getViewId();
for (XmlOutputElement element : filteredElements) {
IAnalysisOutput output = new TmfXmlViewOutput(viewId, viewType);
output.setOutputProperty(TmfXmlStrings.XML_OUTPUT_DATA, element.getId() + DATA_SEPARATOR + element.getPath() + DATA_SEPARATOR + element.getLabel(), false);
module.registerOutput(output);
}
}
}
}
// Add the latency views for pattern analysis
if (module instanceof XmlPatternAnalysis) {
for (LatencyViewType viewType : LatencyViewType.values()) {
String viewLabelPrefix = ((XmlPatternAnalysis) module).getViewLabelPrefix();
String label = viewLabelPrefix.isEmpty() ? viewType.getLabel() : viewType.getLabel().replaceFirst(LATENCY_STRING, viewLabelPrefix);
IAnalysisOutput output = new TmfXmlLatencyViewOutput(viewType.getViewId(), label);
output.setOutputProperty(TmfXmlStrings.XML_LATENCY_OUTPUT_DATA, module.getId() + DATA_SEPARATOR + output.getName(), false);
module.registerOutput(output);
}
}
}
use of org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems in project tracecompass by tracecompass.
the class StateSystemDataProvider method addTrace.
private boolean addTrace(@Nullable IProgressMonitor monitor) {
boolean fetchTreeIsComplete = true;
ITmfTrace trace = getTrace();
// look if the trace entry already exist
String traceName = Objects.requireNonNull(trace.getName());
EntryModelBuilder entry = fEntryBuilder.get(-1L, traceName);
TraceEntryModel.Builder traceEntry;
if (entry instanceof TraceEntryModel.Builder) {
traceEntry = (TraceEntryModel.Builder) entry;
} else {
long newId = ENTRY_ID.getAndIncrement();
traceEntry = new TraceEntryModel.Builder(newId, -1, traceName, trace.getStartTime().toNanos(), trace);
fEntryBuilder.put(-1L, traceName, traceEntry);
}
// add child entry
long rootId = traceEntry.getId();
for (Entry<ITmfAnalysisModuleWithStateSystems, Boolean> moduleWithStatus : fModulesToStatus.entrySet()) {
if (monitor != null && monitor.isCanceled()) {
return false;
}
ITmfAnalysisModuleWithStateSystems module = Objects.requireNonNull(moduleWithStatus.getKey());
Boolean analysisIsDone = Objects.requireNonNull(moduleWithStatus.getValue());
if (!analysisIsDone || fStartedAnalysis.contains(module)) {
// Children entry of the trace are the modules
fetchTreeIsComplete &= addModule(monitor, module, rootId, trace.getStartTime().toNanos());
fStartedAnalysis.remove(module);
}
}
// Update end Time
long traceEnd = traceEntry.getEndTime();
for (ModuleEntryModel moduleEntryModel : fModuleEntryModelList) {
if (monitor != null && monitor.isCanceled()) {
return false;
}
traceEnd = Long.max(traceEnd, moduleEntryModel.getEndTime());
}
traceEntry.setEndTime(traceEnd);
return fetchTreeIsComplete;
}
use of org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems in project tracecompass by tracecompass.
the class TmfStateSystemExplorer method handleAnalysisStarted.
/**
* Rebuild the view's entry tree to ensure that entries from a newly started
* trace are added.
*
* @param signal
* analysis started signal.
* @since 3.3
*/
@TmfSignalHandler
public void handleAnalysisStarted(TmfStartAnalysisSignal signal) {
IAnalysisModule module = signal.getAnalysisModule();
if (module instanceof ITmfAnalysisModuleWithStateSystems && !module.isAutomatic()) {
/*
* use set to wait for initialization in build entry list to avoid
* deadlocks.
*/
final ITmfTrace viewTrace = getTrace();
if (Iterables.contains(allModules(viewTrace), module)) {
/*
* Rebuild only if the started analysis module is from the
* active trace/experiment.
*/
new Thread(() -> {
/*
* DataProviderManager#getDataProvider() (see getDataProvider() below) should never be called in a signal handler.
*/
synchronized (fStartedAnalysis) {
fStartedAnalysis.add((ITmfAnalysisModuleWithStateSystems) module);
// Every children of ITmfAnalysisModuleWithStateSystems extends TmfAbstractAnalysisModule
ITmfTrace moduleTrace = module instanceof TmfAbstractAnalysisModule ? ((TmfAbstractAnalysisModule) module).getTrace() : viewTrace;
if (moduleTrace != null) {
getDataProvider(moduleTrace).startedAnalysisSignalHandler((ITmfAnalysisModuleWithStateSystems) module);
rebuild();
}
}
}).start();
} else {
/*
* Reset the View for the relevant trace, ensuring that the
* entry list will be rebuilt when the view switches back.
*/
for (ITmfTrace trace : TmfTraceManager.getInstance().getOpenedTraces()) {
if (Iterables.contains(allModules(trace), module)) {
synchronized (fStartedAnalysis) {
fStartedAnalysis.add((ITmfAnalysisModuleWithStateSystems) module);
resetView(trace);
}
break;
}
}
}
}
}
use of org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems in project tracecompass by tracecompass.
the class XmlTimeGraphDataProviderTest method testFactory.
/**
* Test the {@link DataDrivenTimeGraphProviderFactory} class
*/
@Test
public void testFactory() {
ITmfTrace trace = getTrace();
assertNotNull(trace);
try {
runModule(trace);
// Get the view element from the file
Element viewElement = TmfXmlUtils.getElementInFile(TmfXmlTestFiles.DATA_PROVIDER_SIMPLE_FILE.getPath().toOSString(), TmfXmlStrings.TIME_GRAPH_VIEW, TIME_GRAPH_VIEW_ID);
assertNotNull(viewElement);
TmfXmlTimeGraphViewCu tgViewCu = TmfXmlTimeGraphViewCu.compile(new AnalysisCompilationData(), viewElement);
assertNotNull(tgViewCu);
DataDrivenTimeGraphProviderFactory timeGraphFactory = tgViewCu.generate();
// Test the factory with a simple trace
ITimeGraphDataProvider<@NonNull TimeGraphEntryModel> provider = timeGraphFactory.create(trace);
assertNotNull(provider);
assertEquals(DataDrivenTimeGraphDataProvider.ID, provider.getId());
// Test the factory with an ID and state system
ITmfAnalysisModuleWithStateSystems module = TmfTraceUtils.getAnalysisModuleOfClass(trace, ITmfAnalysisModuleWithStateSystems.class, ANALYSIS_ID);
assertNotNull(module);
Iterable<@NonNull ITmfStateSystem> stateSystems = module.getStateSystems();
assertNotNull(stateSystems);
provider = DataDrivenTimeGraphProviderFactory.create(trace, Objects.requireNonNull(Lists.newArrayList(stateSystems)), getEntries(new AnalysisCompilationData(), viewElement), getvalues(viewElement), ANALYSIS_ID);
assertNotNull(provider);
assertEquals(ANALYSIS_ID, provider.getId());
} finally {
trace.dispose();
TmfTraceManager.getInstance().traceClosed(new TmfTraceClosedSignal(this, trace));
}
}
use of org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems in project tracecompass by tracecompass.
the class XmlXyDataProviderTest method testXYFactory.
/**
* Test the {@link DataDrivenXYProviderFactory} class
*/
@Test
public void testXYFactory() {
ITmfTrace trace = getTrace();
assertNotNull(trace);
try {
runModule(trace);
// Get the view element from the file
Element viewElement = TmfXmlUtils.getElementInFile(TmfXmlTestFiles.DATA_PROVIDER_SIMPLE_FILE.getPath().toOSString(), TmfXmlStrings.XY_VIEW, XY_VIEW_ID_DELTA);
assertNotNull(viewElement);
TmfXmlXYViewCu tgViewCu = TmfXmlXYViewCu.compile(new AnalysisCompilationData(), viewElement);
assertNotNull(tgViewCu);
DataDrivenXYProviderFactory XYFactory = tgViewCu.generate();
// Test the factory with a simple trace
ITmfTreeXYDataProvider<@NonNull ITmfTreeDataModel> provider = XYFactory.create(trace);
assertNotNull(provider);
assertEquals(DataDrivenXYDataProvider.ID, provider.getId());
// Test the factory with an ID and state system
ITmfAnalysisModuleWithStateSystems module = TmfTraceUtils.getAnalysisModuleOfClass(trace, ITmfAnalysisModuleWithStateSystems.class, ANALYSIS_ID);
assertNotNull(module);
Iterable<@NonNull ITmfStateSystem> stateSystems = module.getStateSystems();
assertNotNull(stateSystems);
provider = DataDrivenXYProviderFactory.create(trace, Objects.requireNonNull(Lists.newArrayList(stateSystems)), getEntries(new AnalysisCompilationData(), viewElement), ANALYSIS_ID);
assertNotNull(provider);
assertEquals(ANALYSIS_ID, provider.getId());
} finally {
trace.dispose();
TmfTraceManager.getInstance().traceClosed(new TmfTraceClosedSignal(this, trace));
}
}
Aggregations