Search in sources :

Example 1 with Status

use of org.eclipse.tracecompass.tmf.core.response.ITmfResponse.Status 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);
}
Also used : Status(org.eclipse.tracecompass.tmf.core.response.ITmfResponse.Status) Builder(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.module.XmlTimeGraphEntryModel.Builder) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) TmfModelResponse(org.eclipse.tracecompass.tmf.core.response.TmfModelResponse) NonNull(org.eclipse.jdt.annotation.NonNull) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)

Example 2 with Status

use of org.eclipse.tracecompass.tmf.core.response.ITmfResponse.Status in project tracecompass by tracecompass.

the class StateSystemDataProvider method fetchTree.

@Override
@NonNull
public TmfModelResponse<TmfTreeModel<TimeGraphEntryModel>> fetchTree(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
    // need to create the tree
    boolean fetchTreeIsComplete;
    synchronized (fEntryBuilder) {
        fModuleEntryModelList.clear();
        fetchTreeIsComplete = addTrace(monitor);
        if (monitor != null && monitor.isCanceled()) {
            return new TmfModelResponse<>(null, Status.CANCELLED, CommonStatusMessage.TASK_CANCELLED);
        }
    }
    List<TimeGraphEntryModel> entryList = buildEntryList(monitor);
    Status status = fetchTreeIsComplete ? Status.COMPLETED : Status.RUNNING;
    String msg = fetchTreeIsComplete ? CommonStatusMessage.COMPLETED : CommonStatusMessage.RUNNING;
    return new TmfModelResponse<>(new TmfTreeModel<>(Collections.emptyList(), entryList), status, msg);
}
Also used : Status(org.eclipse.tracecompass.tmf.core.response.ITmfResponse.Status) TimeGraphEntryModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel) TmfModelResponse(org.eclipse.tracecompass.tmf.core.response.TmfModelResponse) NonNull(org.eclipse.jdt.annotation.NonNull)

Example 3 with Status

use of org.eclipse.tracecompass.tmf.core.response.ITmfResponse.Status in project tracecompass by tracecompass.

the class ExampleTimeGraphDataProvider method fetchTree.

@Override
public TmfModelResponse<TmfTreeModel<@NonNull ITimeGraphEntryModel>> fetchTree(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
    fModule.waitForInitialization();
    ITmfStateSystem ss = fModule.getStateSystem();
    if (ss == null) {
        return new TmfModelResponse<>(null, ITmfResponse.Status.FAILED, CommonStatusMessage.ANALYSIS_INITIALIZATION_FAILED);
    }
    boolean isComplete = ss.waitUntilBuilt(0);
    long endTime = ss.getCurrentEndTime();
    // Make an entry for each base quark
    List<ITimeGraphEntryModel> entryList = new ArrayList<>();
    for (Integer quark : ss.getQuarks("CPUs", "*")) {
        // $NON-NLS-1$ //$NON-NLS-2$
        Long id = fIDToDisplayQuark.inverse().computeIfAbsent(quark, q -> sfAtomicId.getAndIncrement());
        entryList.add(new TimeGraphEntryModel(id, -1, ss.getAttributeName(quark), ss.getStartTime(), endTime));
    }
    Status status = isComplete ? Status.COMPLETED : Status.RUNNING;
    String msg = isComplete ? CommonStatusMessage.COMPLETED : CommonStatusMessage.RUNNING;
    return new TmfModelResponse<>(new TmfTreeModel<>(Collections.emptyList(), entryList), status, msg);
}
Also used : Status(org.eclipse.tracecompass.tmf.core.response.ITmfResponse.Status) ArrayList(java.util.ArrayList) TmfModelResponse(org.eclipse.tracecompass.tmf.core.response.TmfModelResponse) ITimeGraphEntryModel(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphEntryModel) TimeGraphEntryModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel) AtomicLong(java.util.concurrent.atomic.AtomicLong) ITimeGraphEntryModel(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphEntryModel) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)

Example 4 with Status

use of org.eclipse.tracecompass.tmf.core.response.ITmfResponse.Status in project tracecompass by tracecompass.

the class DataDrivenTimeGraphDataProvider method fetchTree.

@Override
public final TmfModelResponse<TmfTreeModel<@NonNull TimeGraphEntryModel>> fetchTree(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
    List<TimeGraphEntryModel> 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());
            TimeGraphEntryModel ssEntry = new TimeGraphEntryModel(id, -1, traceName, start, end);
            entryList.add(ssEntry);
            for (DataDrivenOutputEntry entry : fEntries) {
                entryList.addAll(entry.buildEntries(ss, ssEntry.getId(), getTrace(), -1, StringUtils.EMPTY, end, fIdGenerator, fQuarkCallback));
            }
        }
    }
    Status status = isComplete ? Status.COMPLETED : Status.RUNNING;
    String msg = isComplete ? CommonStatusMessage.COMPLETED : CommonStatusMessage.RUNNING;
    TmfTreeModel<@NonNull TimeGraphEntryModel> tree = new TmfTreeModel<>(Collections.emptyList(), entryList);
    return new TmfModelResponse<>(tree, status, msg);
}
Also used : Status(org.eclipse.tracecompass.tmf.core.response.ITmfResponse.Status) TimeGraphEntryModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel) ArrayList(java.util.ArrayList) TmfTreeModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel) TmfModelResponse(org.eclipse.tracecompass.tmf.core.response.TmfModelResponse) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)

Aggregations

Status (org.eclipse.tracecompass.tmf.core.response.ITmfResponse.Status)4 TmfModelResponse (org.eclipse.tracecompass.tmf.core.response.TmfModelResponse)4 ArrayList (java.util.ArrayList)3 ITmfStateSystem (org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)3 TimeGraphEntryModel (org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel)3 NonNull (org.eclipse.jdt.annotation.NonNull)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 Builder (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.module.XmlTimeGraphEntryModel.Builder)1 ITimeGraphEntryModel (org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphEntryModel)1 TmfTreeModel (org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel)1 Element (org.w3c.dom.Element)1