use of org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException in project tracecompass by tracecompass.
the class AbstractTreeCommonXDataProvider method fetchXY.
@Override
public final TmfModelResponse<ITmfXyModel> fetchXY(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
A module = getAnalysisModule();
// TODO server: Parameters validation should be handle separately. It
// can be either in the data provider itself or before calling it. It
// will avoid the creation of filters and the content of the map can be
// use directly.
SelectionTimeQueryFilter filter = FetchParametersUtils.createSelectionTimeQuery(fetchParameters);
if (filter == null) {
return TmfXyResponseFactory.createFailedResponse(CommonStatusMessage.INCORRECT_QUERY_PARAMETERS);
}
TmfModelResponse<ITmfXyModel> res = verifyParameters(module, filter, monitor);
if (res != null) {
return res;
}
ITmfStateSystem ss = Objects.requireNonNull(module.getStateSystem(), // $NON-NLS-1$
"Statesystem should have been verified by verifyParameters");
long currentEnd = ss.getCurrentEndTime();
boolean complete = ss.waitUntilBuilt(0) || filter.getEnd() <= currentEnd;
try (FlowScopeLog scope = // $NON-NLS-1$
new FlowScopeLogBuilder(LOGGER, Level.FINE, "AbstractTreeXyDataProvider#fetchXY").setCategory(getClass().getSimpleName()).build()) {
Collection<IYModel> yModels = getYSeriesModels(ss, fetchParameters, monitor);
if (yModels == null) {
// getModels returns null if the query was cancelled.
return TmfXyResponseFactory.createCancelledResponse(CommonStatusMessage.TASK_CANCELLED);
}
return TmfXyResponseFactory.create(getTitle(), filter.getTimesRequested(), ImmutableList.copyOf(yModels), complete);
} catch (StateSystemDisposedException | TimeRangeException | IndexOutOfBoundsException e) {
return TmfXyResponseFactory.createFailedResponse(String.valueOf(e.getMessage()));
}
}
use of org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException in project tracecompass by tracecompass.
the class AbstractTmfMipmapStateProvider method getFeatureSet.
// ------------------------------------------------------------------------
// Private methods
// ------------------------------------------------------------------------
private Set<ITmfMipmapFeature> getFeatureSet(int baseQuark, long ts, ITmfStateValue value, int mipmapFeatureBits, int resolution) {
ITmfStateSystemBuilder ss = checkNotNull(getStateSystemBuilder());
Set<ITmfMipmapFeature> features = featureMap.get(baseQuark);
if (features != null) {
return features;
}
features = new LinkedHashSet<>();
if (value.isNull()) {
return features;
}
featureMap.put(baseQuark, features);
if (resolution > 1) {
try {
if ((mipmapFeatureBits & MAX) != 0) {
int featureQuark = ss.getQuarkRelativeAndAdd(baseQuark, MAX_STRING);
ss.modifyAttribute(ts, 0, featureQuark);
MaxMipmapFeature mf = new MaxMipmapFeature(baseQuark, featureQuark, resolution, ss);
features.add(mf);
}
if ((mipmapFeatureBits & MIN) != 0) {
int featureQuark = ss.getQuarkRelativeAndAdd(baseQuark, MIN_STRING);
ss.modifyAttribute(ts, 0, featureQuark);
MinMipmapFeature mf = new MinMipmapFeature(baseQuark, featureQuark, resolution, ss);
features.add(mf);
}
if ((mipmapFeatureBits & AVG) != 0) {
int featureQuark = ss.getQuarkRelativeAndAdd(baseQuark, AVG_STRING);
ss.modifyAttribute(ts, 0, featureQuark);
AvgMipmapFeature mf = new AvgMipmapFeature(baseQuark, featureQuark, resolution, ss);
features.add(mf);
}
} catch (TimeRangeException e) {
// $NON-NLS-1$
Activator.logError("MipMapProvider : Time stamp outside of time range of state system", e);
} catch (StateValueTypeException e) {
// $NON-NLS-1$
Activator.logError("MipMapProvider : Wrong state value type", e);
}
}
return features;
}
use of org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException in project tracecompass by tracecompass.
the class StateSystemDataProvider method fetchRowModel.
@Override
@NonNull
public TmfModelResponse<@NonNull TimeGraphModel> fetchRowModel(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
Table<ITmfStateSystem, Integer, Long> table = HashBasedTable.create();
// Get the quarks to display
Collection<Long> selectedItems = DataProviderParameterUtils.extractSelectedItems(fetchParameters);
synchronized (fEntryBuilder) {
if (selectedItems == null) {
// No selected items, take them all
selectedItems = fIDToDisplayQuark.keySet();
}
for (Long id : selectedItems) {
Pair<ITmfStateSystem, Integer> pair = fIDToDisplayQuark.get(id);
if (pair != null) {
table.put(pair.getFirst(), pair.getSecond(), id);
}
}
}
List<@NonNull ITimeGraphRowModel> allRows = new ArrayList<>();
try {
List<Long> times = DataProviderParameterUtils.extractTimeRequested(fetchParameters);
for (Entry<ITmfStateSystem, Map<Integer, Long>> ssEntry : table.rowMap().entrySet()) {
ITmfStateSystem ss = Objects.requireNonNull(ssEntry.getKey());
List<@NonNull ITimeGraphRowModel> rows = getRowModels(ss, ssEntry.getValue(), times, fetchParameters, monitor);
if (monitor != null && monitor.isCanceled()) {
return new TmfModelResponse<>(null, Status.CANCELLED, CommonStatusMessage.TASK_CANCELLED);
}
synchronized (fEntryBuilder) {
// Add the SS
Long ssId = fSsToId.get(ss);
if (ssId != null && selectedItems.contains(ssId)) {
TimeGraphRowModel ssRow = new TimeGraphRowModel(ssId, new ArrayList<>());
List<@NonNull ITimeGraphState> states = ssRow.getStates();
states.add(new TimeGraphState(ss.getStartTime(), ss.getCurrentEndTime() - ss.getStartTime(), Integer.MAX_VALUE));
rows.add(ssRow);
}
}
allRows.addAll(rows);
}
synchronized (fEntryBuilder) {
for (ModuleEntryModel module : fModuleEntryModelList) {
if (selectedItems.contains(module.getId())) {
allRows.add(getModuleRowModels(module));
}
}
}
if (monitor != null && monitor.isCanceled()) {
return new TmfModelResponse<>(null, Status.CANCELLED, CommonStatusMessage.TASK_CANCELLED);
}
return new TmfModelResponse<>(new TimeGraphModel(allRows), Status.COMPLETED, CommonStatusMessage.COMPLETED);
} catch (IndexOutOfBoundsException | TimeRangeException | StateSystemDisposedException e) {
return new TmfModelResponse<>(null, Status.FAILED, CommonStatusMessage.STATE_SYSTEM_FAILED);
}
}
use of org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException in project tracecompass by tracecompass.
the class KernelContextSwitchAnalysis method getContextSwitchesRange.
/**
* Get a map of the number of context switch per CPU during a time range.
*
* @param startParam
* Start time of requested range
* @param endParam
* End time of requested range
* @return A map of CPU# -> nb of context switch in the [start, end]
* interval. CPU# == -1 represents the total number of context
* switch
* @throws TimeRangeException
* if one or more of the parameters is outside the range the
* state history
*/
@NonNullByDefault({})
@NonNull
public Map<Integer, Long> getContextSwitchesRange(final long startParam, final long endParam) {
@Nullable final ITmfStateSystem stateSystem = getStateSystem();
ITmfTrace trace = getTrace();
if (trace == null || stateSystem == null) {
return Collections.<Integer, Long>emptyMap();
}
long start = Math.max(startParam, stateSystem.getStartTime());
long end = Math.min(endParam, stateSystem.getCurrentEndTime());
ITmfStateSystem contextSwitchStateSystem = TmfStateSystemAnalysisModule.getStateSystem(trace, KernelContextSwitchAnalysis.ID);
if (contextSwitchStateSystem == null) {
return Collections.<Integer, Long>emptyMap();
}
/*
* Make sure the start/end times are within the state history, so we
* don't get TimeRange exceptions.
*/
long startTime = contextSwitchStateSystem.getStartTime();
long endTime = contextSwitchStateSystem.getCurrentEndTime();
if (endTime < startTime) {
return Collections.<Integer, Long>emptyMap();
}
Map<Integer, Long> map = new HashMap<>();
try {
/* Get the list of quarks for each CPU */
int cpusNode = contextSwitchStateSystem.getQuarkAbsolute(Attributes.CPUS);
List<Integer> cpuQuarks = contextSwitchStateSystem.getSubAttributes(cpusNode, false);
/* Query full states at start and end times */
List<ITmfStateInterval> kernelEndState = contextSwitchStateSystem.queryFullState(end);
List<ITmfStateInterval> kernelStartState = contextSwitchStateSystem.queryFullState(start);
Long totalNbCxtSwt = 0l;
for (Integer cpuQuark : cpuQuarks) {
int cpuNb = Integer.parseInt(contextSwitchStateSystem.getAttributeName(cpuQuark.intValue()));
Long nbCxtSwtForCore = kernelEndState.get(cpuQuark).getStateValue().unboxLong() - kernelStartState.get(cpuQuark).getStateValue().unboxLong();
map.put(cpuNb, nbCxtSwtForCore);
totalNbCxtSwt += nbCxtSwtForCore;
}
/* Put the total number of context switches in the interval */
map.put(TOTAL, totalNbCxtSwt);
} catch (TimeRangeException | AttributeNotFoundException e) {
/*
* Assume there is no events or the attribute does not exist yet,
* nothing will be put in the map.
*/
} catch (StateValueTypeException | StateSystemDisposedException e) {
/*
* These other exception types would show a logic problem, so they
* should not happen.
*/
// $NON-NLS-1$
Activator.getDefault().logError("Error getting CPU context switches in a time range", e);
}
return map;
}
use of org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException in project tracecompass by tracecompass.
the class ThreadPriorityAspect method resolve.
@Override
@Nullable
public Integer resolve(ITmfEvent event) {
@NonNull final ITmfTrace trace = event.getTrace();
KernelAnalysisModule kernelAnalysis = TmfTraceUtils.getAnalysisModuleOfClass(trace, KernelAnalysisModule.class, KernelAnalysisModule.ID);
if (kernelAnalysis == null) {
return null;
}
ITmfStateSystem ss = kernelAnalysis.getStateSystem();
if (ss == null) {
return null;
}
Integer tid = KernelTidAspect.INSTANCE.resolve(event);
if (tid == null) {
return null;
}
final long ts = event.getTimestamp().getValue();
Integer execPrio = null;
try {
Integer cpu = 0;
if (tid == 0) {
/* Find the CPU this event is run on */
cpu = TmfTraceUtils.resolveIntEventAspectOfClassForEvent(trace, TmfCpuAspect.class, event);
}
int execPrioQuark = ss.getQuarkAbsolute(Attributes.THREADS, Attributes.buildThreadAttributeName(tid, cpu), Attributes.PRIO);
ITmfStateInterval interval = ss.querySingleState(ts, execPrioQuark);
ITmfStateValue prioValue = interval.getStateValue();
/* We know the prio must be an Integer */
execPrio = prioValue.unboxInt();
} catch (AttributeNotFoundException | StateSystemDisposedException | TimeRangeException e) {
}
return execPrio;
}
Aggregations