-
Notifications
You must be signed in to change notification settings - Fork 12
/
PriorityThreadNameStatisticsDataProviderFactory.java
95 lines (84 loc) · 4.4 KB
/
PriorityThreadNameStatisticsDataProviderFactory.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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;
}
}