use of org.eclipse.tracecompass.statesystem.core.ITmfStateSystem in project tracecompass by tracecompass.
the class IAnalysisDataContainer method getQuarkAbsoluteAndAdd.
/**
* Basic quark-retrieving method. Pass an attribute in parameter as an array of
* strings, the matching quark will be returned. If the attribute does not
* exist, it will add the quark to the state system if the context allows it.
* Otherwise a negative value will be returned.
*
* See {@link ITmfStateSystemBuilder#getQuarkAbsoluteAndAdd(String...)}
*
* @param path
* Full path to the attribute
* @return The quark for this attribute
*/
default int getQuarkAbsoluteAndAdd(String... path) {
ITmfStateSystem stateSystem = getStateSystem();
int quark = stateSystem.optQuarkAbsolute(path);
if (quark == ITmfStateSystem.INVALID_ATTRIBUTE && !isReadOnlyContainer() && (stateSystem instanceof ITmfStateSystemBuilder)) {
quark = ((ITmfStateSystemBuilder) stateSystem).getQuarkAbsoluteAndAdd(path);
}
return quark;
}
use of org.eclipse.tracecompass.statesystem.core.ITmfStateSystem in project tracecompass by tracecompass.
the class XmlTimeGraphDataProvider method create.
/**
* {@link XmlTimeGraphDataProvider} create method
*
* @param trace
* the trace for which the provider will return data
* @param viewElement
* the XML view {@link Element}.
* @return the relevant {@link XmlTimeGraphDataProvider}
*/
public static XmlTimeGraphDataProvider create(@NonNull ITmfTrace trace, Element viewElement) {
Set<@NonNull String> analysisIds = TmfXmlUtils.getViewAnalysisIds(viewElement);
List<Element> entries = TmfXmlUtils.getChildElements(viewElement, TmfXmlStrings.ENTRY_ELEMENT);
Set<@NonNull ITmfAnalysisModuleWithStateSystems> stateSystemModules = new HashSet<>();
if (analysisIds.isEmpty()) {
/*
* No analysis specified, take all state system analysis modules
*/
Iterables.addAll(stateSystemModules, TmfTraceUtils.getAnalysisModulesOfClass(trace, ITmfAnalysisModuleWithStateSystems.class));
} else {
for (String moduleId : analysisIds) {
// Get the module for the current trace only. The caller will take care of
// generating composite providers with experiments
IAnalysisModule module = trace.getAnalysisModule(moduleId);
if (module instanceof ITmfAnalysisModuleWithStateSystems) {
stateSystemModules.add((ITmfAnalysisModuleWithStateSystems) module);
}
}
}
List<ITmfStateSystem> sss = new ArrayList<>();
for (ITmfAnalysisModuleWithStateSystems module : stateSystemModules) {
if (module.schedule().isOK() && module.waitForInitialization()) {
module.getStateSystems().forEach(sss::add);
}
}
return (sss.isEmpty() ? null : new XmlTimeGraphDataProvider(trace, sss, entries));
}
use of org.eclipse.tracecompass.statesystem.core.ITmfStateSystem in project tracecompass by tracecompass.
the class XmlTimeGraphDataProvider method fetchTree.
@Override
public TmfModelResponse<TmfTreeModel<@NonNull XmlTimeGraphEntryModel>> fetchTree(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
@NonNull List<@NonNull XmlTimeGraphEntryModel> entryList = new ArrayList<>();
boolean isComplete = true;
String traceName = String.valueOf(getTrace().getName());
for (ITmfStateSystem ss : fSs) {
isComplete &= ss.waitUntilBuilt(0);
/* Don't query empty state system */
if (ss.getNbAttributes() > 0 && ss.getStartTime() != Long.MIN_VALUE) {
long start = ss.getStartTime();
long end = ss.getCurrentEndTime();
long id = fBaseQuarkToId.row(ss).computeIfAbsent(ITmfStateSystem.ROOT_ATTRIBUTE, s -> sfAtomicId.getAndIncrement());
Builder ssEntry = new Builder(id, -1, Collections.singletonList(traceName), start, end, null, ss, ITmfStateSystem.ROOT_ATTRIBUTE, fCompilationData);
entryList.add(ssEntry.build());
for (Element entry : fEntries) {
buildEntry(ss, entry, ssEntry, -1, StringUtils.EMPTY, end, entryList);
}
}
}
Status status = isComplete ? Status.COMPLETED : Status.RUNNING;
String msg = isComplete ? CommonStatusMessage.COMPLETED : CommonStatusMessage.RUNNING;
return new TmfModelResponse<>(new TmfTreeModel<>(Collections.emptyList(), entryList), status, msg);
}
use of org.eclipse.tracecompass.statesystem.core.ITmfStateSystem in project tracecompass by tracecompass.
the class XmlTimeGraphDataProvider method fetchRowModel.
@Override
@NonNull
public TmfModelResponse<@NonNull TimeGraphModel> fetchRowModel(@NonNull Map<@NonNull String, @NonNull Object> fetchParameters, @Nullable IProgressMonitor monitor) {
Table<ITmfStateSystem, Integer, Long> table = HashBasedTable.create();
// TODO server: Parameters validation should be handle separately. It
// can be either in the data provider itself or before calling it. It
// will avoid the creation of filters and the content of the map can be
// use directly.
SelectionTimeQueryFilter filter = FetchParametersUtils.createSelectionTimeQuery(fetchParameters);
if (filter == null) {
return new TmfModelResponse<>(null, ITmfResponse.Status.FAILED, CommonStatusMessage.INCORRECT_QUERY_PARAMETERS);
}
for (Long id : filter.getSelectedItems()) {
Pair<ITmfStateSystem, Integer> pair = fIDToDisplayQuark.get(id);
if (pair != null) {
table.put(pair.getFirst(), pair.getSecond(), id);
}
}
List<@NonNull ITimeGraphRowModel> allRows = new ArrayList<>();
try {
for (Entry<ITmfStateSystem, Map<Integer, Long>> ssEntry : table.rowMap().entrySet()) {
Collection<@NonNull ITimeGraphRowModel> rows = createRows(ssEntry.getKey(), ssEntry.getValue(), filter.getTimesRequested(), fetchParameters, monitor);
allRows.addAll(rows);
}
} catch (IndexOutOfBoundsException | TimeRangeException | StateSystemDisposedException e) {
return new TmfModelResponse<>(null, Status.FAILED, CommonStatusMessage.STATE_SYSTEM_FAILED);
}
return new TmfModelResponse<>(new TimeGraphModel(allRows), Status.COMPLETED, CommonStatusMessage.COMPLETED);
}
use of org.eclipse.tracecompass.statesystem.core.ITmfStateSystem in project tracecompass by tracecompass.
the class XmlXYDataProvider method fetchXY.
@Override
public TmfModelResponse<ITmfXyModel> fetchXY(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
DataDrivenStateSystemPath display = fDisplay;
XmlXYEntry entry = fXmlEntry;
ITmfStateSystem ss = entry.getStateSystem();
TimeQueryFilter filter = FetchParametersUtils.createTimeQuery(fetchParameters);
if (filter == null) {
return TmfXyResponseFactory.createFailedResponse(CommonStatusMessage.INCORRECT_QUERY_PARAMETERS);
}
long[] xValues = filter.getTimesRequested();
Map<Integer, IYModel> map = initSeries(fetchParameters);
if (map.isEmpty()) {
return TmfXyResponseFactory.create(TITLE, xValues, Collections.emptyList(), true);
}
long currentEnd = ss.getCurrentEndTime();
try {
for (int i = 0; i < xValues.length; i++) {
if (monitor != null && monitor.isCanceled()) {
return TmfXyResponseFactory.createCancelledResponse(CommonStatusMessage.TASK_CANCELLED);
}
long time = xValues[i];
if (time > currentEnd) {
break;
} else if (ss.getStartTime() <= time) {
List<@NonNull ITmfStateInterval> full = ss.queryFullState(time);
for (Entry<Integer, IYModel> series : map.entrySet()) {
int attributeQuark = display.getQuark(series.getKey(), entry);
if (attributeQuark >= 0 && attributeQuark < full.size()) {
Object value = full.get(attributeQuark).getValue();
series.getValue().getData()[i] = extractValue(value);
}
}
}
}
// Update the series value if delta is requested
for (Entry<Integer, IYModel> series : map.entrySet()) {
if (entry.getType().equals(DisplayType.DELTA)) {
getSeriesDelta(series.getValue().getData());
}
}
} catch (StateSystemDisposedException e) {
return TmfXyResponseFactory.createFailedResponse(e.getMessage());
}
boolean complete = ss.waitUntilBuilt(0) || filter.getEnd() <= currentEnd;
return TmfXyResponseFactory.create(TITLE, xValues, map.values(), complete);
}
Aggregations