Skip to content

Commit

Permalink
os.linux: Show latency data providers per priority only when applicable
Browse files Browse the repository at this point in the history
For that, add check for SWSLatencyAnalysis instance before returning
the data provider descriptor, in case of the SWS latency statistics
per priority and thread.

Let method getDataProviderDescriptor(analysis) of abstract class
AbstractSegmentStoreStatisticsDataProviderFactory return an
IDataProviderDescriptor instead DataProviderDescriptor.Builder, and
update all extending classes of this abstract class.

Change-Id: I61b92ba134eeca2c5b5cdb6c8f9dfa5d458a2756
Signed-off-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/c/tracecompass/org.eclipse.tracecompass/+/205078
Tested-by: Trace Compass Bot <tracecompass-bot@eclipse.org>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
  • Loading branch information
bhufmann committed Oct 24, 2023
1 parent a3cdf30 commit 5676585
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 32 deletions.
Expand Up @@ -13,18 +13,18 @@

import java.util.Objects;

import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.osgi.util.NLS;
import org.eclipse.tracecompass.analysis.os.linux.core.swslatency.SWSLatencyAnalysis;
import org.eclipse.tracecompass.analysis.timing.core.segmentstore.GenericSegmentStatisticsAnalysis;
import org.eclipse.tracecompass.analysis.timing.core.segmentstore.statistics.AbstractSegmentStatisticsAnalysis;
import org.eclipse.tracecompass.internal.analysis.timing.core.segmentstore.AbstractSegmentStoreStatisticsDataProviderFactory;
import org.eclipse.tracecompass.segmentstore.core.ISegment;
import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule;
import org.eclipse.tracecompass.tmf.core.component.DataProviderConstants;
import org.eclipse.tracecompass.tmf.core.dataprovider.IDataProviderDescriptor;
import org.eclipse.tracecompass.tmf.core.dataprovider.IDataProviderDescriptor.ProviderType;
import org.eclipse.tracecompass.tmf.core.model.DataProviderDescriptor;
import org.eclipse.tracecompass.tmf.core.model.DataProviderDescriptor.Builder;

