Search in sources :

Example 16 with TimeGraphEntryModel

use of org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel in project tracecompass by tracecompass.

the class XmlDataProviderManagerTest method testOneTraceWithExperimentAnalysis.

/**
 * Test getting the XML data provider for one trace, with an analysis that
 * applies to an experiment
 */
@Test
public void testOneTraceWithExperimentAnalysis() {
    ITmfTrace trace = null;
    try {
        // Initialize the trace and module
        trace = XmlUtilsTest.initializeTrace(TEST_TRACE);
        TmfTraceOpenedSignal signal = new TmfTraceOpenedSignal(this, trace, null);
        ((TmfTrace) trace).traceOpened(signal);
        // The data provider manager uses opened traces from the manager
        TmfTraceManager.getInstance().traceOpened(signal);
        // Get the view element from the file
        Element viewElement = TmfXmlUtils.getElementInFile(TmfXmlTestFiles.EXPERIMENT.getPath().toOSString(), TmfXmlStrings.TIME_GRAPH_VIEW, EXPERIMENT_VIEW_ID);
        assertNotNull(viewElement);
        ITimeGraphDataProvider<@NonNull TimeGraphEntryModel> timeGraphProvider = XmlDataProviderManager.getInstance().getTimeGraphProvider(trace, viewElement);
        assertNull(timeGraphProvider);
    } finally {
        if (trace != null) {
            trace.dispose();
            TmfTraceManager.getInstance().traceClosed(new TmfTraceClosedSignal(this, trace));
        }
    }
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfTrace(org.eclipse.tracecompass.tmf.core.trace.TmfTrace) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) Element(org.w3c.dom.Element) TimeGraphEntryModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel) TmfTraceOpenedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal) TmfTraceClosedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal) Test(org.junit.Test)

Example 17 with TimeGraphEntryModel

use of org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel 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 18 with TimeGraphEntryModel

use of org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel 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 19 with TimeGraphEntryModel

use of org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel in project tracecompass by tracecompass.

the class ActiveThreadsFilter method getOnCpuThreads.

@NonNull
private static Set<Long> getOnCpuThreads(@NonNull List<Range<Long>> cpuRanges, TmfTimeRange winRange, @NonNull ITmfTrace trace) {
    ThreadStatusDataProvider threadStatusProvider = DataProviderManager.getInstance().getDataProvider(trace, ThreadStatusDataProvider.ID, ThreadStatusDataProvider.class);
    if (threadStatusProvider == null) {
        return Collections.emptySet();
    }
    long beginTS = winRange.getStartTime().getValue();
    long endTS = winRange.getEndTime().getValue();
    @NonNull Set<@NonNull Long> cpus = new HashSet<>();
    for (Range<Long> range : cpuRanges) {
        for (long cpu = range.lowerEndpoint(); cpu <= range.upperEndpoint(); cpu++) {
            cpus.add(cpu);
        }
    }
    SelectionTimeQueryFilter filter = new SelectionTimeQueryFilter(beginTS, endTS, 2, cpus);
    Map<@NonNull String, @NonNull Object> parameters = FetchParametersUtils.selectionTimeQueryToMap(filter);
    parameters.put(ThreadStatusDataProvider.ACTIVE_THREAD_FILTER_KEY, true);
    TmfModelResponse<TmfTreeModel<@NonNull TimeGraphEntryModel>> response = threadStatusProvider.fetchTree(parameters, null);
    TmfTreeModel<@NonNull TimeGraphEntryModel> model = response.getModel();
    if (model == null) {
        return Collections.emptySet();
    }
    HashSet<Long> onCpuThreads = Sets.newHashSet(Iterables.transform(model.getEntries(), TimeGraphEntryModel::getId));
    return onCpuThreads == null ? Collections.emptySet() : onCpuThreads;
}
Also used : SelectionTimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter) NonNull(org.eclipse.jdt.annotation.NonNull) TimeGraphEntryModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel) TmfTreeModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel) ThreadStatusDataProvider(org.eclipse.tracecompass.internal.analysis.os.linux.core.threadstatus.ThreadStatusDataProvider) HashSet(java.util.HashSet) NonNull(org.eclipse.jdt.annotation.NonNull)

