use of org.ovirt.engine.api.model.Statistic in project ovirt-engine by oVirt.
the class BackendHostNicsResource method addStatistics.
private void addStatistics(HostNic model, VdsNetworkInterface entity) {
model.setStatistics(new Statistics());
HostNicStatisticalQuery query = new HostNicStatisticalQuery(newModel(model.getId()));
List<Statistic> statistics = query.getStatistics(entity);
for (Statistic statistic : statistics) {
LinkHelper.addLinks(statistic, query.getParentType());
}
model.getStatistics().getStatistics().addAll(statistics);
}
use of org.ovirt.engine.api.model.Statistic in project ovirt-engine by oVirt.
the class GlusterTaskStatisticalQueryTest method testQuery.
@Test
public void testQuery() {
List<Statistic> statistics = query.getStatistics(getTaskEntity());
assertEquals(14, statistics.size());
for (Statistic statistic : statistics) {
verifyStatistic(statistic);
}
}
use of org.ovirt.engine.api.model.Statistic in project ovirt-engine by oVirt.
the class DiskStatisticalQueryTest method testQuery.
@Test
public void testQuery() {
List<Statistic> statistics = query.getStatistics(getDisk());
assertEquals(5, statistics.size());
for (Statistic statistic : statistics) {
verifyStatistic(statistic);
}
}
use of org.ovirt.engine.api.model.Statistic in project ovirt-engine by oVirt.
the class BackendVmResourceTest method verifyQuery.
protected void verifyQuery(AbstractStatisticalQuery<Vm, org.ovirt.engine.core.common.businessentities.VM> query, org.ovirt.engine.core.common.businessentities.VM entity) throws Exception {
assertEquals(Vm.class, query.getParentType());
assertSame(entity, query.resolve(GUIDS[0]));
List<Statistic> statistics = query.getStatistics(entity);
verifyStatistics(statistics, new String[] { "memory.installed", "memory.used", "memory.free", "memory.buffered", "memory.cached", "cpu.current.guest", "cpu.current.hypervisor", "cpu.current.total", "migration.progress" }, new BigDecimal[] { asDec(10 * Mb), asDec(2 * Mb), asDec(5 * Mb), asDec(2 * Mb), asDec(1 * Mb), asDec(30), asDec(40), asDec(70), asDec(50) });
Statistic adopted = query.adopt(new Statistic());
assertTrue(adopted.isSetVm());
assertEquals(GUIDS[0].toString(), adopted.getVm().getId());
}
use of org.ovirt.engine.api.model.Statistic in project ovirt-engine by oVirt.
the class BackendVmNicResourceTest method verifyQuery.
protected void verifyQuery(AbstractStatisticalQuery<Nic, VmNetworkInterface> query, VmNetworkInterface entity) throws Exception {
assertEquals(Nic.class, query.getParentType());
assertSame(entity, query.resolve(NIC_ID));
List<Statistic> statistics = query.getStatistics(entity);
verifyStatistics(statistics, new String[] { "data.current.rx", "data.current.tx", "data.current.rx.bps", "data.current.tx.bps", "errors.total.rx", "errors.total.tx", "data.total.rx", "data.total.tx" }, new BigDecimal[] { asDec(RxTxCalculator.percent2bytes(50, 10D)), asDec(RxTxCalculator.percent2bytes(50, 20D)), asDec(RxTxCalculator.percent2bits(50, 10D)), asDec(RxTxCalculator.percent2bits(50, 20D)), asDec(30), asDec(40), asDec(50), asDec(60) });
Statistic adopted = query.adopt(new Statistic());
assertTrue(adopted.isSetNic());
assertEquals(NIC_ID.toString(), adopted.getNic().getId());
assertTrue(adopted.getNic().isSetVm());
assertEquals(VM_ID.toString(), adopted.getNic().getVm().getId());
}
Aggregations