/**
* A data provider factory for Priority Statistics analysis.
Expand All @@ -51,7 +51,7 @@ private PriorityStatisticsAnalysis(String secondaryId) {
}

@Override
protected @Nullable String getSegmentType(@NonNull ISegment segment) {
protected @Nullable String getSegmentType(ISegment segment) {
if (segment instanceof IPrioritySegment) {
// The segment type is the priority of the segment
return NLS.bind(Messages.PriorityStatisticsAnalysis_segmentType, ((IPrioritySegment) segment).getPriority());
Expand Down Expand Up @@ -80,12 +80,15 @@ protected void setStatisticsAnalysisModuleName(AbstractSegmentStatisticsAnalysis
}

@Override
protected Builder getDataProviderDescriptor(IAnalysisModule analysis) {
DataProviderDescriptor.Builder builder = new DataProviderDescriptor.Builder();
builder.setId(DATA_PROVIDER_ID + DataProviderConstants.ID_SEPARATOR + analysis.getId())
.setName(Objects.requireNonNull(NLS.bind(Messages.PriorityStatisticsDataProviderFactory_title, analysis.getName())))
.setDescription(Objects.requireNonNull(NLS.bind(Messages.PriorityStatisticsDataProviderFactory_description, analysis.getHelpText())))
.setProviderType(ProviderType.DATA_TREE);
return builder;
protected @Nullable IDataProviderDescriptor getDataProviderDescriptor(IAnalysisModule analysis) {
if (analysis instanceof SWSLatencyAnalysis) {
DataProviderDescriptor.Builder builder = new DataProviderDescriptor.Builder();
builder.setId(DATA_PROVIDER_ID + DataProviderConstants.ID_SEPARATOR + analysis.getId())
.setName(Objects.requireNonNull(NLS.bind(Messages.PriorityStatisticsDataProviderFactory_title, analysis.getName())))
.setDescription(Objects.requireNonNull(NLS.bind(Messages.PriorityStatisticsDataProviderFactory_description, analysis.getHelpText())))
.setProviderType(ProviderType.DATA_TREE);
return builder.build();
}
return null;
}
}
Expand Up @@ -13,19 +13,19 @@

import java.util.Objects;

import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.osgi.util.NLS;
import org.eclipse.tracecompass.analysis.os.linux.core.swslatency.SWSLatencyAnalysis;
import org.eclipse.tracecompass.analysis.timing.core.segmentstore.GenericSegmentStatisticsAnalysis;
import org.eclipse.tracecompass.analysis.timing.core.segmentstore.statistics.AbstractSegmentStatisticsAnalysis;
import org.eclipse.tracecompass.internal.analysis.timing.core.segmentstore.AbstractSegmentStoreStatisticsDataProviderFactory;
import org.eclipse.tracecompass.segmentstore.core.ISegment;
import org.eclipse.tracecompass.segmentstore.core.segment.interfaces.INamedSegment;
import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule;
import org.eclipse.tracecompass.tmf.core.component.DataProviderConstants;
import org.eclipse.tracecompass.tmf.core.dataprovider.IDataProviderDescriptor;
import org.eclipse.tracecompass.tmf.core.dataprovider.IDataProviderDescriptor.ProviderType;
import org.eclipse.tracecompass.tmf.core.model.DataProviderDescriptor;
import org.eclipse.tracecompass.tmf.core.model.DataProviderDescriptor.Builder;

/**
* A data provider factory for Priority/Thread name statistics analysis.
Expand Down Expand Up @@ -56,7 +56,7 @@ private PriorityThreadNameStatisticsAnalysis(String secondaryId) {
}

@Override
protected @Nullable String getSegmentType(@NonNull ISegment segment) {
protected @Nullable String getSegmentType(ISegment segment) {
if ((segment instanceof INamedSegment) && (segment instanceof IPrioritySegment)) {
return NLS.bind(Messages.PriorityThreadNameStatisticsAnalysis_segmentType, ((IPrioritySegment) segment).getPriority(), ((INamedSegment) segment).getName());
}
Expand Down Expand Up @@ -84,12 +84,15 @@ protected void setStatisticsAnalysisModuleName(AbstractSegmentStatisticsAnalysis
}

@Override
protected Builder getDataProviderDescriptor(IAnalysisModule analysis) {
DataProviderDescriptor.Builder builder = new DataProviderDescriptor.Builder();
builder.setId(DATA_PROVIDER_ID + DataProviderConstants.ID_SEPARATOR + analysis.getId())
.setName(Objects.requireNonNull(NLS.bind(Messages.PriorityThreadNameStatisticsDataProviderFactory_title, analysis.getName())))
.setDescription(Objects.requireNonNull(NLS.bind(Messages.PriorityThreadNameStatisticsDataProviderFactory_description, analysis.getHelpText())))
.setProviderType(ProviderType.DATA_TREE);
return builder;
protected @Nullable IDataProviderDescriptor getDataProviderDescriptor(IAnalysisModule analysis) {
if (analysis instanceof SWSLatencyAnalysis) {
DataProviderDescriptor.Builder builder = new DataProviderDescriptor.Builder();
builder.setId(DATA_PROVIDER_ID + DataProviderConstants.ID_SEPARATOR + analysis.getId())
.setName(Objects.requireNonNull(NLS.bind(Messages.PriorityThreadNameStatisticsDataProviderFactory_title, analysis.getName())))
.setDescription(Objects.requireNonNull(NLS.bind(Messages.PriorityThreadNameStatisticsDataProviderFactory_description, analysis.getHelpText())))
.setProviderType(ProviderType.DATA_TREE);
return builder.build();
}
return null;
}
}
@@ -0,0 +1,13 @@
/*******************************************************************************
* Copyright (c) 2023 Ericsson
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/

@org.eclipse.jdt.annotation.NonNullByDefault
package org.eclipse.tracecompass.internal.analysis.os.linux.core.segmentstore;
Expand Up @@ -24,7 +24,6 @@
import org.eclipse.tracecompass.tmf.core.dataprovider.IDataProviderDescriptor;
import org.eclipse.tracecompass.tmf.core.dataprovider.IDataProviderFactory;
import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
import org.eclipse.tracecompass.tmf.core.model.DataProviderDescriptor;
import org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel;
import org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataProvider;
import org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeCompositeDataProvider;
Expand Down Expand Up @@ -85,9 +84,11 @@ public Collection<IDataProviderDescriptor> getDescriptors(ITmfTrace trace) {
IAnalysisModule analysis = (IAnalysisModule) module;
// Only add analysis once per trace (which could be an experiment)
if (!existingModules.contains(analysis.getId())) {
DataProviderDescriptor.Builder builder = getDataProviderDescriptor(analysis);
descriptors.add(builder.build());
existingModules.add(analysis.getId());
IDataProviderDescriptor descriptor = getDataProviderDescriptor(analysis);
if (descriptor != null) {
descriptors.add(descriptor);
existingModules.add(analysis.getId());
}
}
}
return descriptors;
Expand Down Expand Up @@ -125,13 +126,13 @@ public Collection<IDataProviderDescriptor> getDescriptors(ITmfTrace trace) {
protected abstract void setStatisticsAnalysisModuleName(AbstractSegmentStatisticsAnalysis statisticsAnalysisModule, IAnalysisModule baseAnalysisModule);

/**
* Get the data provider descriptor
* Get the data provider descriptor. Only return a descriptor if the
* analysis is applicable for that factory.
*
* @param analysis
* The base analysis on which the statistics are based on.
* @return A
* {@link org.eclipse.tracecompass.tmf.core.model.DataProviderDescriptor.Builder}
* that contains the data provider information
* @return A {@link IDataProviderDescriptor} that contains the data provider
* information or null if not applicable for this analysis module
*/
protected abstract DataProviderDescriptor.Builder getDataProviderDescriptor(IAnalysisModule analysis);
protected abstract @Nullable IDataProviderDescriptor getDataProviderDescriptor(IAnalysisModule analysis);
}
Expand Up @@ -13,14 +13,15 @@

