use of org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel in project tracecompass by tracecompass.
the class BaseDataProviderTimeGraphView method zoomEntries.
@Override
protected void zoomEntries(@NonNull Iterable<@NonNull TimeGraphEntry> entries, long zoomStartTime, long zoomEndTime, long resolution, boolean fullSearch, @NonNull IProgressMonitor monitor) {
if (resolution < 0) {
// StateSystemUtils.getTimes would throw an illegal argument exception.
return;
}
long start = Long.min(zoomStartTime, zoomEndTime);
long end = Long.max(zoomStartTime, zoomEndTime);
Sampling sampling = new Sampling(start, end, resolution);
Multimap<ITimeGraphDataProvider<? extends TimeGraphEntryModel>, Long> providersToModelIds = filterGroupEntries(entries, zoomStartTime, zoomEndTime);
// $NON-NLS-1$
SubMonitor subMonitor = SubMonitor.convert(monitor, getClass().getSimpleName() + "#zoomEntries", providersToModelIds.size());
for (Entry<ITimeGraphDataProvider<? extends TimeGraphEntryModel>, Collection<Long>> entry : providersToModelIds.asMap().entrySet()) {
ITimeGraphDataProvider<? extends TimeGraphEntryModel> dataProvider = entry.getKey();
Map<@NonNull String, @NonNull Object> parameters = getFetchRowModelParameters(start, end, resolution, fullSearch, entry.getValue());
TmfModelResponse<TimeGraphModel> response = dataProvider.fetchRowModel(parameters, monitor);
TimeGraphModel model = response.getModel();
if (model != null) {
zoomEntries(fEntries.row(dataProvider), model.getRows(), response.getStatus() == ITmfResponse.Status.COMPLETED, sampling);
}
subMonitor.worked(1);
}
}
use of org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel in project tracecompass by tracecompass.
the class BaseDataProviderTimeGraphView method getViewMarkerList.
@Override
@NonNull
protected List<IMarkerEvent> getViewMarkerList(Iterable<@NonNull TimeGraphEntry> entries, long startTime, long endTime, long resolution, @NonNull IProgressMonitor monitor) {
List<IMarkerEvent> viewMarkerList = super.getViewMarkerList(startTime, endTime, resolution, monitor);
List<@NonNull TimeGraphEntry> traceEntries = getEntryList(getTrace());
if (traceEntries == null) {
return viewMarkerList;
}
List<@NonNull Long> times = StateSystemUtils.getTimes(startTime, endTime, resolution);
Multimap<ITimeGraphDataProvider<? extends TimeGraphEntryModel>, Long> providersToModelIds = filterGroupEntries(entries, startTime, endTime);
for (ITimeGraphDataProvider<? extends TimeGraphEntryModel> provider : providersToModelIds.keySet()) {
if (provider instanceof IOutputAnnotationProvider) {
List<String> categories = new ArrayList<>(fMarkerCategories.get(provider));
categories.removeIf(category -> !getTimeGraphViewer().isMarkerCategoryVisible(category));
if (categories.isEmpty()) {
continue;
}
Map<@NonNull String, @NonNull Object> parameters = getFetchAnnotationsParameters(times, providersToModelIds.get(provider));
parameters.put(DataProviderParameterUtils.REQUESTED_MARKER_CATEGORIES_KEY, categories);
TmfModelResponse<@NonNull AnnotationModel> response = ((IOutputAnnotationProvider) provider).fetchAnnotations(parameters, new NullProgressMonitor());
AnnotationModel model = response.getModel();
if (model != null) {
for (Entry<String, Collection<Annotation>> entry : model.getAnnotations().entrySet()) {
String category = entry.getKey();
for (Annotation annotation : entry.getValue()) {
if (annotation.getType() == AnnotationType.CHART) {
// If the annotation entry ID is -1 we want the
// marker to span across all entries
ITimeGraphEntry markerEntry = null;
if (annotation.getEntryId() != -1) {
synchronized (fEntries) {
markerEntry = fEntries.get(provider, annotation.getEntryId());
}
}
MarkerEvent markerEvent = new MarkerEvent(annotation, markerEntry, category, true);
viewMarkerList.add(markerEvent);
}
}
}
}
}
}
return viewMarkerList;
}
use of org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel in project tracecompass by tracecompass.
the class BaseDataProviderTimeGraphView method getViewMarkerCategories.
@Override
@NonNull
protected List<String> getViewMarkerCategories() {
List<String> viewMarkerCategories = super.getViewMarkerCategories();
Collection<ITimeGraphDataProvider<? extends @NonNull TimeGraphEntryModel>> providers = getProviders(getTrace());
if (providers.isEmpty()) {
return viewMarkerCategories;
}
for (ITimeGraphDataProvider<? extends TimeGraphEntryModel> provider : providers) {
if (provider instanceof IOutputAnnotationProvider) {
Map<@NonNull String, @NonNull Object> parameters = getFetchAnnotationCategoriesParameters();
TmfModelResponse<@NonNull AnnotationCategoriesModel> response = ((IOutputAnnotationProvider) provider).fetchAnnotationCategories(parameters, new NullProgressMonitor());
AnnotationCategoriesModel model = response.getModel();
if (model != null) {
List<@NonNull String> categories = model.getAnnotationCategories();
viewMarkerCategories.addAll(categories);
fMarkerCategories.put(provider, categories);
}
}
}
return viewMarkerCategories;
}
use of org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel in project tracecompass by tracecompass.
the class BaseDataProviderTimeGraphView method buildEntryList.
@Override
protected void buildEntryList(@NonNull ITmfTrace trace, @NonNull ITmfTrace parentTrace, @NonNull IProgressMonitor monitor) {
ITimeGraphDataProvider<@NonNull TimeGraphEntryModel> dataProvider = DataProviderManager.getInstance().getDataProvider(trace, getProviderId(), ITimeGraphDataProvider.class);
if (dataProvider == null) {
return;
}
ITimeGraphPresentationProvider presentationProvider = getPresentationProvider();
if (presentationProvider instanceof BaseDataProviderTimeGraphPresentationProvider) {
((BaseDataProviderTimeGraphPresentationProvider) presentationProvider).addProvider(dataProvider, getTooltipResolver(dataProvider));
}
boolean complete = false;
while (!complete && !monitor.isCanceled()) {
Map<@NonNull String, @NonNull Object> parameters = getFetchTreeParameters();
TmfModelResponse<TmfTreeModel<@NonNull TimeGraphEntryModel>> response = dataProvider.fetchTree(parameters, monitor);
if (response.getStatus() == ITmfResponse.Status.FAILED) {
// $NON-NLS-1$
Activator.getDefault().logError(getClass().getSimpleName() + " Data Provider failed: " + response.getStatusMessage());
return;
} else if (response.getStatus() == ITmfResponse.Status.CANCELLED) {
return;
}
complete = response.getStatus() == ITmfResponse.Status.COMPLETED;
double factor = 1.0;
TmfTreeModel<@NonNull TimeGraphEntryModel> model = response.getModel();
if (model != null) {
synchronized (fEntries) {
Object scope = (model.getScope() == null) ? dataProvider : model.getScope();
fProviders.put(parentTrace, dataProvider);
fScopes.put(parentTrace, scope);
/*
* The provider may send entries unordered and parents may
* not exist when child is constructor, we'll re-unite
* families at the end
*/
List<TimeGraphEntry> orphaned = new ArrayList<>();
Map<Long, AtomicInteger> indexMap = new HashMap<>();
for (TimeGraphEntryModel entry : model.getEntries()) {
TimeGraphEntry uiEntry = fScopedEntries.get(scope, entry.getId());
if (entry.getParentId() != -1) {
if (uiEntry == null) {
uiEntry = new TimeGraphEntry(entry);
TimeGraphEntry parent = fScopedEntries.get(scope, entry.getParentId());
if (parent != null) {
// TODO: the order of children from different data providers is undefined
int index = indexMap.computeIfAbsent(entry.getParentId(), l -> new AtomicInteger()).getAndIncrement();
parent.addChild(index, uiEntry);
} else {
orphaned.add(uiEntry);
}
fScopedEntries.put(scope, entry.getId(), uiEntry);
} else {
indexMap.computeIfAbsent(entry.getParentId(), l -> new AtomicInteger()).getAndIncrement();
uiEntry.updateModel(entry);
}
} else {
if (entry.getStartTime() != Long.MIN_VALUE) {
setStartTime(Long.min(getStartTime(), entry.getStartTime()));
}
setEndTime(Long.max(getEndTime(), entry.getEndTime() + 1));
if (uiEntry != null) {
uiEntry.updateModel(entry);
} else {
// Do not assume that parentless entries are
// trace entries
uiEntry = new TraceEntry(entry, trace, dataProvider);
fScopedEntries.put(scope, entry.getId(), uiEntry);
addToEntryList(parentTrace, Collections.singletonList(uiEntry));
}
}
fEntries.put(dataProvider, entry.getId(), uiEntry);
fEntryIds.put(uiEntry, dataProvider, entry.getId());
}
// Find missing parents
// Orphans should be inserted before non-orphans
indexMap.clear();
for (TimeGraphEntry orphanedEntry : orphaned) {
TimeGraphEntry parent = fScopedEntries.get(scope, orphanedEntry.getEntryModel().getParentId());
if (parent != null) {
int index = indexMap.computeIfAbsent(parent.getEntryModel().getId(), l -> new AtomicInteger()).getAndIncrement();
parent.addChild(index, orphanedEntry);
}
}
}
long start = getStartTime();
long end = getEndTime();
final long resolution = Long.max(1, (end - start) / getDisplayWidth());
@NonNull Iterable<@NonNull TimeGraphEntry> entries;
synchronized (fEntries) {
entries = ImmutableList.copyOf(fEntries.values());
}
zoomEntries(entries, start, end, resolution, monitor);
}
if (monitor.isCanceled()) {
return;
}
if (parentTrace.equals(getTrace())) {
synchingToTime(getTimeGraphViewer().getSelectionBegin());
refresh();
}
monitor.worked(1);
if (!complete && !monitor.isCanceled()) {
try {
Thread.sleep((long) (BUILD_UPDATE_TIMEOUT * factor));
factor = Math.min(20, factor + 1);
} catch (InterruptedException e) {
// $NON-NLS-1$
Activator.getDefault().logError("Failed to wait for data provider", e);
Thread.currentThread().interrupt();
}
}
}
}
Aggregations