use of org.ovirt.engine.api.model.Statistic in project ovirt-engine by oVirt.
the class BackendStatisticsResource method list.
@Override
public Statistics list() {
try {
Statistics statistics = new Statistics();
Q entity = query.resolve(subjectId);
if (entity != null) {
List<Statistic> currentStats = query.getStatistics(entity);
for (Statistic statistic : currentStats) {
addLinks(statistic, query.getParentType());
}
statistics.getStatistics().addAll(currentStats);
}
return statistics;
} catch (Exception e) {
return handleError(e, false);
}
}
use of org.ovirt.engine.api.model.Statistic in project ovirt-engine by oVirt.
the class LinkHelperTest method testStatisticLinks.
@Test
public void testStatisticLinks() throws Exception {
Statistic statistic = new Statistic();
statistic.setId(STATISTIC_ID);
statistic.setVm(new Vm());
statistic.getVm().setId(VM_ID);
LinkHelper.addLinks(statistic);
assertEquals(STATISTIC_HREF, statistic.getHref());
}
use of org.ovirt.engine.api.model.Statistic in project ovirt-engine by oVirt.
the class StepStatisticalQuery method setHostDatum.
private Statistic setHostDatum(Statistic stat, BigDecimal value, Guid hostId) {
Statistic statistic = setDatum(clone(stat), value);
statistic.setHost(getHost(hostId));
return statistic;
}
use of org.ovirt.engine.api.model.Statistic in project ovirt-engine by oVirt.
the class BackendVmDiskResourceTest method verifyQuery.
protected void verifyQuery(AbstractStatisticalQuery<Disk, DiskImage> query, DiskImage entity) throws Exception {
assertEquals(Disk.class, query.getParentType());
assertSame(entity, query.resolve(DISK_ID));
List<Statistic> statistics = query.getStatistics(entity);
verifyStatistics(statistics, new String[] { "data.current.read", "data.current.write", "disk.read.latency", "disk.write.latency", "disk.flush.latency" }, new BigDecimal[] { asDec(10), asDec(20), asDec(30.0), asDec(40.0), asDec(50.0) });
Statistic adopted = query.adopt(new Statistic());
assertTrue(adopted.isSetDisk());
assertEquals(DISK_ID.toString(), adopted.getDisk().getId());
assertTrue(adopted.getDisk().isSetVm());
assertEquals(VM_ID.toString(), adopted.getDisk().getVm().getId());
}
use of org.ovirt.engine.api.model.Statistic in project ovirt-engine by oVirt.
the class BackendStatisticsResourceTest method getPrototype.
static Statistic getPrototype(String name) {
Statistic statistic = new Statistic();
statistic.setName(name);
statistic.setId(UUID.nameUUIDFromBytes(statistic.getName().getBytes()).toString());
statistic.setUnit(StatisticUnit.BYTES);
statistic.setKind(StatisticKind.GAUGE);
Value value = new Value();
statistic.setValues(new Values());
statistic.setType(ValueType.INTEGER);
statistic.getValues().getValues().add(value);
statistic.setHost(new Host());
statistic.getHost().setId(GUIDS[2].toString());
return statistic;
}
Aggregations