Skip to content

Commit 87a6529

Browse files
committed
counter.core: Generalize the counterAnalysis to take ITmfCounterAspect
[Changed] Allowed ITmfCounterAspect populate counterAnalysis Signed-off-by: Reza Rouhghalandari <reza.rouhghalandari@ericsson.com>
1 parent c8509f5 commit 87a6529

File tree

5 files changed

+54
-20
lines changed

5 files changed

+54
-20
lines changed

analysis/org.eclipse.tracecompass.analysis.counters.core/META-INF/MANIFEST.MF

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: %Bundle-Name
44
Bundle-Vendor: %Bundle-Vendor
5-
Bundle-Version: 2.2.1.qualifier
5+
Bundle-Version: 2.3.0.qualifier
66
Bundle-Localization: plugin
77
Bundle-SymbolicName: org.eclipse.tracecompass.analysis.counters.core;singleton:=true
88
Bundle-Activator: org.eclipse.tracecompass.internal.analysis.counters.core.Activator
99
Bundle-ActivationPolicy: lazy
10-
Bundle-RequiredExecutionEnvironment: JavaSE-11
10+
Bundle-RequiredExecutionEnvironment: JavaSE-11,
11+
JavaSE-21
1112
Require-Bundle: org.eclipse.core.runtime,
1213
org.eclipse.core.resources,
1314
org.eclipse.tracecompass.common.core,