Example 20 with TimeGraphEntryModel

use of org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel in project tracecompass by tracecompass.

the class FlameChartView method getNextEventAction.

/**
 * Get the the next event action.
 *
 * @return The action object
 */
private Action getNextEventAction() {
    Action nextAction = fNextEventAction;
    if (nextAction == null) {
        Action superNextAction = getTimeGraphViewer().getNextEventAction();
        nextAction = new Action() {

            @Override
            public void run() {
                TimeGraphViewer viewer = getTimeGraphViewer();
                ITimeGraphEntry entry = viewer.getSelection();
                if (entry instanceof TimeGraphEntry) {
                    TimeGraphEntry callStackEntry = (TimeGraphEntry) entry;
                    ITimeGraphDataProvider<? extends TimeGraphEntryModel> provider = getProvider(callStackEntry);
                    long selectionBegin = viewer.getSelectionBegin();
                    SelectionTimeQueryFilter filter = new SelectionTimeQueryFilter(selectionBegin, Long.MAX_VALUE, 2, Collections.singleton(callStackEntry.getEntryModel().getId()));
                    TmfModelResponse<@NonNull TimeGraphModel> response = provider.fetchRowModel(FetchParametersUtils.selectionTimeQueryToMap(filter), null);
                    TimeGraphModel model = response.getModel();
                    if (model == null || model.getRows().size() != 1) {
                        return;
                    }
                    List<@NonNull ITimeGraphState> row = model.getRows().get(0).getStates();
                    if (row.size() != 1) {
                        return;
                    }
                    ITimeGraphState stackInterval = row.get(0);
                    if (stackInterval.getStartTime() <= selectionBegin && selectionBegin <= stackInterval.getStartTime() + stackInterval.getDuration()) {
                        viewer.setSelectedTimeNotify(stackInterval.getStartTime() + stackInterval.getDuration() + 1, true);
                    } else {
                        viewer.setSelectedTimeNotify(stackInterval.getStartTime(), true);
                    }
                    int stackLevel = stackInterval.getValue();
                    ITimeGraphEntry selectedEntry = callStackEntry.getParent().getChildren().get(Integer.max(0, stackLevel - 1));
                    viewer.setSelection(selectedEntry, true);
                    viewer.getTimeGraphControl().fireSelectionChanged();
                    startZoomThread(viewer.getTime0(), viewer.getTime1());
                }
            }
        };
        nextAction.setText(superNextAction.getText());
        nextAction.setToolTipText(superNextAction.getToolTipText());
        nextAction.setImageDescriptor(superNextAction.getImageDescriptor());
        fNextEventAction = nextAction;
    }
    return nextAction;
}
Also used : Action(org.eclipse.jface.action.Action) ITimeGraphDataProvider(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphDataProvider) TimeGraphModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphModel) TmfModelResponse(org.eclipse.tracecompass.tmf.core.response.TmfModelResponse) ITimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry) TimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry) ITimeGraphState(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphState) SelectionTimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter) ITimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry) TimeGraphEntryModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel) NonNull(org.eclipse.jdt.annotation.NonNull) Objects.requireNonNull(java.util.Objects.requireNonNull) TimeGraphViewer(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.TimeGraphViewer) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

TimeGraphEntryModel (org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel)29 NonNull (org.eclipse.jdt.annotation.NonNull)16 ArrayList (java.util.ArrayList)12 TmfTreeModel (org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel)11 TmfModelResponse (org.eclipse.tracecompass.tmf.core.response.TmfModelResponse)10 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)10 ITimeGraphDataProvider (org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphDataProvider)8 Element (org.w3c.dom.Element)8 ITmfStateSystem (org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)7 SelectionTimeQueryFilter (org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter)7 TmfTraceClosedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal)7 Test (org.junit.Test)7 HashMap (java.util.HashMap)6 List (java.util.List)6 ITimeGraphEntry (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry)6 Collection (java.util.Collection)5 TimeQueryFilter (org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter)5 TimeGraphModel (org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphModel)5 TimeGraphEntry (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry)5 Status (org.eclipse.tracecompass.tmf.core.response.ITmfResponse.Status)4