Skip to content

Commit

Permalink
linux.core: Add priority/thread name statistics data provider factory
Browse files Browse the repository at this point in the history
This commit creates a new data provider for the new priority/thread name
statistics analysis by extending the
AbstractSegmentStoreStatisticsDataProviderFactory class. The data
provider has a private class called PriorityThreadNameStatisticsAnalysis
which specifies that entries for the priority/thread name statistics
analysis should be grouped by priority and thread name.

[Added] Data provider factory for priority/thread name statistics
analysis

Change-Id: Id5ad6a8301e1188916f0abc40006c11045b54976
Signed-off-by: Hoang Thuan Pham <hoang.pham@calian.ca>
Reviewed-on: https://git.eclipse.org/r/c/tracecompass/org.eclipse.tracecompass/+/204382
Tested-by: Trace Compass Bot <tracecompass-bot@eclipse.org>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
  • Loading branch information
hoangphamEclipse authored and MatthewKhouzam committed Oct 10, 2023
1 parent 32f3220 commit 34d2520
Show file tree
Hide file tree
Showing 5 changed files with 162 additions and 1 deletion.
Expand Up @@ -64,6 +64,7 @@ Export-Package: org.eclipse.tracecompass.analysis.os.linux.core.contextswitch,
org.eclipse.tracecompass.lttng2.kernel.core.tests,
org.eclipse.tracecompass.analysis.callstack.core.tests",
org.eclipse.tracecompass.internal.analysis.os.linux.core.resourcesstatus;x-friends:="org.eclipse.tracecompass.analysis.os.linux.ui",
org.eclipse.tracecompass.internal.analysis.os.linux.core.segmentstore;x-internal:=true,
org.eclipse.tracecompass.internal.analysis.os.linux.core.threadstatus;
x-friends:="org.eclipse.tracecompass.analysis.callstack.core,
org.eclipse.tracecompass.analysis.os.linux.core.tests,
Expand Down
@@ -0,0 +1,49 @@
/**********************************************************************
* 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
**********************************************************************/

package org.eclipse.tracecompass.internal.analysis.os.linux.core.segmentstore;

import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.osgi.util.NLS;

/**
* Message bundle for the segment store analysis module
*
* @author Hoang Thuan Pham
*/
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.tracecompass.internal.analysis.os.linux.core.segmentstore.messages"; //$NON-NLS-1$

/**
* Name of the Priority/Thread name data provider
*/
public static @Nullable String PriorityThreadNameStatisticsDataProviderFactory_AnalysisName;
/**
* Title of the Priority/Thread name data provider
*/
public static @Nullable String PriorityThreadNameStatisticsDataProviderFactory_title;
/**
* Description of the Priority/Thread name data provider
*/
public static @Nullable String PriorityThreadNameStatisticsDataProviderFactory_description;
/**
* The segment type format of the PriorityThreadNameStatisticsAnalysis
*/
public static @Nullable String PriorityThreadNameStatisticsAnalysis_segmentType;

static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
}

private Messages() {
}
}
@@ -0,0 +1,95 @@
/**********************************************************************
* 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
**********************************************************************/

package org.eclipse.tracecompass.internal.analysis.os.linux.core.segmentstore;

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.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.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.
*
* @author Hoang Thuan Pham
*/
public class PriorityThreadNameStatisticsDataProviderFactory extends AbstractSegmentStoreStatisticsDataProviderFactory {

/**
* The data provider ID
*/
public static final String DATA_PROVIDER_ID = "org.eclipse.tracecompass.internal.analysis.os.linux.core.segmentstore.PriorityThreadNameStatisticsDataProvider"; //$NON-NLS-1$

/**
* To extend another data provider, create an analysis that extends
* {@link GenericSegmentStatisticsAnalysis} and override the
* getSegmentType method again to specify how entries should be grouped for the
* statistics.
*/
private final class PriorityThreadNameStatisticsAnalysis extends GenericSegmentStatisticsAnalysis {
/**
* Constructor
*
* @param secondaryId The ID of the analysis which generates the segment store
*/
private PriorityThreadNameStatisticsAnalysis(String secondaryId) {
super(secondaryId);
}

@Override
protected @Nullable String getSegmentType(@NonNull ISegment segment) {
if ((segment instanceof INamedSegment) && (segment instanceof IPrioritySegment)) {
return NLS.bind(Messages.PriorityThreadNameStatisticsAnalysis_segmentType, ((IPrioritySegment) segment).getPriority(), ((INamedSegment) segment).getName());
}
return null;
}
}

@Override
protected AbstractSegmentStatisticsAnalysis getAnalysis(String analysisId) {
/**
* Return the {@link AbstractSegmentStatisticsAnalysis} that has the new
* getSegmentType logic to bind it to the data provider.
*/
return new PriorityThreadNameStatisticsAnalysis(analysisId);
}

@Override
protected String getDataProviderId() {
return DATA_PROVIDER_ID;
}

@Override
protected void setStatisticsAnalysisModuleName(AbstractSegmentStatisticsAnalysis statisticsAnalysisModule, IAnalysisModule baseAnalysisModule) {
statisticsAnalysisModule.setName(Objects.requireNonNull(NLS.bind(Messages.PriorityThreadNameStatisticsDataProviderFactory_AnalysisName, baseAnalysisModule.getName())));
}

@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;
}
}
@@ -0,0 +1,15 @@
###############################################################################
# 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
###############################################################################

PriorityThreadNameStatisticsDataProviderFactory_AnalysisName=Priority/Thread name Statistics for {0}
PriorityThreadNameStatisticsDataProviderFactory_title={0} - Priority/Thread name Statistics Table
PriorityThreadNameStatisticsDataProviderFactory_description=Show Priority/Thread name Statistics Table provided by {0}
PriorityThreadNameStatisticsAnalysis_segmentType=Prio: {0}; {1}
Expand Up @@ -25,7 +25,8 @@ Export-Package: org.eclipse.tracecompass.analysis.timing.core.segmentstore,
org.eclipse.tracecompass.analysis.timing.ui,
org.eclipse.tracecompass.tmf.analysis.xml.core,
org.eclipse.tracecompass.analysis.profiling.core,
org.eclipse.tracecompass.tmf.analysis.xml.ui",
org.eclipse.tracecompass.tmf.analysis.xml.ui,
org.eclipse.tracecompass.analysis.os.linux.core",
org.eclipse.tracecompass.internal.analysis.timing.core.segmentstore.statistics;x-friends:="org.eclipse.tracecompass.analysis.timing.core.tests"
Import-Package: com.google.common.annotations,
com.google.common.base,
Expand Down

0 comments on commit 34d2520

Please sign in to comment.