analysis/org.eclipse.tracecompass.analysis.counters.core/src/org/eclipse/tracecompass/analysis/counters/core/CounterStateProvider.java

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ public static CounterStateProvider create(ITmfTrace trace) {
7676
Iterable<ITmfEventAspect<?>> counterAspects = TmfTraceUtils.getEventAspects(trace, ITmfCounterAspect.class);
7777
for (ITmfEventAspect<?> counter : counterAspects) {
7878

79-
if (counter instanceof CounterAspect) {
80-
CounterAspect counterAspect = (CounterAspect) counter;
79+
if (counter instanceof ITmfCounterAspect) {
80+
ITmfCounterAspect counterAspect = (ITmfCounterAspect) counter;
8181
for (Class<? extends ITmfEventAspect<?>> parentAspectClass : counterAspect.getGroups()) {
8282

8383
// Avoid creating the same aggregated aspect multiple times
@@ -122,14 +122,14 @@ protected void eventHandle(@NonNull ITmfEvent event) {
122122
}
123123

124124
for (ITmfEventAspect<?> aspect : fCounterAspects) {
125-
if (aspect instanceof CounterAspect) {
126-
CounterAspect counterAspect = (CounterAspect) aspect;
125+
if (aspect instanceof ITmfCounterAspect) {
126+
ITmfCounterAspect counterAspect = (ITmfCounterAspect) aspect;
127127
if (counterAspect.getGroups().length > 0) {
128128
int rootQuark = ss.getQuarkAbsoluteAndAdd(CounterAnalysis.GROUPED_COUNTER_ASPECTS_ATTRIB);
129-
handleGroupedCounterAspect(event, ss, counterAspect, rootQuark);
129+
handleGroupedCounterAspect(event, ss, rootQuark, counterAspect);
130130
} else {
131131
int rootQuark = ss.getQuarkAbsoluteAndAdd(CounterAnalysis.UNGROUPED_COUNTER_ASPECTS_ATTRIB);
132-
handleCounterAspect(event, ss, counterAspect, rootQuark);
132+
handleCounterAspect(event, ss, rootQuark, counterAspect);
133133
}
134134
}
135135
}
@@ -147,8 +147,29 @@ protected void eventHandle(@NonNull ITmfEvent event) {
147147
* Grouped counter aspect
148148
* @param rootQuark
149149
* Key to a relative root of the state system
150+
* @deprecated use
151+
* {@link #handleGroupedCounterAspect(ITmfEvent, ITmfStateSystemBuilder, int, ITfmCounterAspect)}
150152
*/
153+
@Deprecated
151154
protected void handleGroupedCounterAspect(ITmfEvent event, ITmfStateSystemBuilder ss, CounterAspect aspect, int rootQuark) {
155+
handleGroupedCounterAspect(event, ss, rootQuark, aspect);
156+
}
157+
158+
/**
159+
* Add the field value of a grouped counter aspect to the state system
160+
* (override in specific implementations)
161+
*
162+
* @param event
163+
* Event to process
164+
* @param ss
165+
* State system object to fill
166+
* @param rootQuark
167+
* Key to a relative root of the state system
168+
* @param aspect
169+
* Grouped counter aspect
170+
* @since 2.3
171+
*/
172+
protected void handleGroupedCounterAspect(ITmfEvent event, ITmfStateSystemBuilder ss, int rootQuark, ITmfCounterAspect aspect) {
152173
/*
153174
* Retrieve the child quark of the counter aspect by going through its
154175
* attribute tree in the state system. The concatenation of the aspect's
@@ -170,10 +191,10 @@ protected void handleGroupedCounterAspect(ITmfEvent event, ITmfStateSystemBuilde
170191
}
171192
}
172193

173-
handleCounterAspect(event, ss, aspect, quark);
194+
handleCounterAspect(event, ss, quark, aspect);
174195
}
175196

176-
private static void handleCounterAspect(ITmfEvent event, ITmfStateSystemBuilder ss, CounterAspect aspect, int rootQuark) {
197+
private static void handleCounterAspect(ITmfEvent event, ITmfStateSystemBuilder ss, int rootQuark, ITmfCounterAspect aspect) {
177198
int quark = ss.getQuarkRelativeAndAdd(rootQuark, aspect.getName());
178199
Number eventContent = aspect.resolve(event);
179200
if (eventContent != null) {

analysis/org.eclipse.tracecompass.analysis.counters.core/src/org/eclipse/tracecompass/analysis/counters/core/aspects/AbstractCounterAspect.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,6 @@ public int hashCode() {
104104
return Objects.hash(fFieldName, fLabel);
105105
}
106106

107-
/**
108-
* {@inheritDoc}
109-
*
110-
* This is a conservative equals. It only works on very identical aspects.
111-
*/
112107
@Override
113108
public boolean equals(@Nullable Object obj) {
114109
if (this == obj) {
@@ -130,6 +125,7 @@ public boolean equals(@Nullable Object obj) {
130125
* @return the type of this counter
131126
* @since 2.1
132127
*/
128+
@Override
133129
public CounterType getType() {
134130
return fType;
135131
}

analysis/org.eclipse.tracecompass.analysis.counters.core/src/org/eclipse/tracecompass/analysis/counters/core/aspects/CounterAspect.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,7 @@ public CounterAspect(String fieldName, String label, CounterType type, Class<? e
7676
fGroups = Arrays.copyOf(groups, groups.length);
7777
}
7878

79-
/**
80-
* Get the groups
81-
*
82-
* @return the groups
83-
*/
79+
@Override
8480
public Class<? extends ITmfEventAspect<?>>[] getGroups() {
8581
return fGroups;
8682
}

analysis/org.eclipse.tracecompass.analysis.counters.core/src/org/eclipse/tracecompass/analysis/counters/core/aspects/ITmfCounterAspect.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
package org.eclipse.tracecompass.analysis.counters.core.aspects;
1313

14+
import org.eclipse.tracecompass.analysis.counters.core.CounterType;
1415
import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
1516

1617
/**
@@ -52,4 +53,23 @@ default boolean isHiddenByDefault() {
5253
default boolean isCumulative() {
5354
return true;
5455
}
56+
57+
/**
58+
* Get the groups
59+
*
60+
* @return the groups
61+
* @since 2.2
62+
*/
63+
default Class<? extends ITmfEventAspect<?>>[] getGroups() {
64+
return new Class[0];
65+
}
66+
67+
/**
68+
* Gets the type of this counter
69+
*
70+
* @since 2.2
71+
*/
72+
default CounterType getType() {
73+
return CounterType.LONG;
74+
}
5575
}

0 commit comments

Comments
 (0)