Skip to content

Commit c0d40cc

Browse files
author
Siwei Zhang
committed
tmf: Simplify and rename state system analysis validation
This commit moves parameter validation logic out of AbstractStateSystemAnalysisDataProvider, retaining only the check for analysis module initialization. This change allows better support for data providers that do not share common query parameters. Signed-off-by: Siwei Zhang <siwei.zhang@ericsson.com>
1 parent a40472f commit c0d40cc

2 files changed

Lines changed: 15 additions & 18 deletions

File tree

tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/model/AbstractStateSystemAnalysisDataProvider.java

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**********************************************************************
2-
* Copyright (c) 2017 Ericsson
2+
* Copyright (c) 2017, 2025 Ericsson
33
*
44
* All rights reserved. This program and the accompanying materials are
55
* made available under the terms of the Eclipse Public License 2.0 which
@@ -15,7 +15,6 @@
1515
import org.eclipse.jdt.annotation.Nullable;
1616
import org.eclipse.tracecompass.internal.tmf.core.model.TmfXyResponseFactory;
1717
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
18-
import org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter;
1918
import org.eclipse.tracecompass.tmf.core.model.xy.ITmfXyModel;
2019
import org.eclipse.tracecompass.tmf.core.response.TmfModelResponse;
2120
import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule;
@@ -24,8 +23,8 @@
2423
/**
2524
* Every data provider that used a TmfStateSystemAnalysisModule should extends
2625
* this class. The purpose of this class is to provide a common method to verify
27-
* parameters of fetch method before computing the model. It's intended only to
28-
* limit code duplication of verification in fetch method of concrete data
26+
* analysis module initialization before computing the model. It's intended only
27+
* to limit code duplication of verification in fetch method of concrete data
2928
* providers
3029
*
3130
* @author Yonni Chen
@@ -45,23 +44,21 @@ public AbstractStateSystemAnalysisDataProvider(ITmfTrace trace) {
4544

4645
/**
4746
* This method is common to any data provider using a
48-
* TmfStateSystemAnalysisModule. We simply verify that parameters passed in
49-
* fetch method of data providers are correct before executing fetch method.
50-
* This method is intended to limit duplication accross all data providers using
51-
* TmfStateSystemAnalysisModule
47+
* TmfStateSystemAnalysisModule. We simply verify that the analysis module
48+
* and state system is initialized. This method is intended to limit
49+
* duplication across all data providers using TmfStateSystemAnalysisModule.
5250
*
5351
* @param module
5452
* A TmfStateSystemAnalysisModule. We are interested to know if
5553
* initialization succeed
56-
* @param filter
57-
* Contains the requested X values.
5854
* @param monitor
59-
* A ProgressMonitor. We are interested if task was cancelled before
60-
* proceding to request
55+
* A ProgressMonitor. We are interested if task was cancelled
56+
* before proceding to request
6157
* @return A {@link TmfModelResponse} if something went wrong. Null if
6258
* everything is fine
59+
* @since 10.2
6360
*/
64-
protected @Nullable TmfModelResponse<ITmfXyModel> verifyParameters(TmfStateSystemAnalysisModule module, TimeQueryFilter filter, @Nullable IProgressMonitor monitor) {
61+
protected @Nullable TmfModelResponse<ITmfXyModel> verifyAnalysisModuleInitialization(TmfStateSystemAnalysisModule module, @Nullable IProgressMonitor monitor) {
6562
if (!module.waitForInitialization()) {
6663
return TmfXyResponseFactory.createFailedResponse(CommonStatusMessage.ANALYSIS_INITIALIZATION_FAILED);
6764
}
@@ -73,10 +70,6 @@ public AbstractStateSystemAnalysisDataProvider(ITmfTrace trace) {
7370
return TmfXyResponseFactory.createFailedResponse(CommonStatusMessage.STATE_SYSTEM_FAILED);
7471
}
7572

76-
long realStart = Math.max(ss.getStartTime(), filter.getStart());
77-
if (realStart >= filter.getEnd()) {
78-
return TmfXyResponseFactory.createEmptyResponse(CommonStatusMessage.INCORRECT_QUERY_INTERVAL);
79-
}
8073
return null;
8174
}
8275
}

tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/model/xy/AbstractTreeCommonXDataProvider.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,17 @@ public final TmfModelResponse<ITmfXyModel> fetchXY(Map<String, Object> fetchPara
7676
if (filter == null) {
7777
return TmfXyResponseFactory.createFailedResponse(CommonStatusMessage.INCORRECT_QUERY_PARAMETERS);
7878
}
79-
TmfModelResponse<ITmfXyModel> res = verifyParameters(module, filter, monitor);
79+
TmfModelResponse<ITmfXyModel> res = verifyAnalysisModuleInitialization(module, monitor);
8080
if (res != null) {
8181
return res;
8282
}
8383

8484
ITmfStateSystem ss = Objects.requireNonNull(module.getStateSystem(),
8585
"Statesystem should have been verified by verifyParameters"); //$NON-NLS-1$
86+
long realStart = Math.max(ss.getStartTime(), filter.getStart());
87+
if (realStart >= filter.getEnd()) {
88+
return TmfXyResponseFactory.createEmptyResponse(CommonStatusMessage.INCORRECT_QUERY_INTERVAL);
89+
}
8690
long currentEnd = ss.getCurrentEndTime();
8791
boolean complete = ss.waitUntilBuilt(0) || filter.getEnd() <= currentEnd;
8892

0 commit comments

Comments
 (0)