import java.util.Objects;

import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.osgi.util.NLS;
import org.eclipse.tracecompass.analysis.timing.core.segmentstore.GenericSegmentStatisticsAnalysis;
import org.eclipse.tracecompass.analysis.timing.core.segmentstore.statistics.AbstractSegmentStatisticsAnalysis;
import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule;
import org.eclipse.tracecompass.tmf.core.component.DataProviderConstants;
import org.eclipse.tracecompass.tmf.core.dataprovider.IDataProviderDescriptor;
import org.eclipse.tracecompass.tmf.core.dataprovider.IDataProviderDescriptor.ProviderType;
import org.eclipse.tracecompass.tmf.core.model.DataProviderDescriptor;
import org.eclipse.tracecompass.tmf.core.model.DataProviderDescriptor.Builder;

/**
* Generalized {@link SegmentStoreStatisticsDataProvider} factory using
Expand Down Expand Up @@ -49,12 +50,12 @@ protected void setStatisticsAnalysisModuleName(AbstractSegmentStatisticsAnalysis
}

@Override
protected Builder getDataProviderDescriptor(IAnalysisModule analysis) {
protected @Nullable IDataProviderDescriptor getDataProviderDescriptor(IAnalysisModule analysis) {
DataProviderDescriptor.Builder builder = new DataProviderDescriptor.Builder();
builder.setId(SegmentStoreStatisticsDataProvider.ID + DataProviderConstants.ID_SEPARATOR + analysis.getId())
.setName(Objects.requireNonNull(NLS.bind(Messages.SegmentStoreStatisticsDataProvider_title, analysis.getName())))
.setDescription(Objects.requireNonNull(NLS.bind(Messages.SegmentStoreStatisticsDataProvider_description, analysis.getHelpText())))
.setProviderType(ProviderType.DATA_TREE);
return builder;
return builder.build();
}
}

0 comments on commit 5676585

Please sign in to comment.