use of org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException in project tracecompass by tracecompass.
the class DataDrivenXYDataProvider method fetchXY.
@Override
public TmfModelResponse<ITmfXyModel> fetchXY(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
TimeQueryFilter filter = FetchParametersUtils.createTimeQuery(fetchParameters);
if (filter == null) {
return TmfXyResponseFactory.createFailedResponse(CommonStatusMessage.INCORRECT_QUERY_PARAMETERS);
}
long[] xValues = filter.getTimesRequested();
filter = FetchParametersUtils.createSelectionTimeQuery(fetchParameters);
if (filter == null) {
return TmfXyResponseFactory.create(TITLE, xValues, Collections.emptyList(), true);
}
Map<DisplayElement, IYModel> map = initSeries(filter);
if (map.isEmpty()) {
return TmfXyResponseFactory.create(TITLE, xValues, Collections.emptyList(), true);
}
ITmfStateSystem ss = null;
for (DisplayElement de : map.keySet()) {
ss = de.fStateSystem;
}
if (ss == null) {
return TmfXyResponseFactory.create(TITLE, xValues, Collections.emptyList(), true);
}
long currentEnd = ss.getCurrentEndTime();
try {
for (int i = 0; i < xValues.length; i++) {
if (monitor != null && monitor.isCanceled()) {
return TmfXyResponseFactory.createCancelledResponse(CommonStatusMessage.TASK_CANCELLED);
}
long time = xValues[i];
if (time > currentEnd) {
break;
} else if (ss.getStartTime() <= time) {
List<@NonNull ITmfStateInterval> full = ss.queryFullState(time);
for (Entry<DisplayElement, IYModel> series : map.entrySet()) {
int attributeQuark = series.getKey().fQuark;
if (attributeQuark >= 0 && attributeQuark < full.size()) {
Object value = full.get(attributeQuark).getValue();
series.getValue().getData()[i] = extractValue(value);
}
}
}
}
// Update the series value if delta is requested
for (Entry<DisplayElement, IYModel> series : map.entrySet()) {
if (series.getKey().fDisplayType.equals(DisplayType.DELTA)) {
getSeriesDelta(series.getValue().getData());
}
}
} catch (StateSystemDisposedException e) {
return TmfXyResponseFactory.createFailedResponse(e.getMessage());
}
boolean complete = ss.waitUntilBuilt(0) || filter.getEnd() <= currentEnd;
return TmfXyResponseFactory.create(TITLE, xValues, ImmutableList.copyOf(map.values()), complete);
}
use of org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException in project tracecompass by tracecompass.
the class TmfMipmapStateProviderTest method testQueryMipMax.
/**
* Test a single query to the state system for a max
*
* Make sure the state system has data.
*
* Hint: the value read should always be greater than(t / 1000)
*/
@Test
public void testQueryMipMax() {
assertNotNull(ssq);
try {
List<ITmfStateInterval> intervals = ssq.queryFullState(TEST_TIMESTAMP);
int mipmapQuark = ssq.getQuarkAbsolute(TEST_ATTRIBUTE_NAME, AbstractTmfMipmapStateProvider.MAX_STRING);
assertEquals("max nblevels", NB_LEVELS, intervals.get(mipmapQuark).getStateValue().unboxInt());
for (int level = 1; level < NB_LEVELS; level++) {
long width = (long) Math.pow(RESOLUTION, level);
int levelQuark = ssq.getQuarkRelative(mipmapQuark, String.valueOf(level));
ITmfStateInterval interval = intervals.get(levelQuark);
long valueLong = interval.getStateValue().unboxLong();
assertEquals("max value @ level " + level, width + (((TEST_TIMESTAMP - START_TIME) / INTERVAL) / width) * width, valueLong);
assertEquals("max start time @ level " + level, START_TIME + (((TEST_TIMESTAMP - START_TIME) / INTERVAL) / width) * width * INTERVAL, interval.getStartTime());
assertEquals("max end time @ level " + level, START_TIME + (INTERVAL * width) + (((TEST_TIMESTAMP - START_TIME) / INTERVAL) / width) * width * INTERVAL, interval.getEndTime() + 1);
}
} catch (TimeRangeException e) {
fail(e.getMessage());
} catch (StateSystemDisposedException e) {
fail(e.getMessage());
} catch (AttributeNotFoundException e) {
fail(e.getMessage());
} catch (StateValueTypeException e) {
fail(e.getMessage());
}
assertTrue(true);
}
use of org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException in project tracecompass by tracecompass.
the class TmfMipmapStateProviderTest method testMaxLevel.
/**
* Test a single query to the state system for the maxLevel.
*
* Make sure the state system has data.
*/
@Test
public void testMaxLevel() {
assertNotNull(ssq);
try {
Random rn = new Random();
long time = Math.max(INTERVAL, rn.nextLong() % END_TIME);
List<ITmfStateInterval> intervals = ssq.queryFullState(time);
int maxMipmapQuark = ssq.getQuarkAbsolute(TEST_ATTRIBUTE_NAME, AbstractTmfMipmapStateProvider.MAX_STRING);
int nbLevelMax = intervals.get(maxMipmapQuark).getStateValue().unboxInt();
assertEquals(NB_LEVELS, nbLevelMax);
int minMipmapQuark = ssq.getQuarkAbsolute(TEST_ATTRIBUTE_NAME, AbstractTmfMipmapStateProvider.MIN_STRING);
int nbLevelMin = intervals.get(minMipmapQuark).getStateValue().unboxInt();
assertEquals(NB_LEVELS, nbLevelMin);
int avgMipmapQuark = ssq.getQuarkAbsolute(TEST_ATTRIBUTE_NAME, AbstractTmfMipmapStateProvider.AVG_STRING);
int nbLevelAvg = intervals.get(avgMipmapQuark).getStateValue().unboxInt();
assertEquals(NB_LEVELS, nbLevelAvg);
} catch (TimeRangeException e) {
fail(e.getMessage());
} catch (StateSystemDisposedException e) {
fail(e.getMessage());
} catch (AttributeNotFoundException e) {
fail(e.getMessage());
} catch (StateValueTypeException e) {
fail(e.getMessage());
}
assertTrue(true);
}
use of org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException in project tracecompass by tracecompass.
the class TmfMipmapStateProviderTest method testQueryEventField.
/**
* Test a single query to the state system for a mip
*
* Make sure the state system has data.
*/
@Test
public void testQueryEventField() {
assertNotNull(ssq);
try {
List<ITmfStateInterval> intervals = ssq.queryFullState(TEST_TIMESTAMP);
int eventFieldQuark = ssq.getQuarkAbsolute(TEST_ATTRIBUTE_NAME);
ITmfStateInterval interval = intervals.get(eventFieldQuark);
long valueLong = interval.getStateValue().unboxLong();
assertEquals(TEST_TIMESTAMP / INTERVAL, valueLong);
} catch (TimeRangeException e) {
fail(e.getMessage());
} catch (StateSystemDisposedException e) {
fail(e.getMessage());
} catch (AttributeNotFoundException e) {
fail(e.getMessage());
} catch (StateValueTypeException e) {
fail(e.getMessage());
}
assertTrue(true);
}
use of org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException in project tracecompass by tracecompass.
the class TmfMipmapStateProviderTest method testQueryMipMin.
/**
* Test a single query to the state system for a min
*
* Make sure the state system has data.
*
* Hint: the value read should always be less than(t / 1000)
*/
@Test
public void testQueryMipMin() {
assertNotNull(ssq);
try {
List<ITmfStateInterval> intervals = ssq.queryFullState(TEST_TIMESTAMP);
int mipmapQuark = ssq.getQuarkAbsolute(TEST_ATTRIBUTE_NAME, AbstractTmfMipmapStateProvider.MIN_STRING);
assertEquals("min nblevels", NB_LEVELS, intervals.get(mipmapQuark).getStateValue().unboxInt());
for (int level = 1; level < NB_LEVELS; level++) {
long width = (long) Math.pow(RESOLUTION, level);
int levelQuark = ssq.getQuarkRelative(mipmapQuark, String.valueOf(level));
ITmfStateInterval interval = intervals.get(levelQuark);
long valueLong = interval.getStateValue().unboxLong();
assertEquals("min value @ level " + level, 1 + (((TEST_TIMESTAMP - START_TIME) / INTERVAL) / width) * width, valueLong);
assertEquals("min start time @ level " + level, START_TIME + (((TEST_TIMESTAMP - START_TIME) / INTERVAL) / width) * width * INTERVAL, interval.getStartTime());
assertEquals("min end time @ level " + level, START_TIME + (INTERVAL * width) + (((TEST_TIMESTAMP - START_TIME) / INTERVAL) / width) * width * INTERVAL, interval.getEndTime() + 1);
}
} catch (TimeRangeException e) {
fail(e.getMessage());
} catch (StateSystemDisposedException e) {
fail(e.getMessage());
} catch (AttributeNotFoundException e) {
fail(e.getMessage());
} catch (StateValueTypeException e) {
fail(e.getMessage());
}
assertTrue(true);
}
Aggregations