Search in sources :

Example 6 with Statistic

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);
}
Also used : Statistic(org.ovirt.engine.api.model.Statistic) Statistics(org.ovirt.engine.api.model.Statistics)

Example 7 with Statistic

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);
    }
}
Also used : Statistic(org.ovirt.engine.api.model.Statistic) Test(org.junit.Test)

Example 8 with 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);
    }
}
Also used : Statistic(org.ovirt.engine.api.model.Statistic) Test(org.junit.Test)

Example 9 with 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());
}
Also used : Statistic(org.ovirt.engine.api.model.Statistic)

Example 10 with Statistic

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());
}
Also used : Statistic(org.ovirt.engine.api.model.Statistic)

Aggregations

Statistic (org.ovirt.engine.api.model.Statistic)27 Statistics (org.ovirt.engine.api.model.Statistics)6 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)3 Values (org.ovirt.engine.api.model.Values)3 VDS (org.ovirt.engine.core.common.businessentities.VDS)2 BigDecimal (java.math.BigDecimal)1 MathContext (java.math.MathContext)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 Host (org.ovirt.engine.api.model.Host)1 Value (org.ovirt.engine.api.model.Value)1 Vm (org.ovirt.engine.api.model.Vm)1 V3Statistic (org.ovirt.engine.api.v3.types.V3Statistic)1 V3Values (org.ovirt.engine.api.v3.types.V3Values)1 VdsStatistics (org.ovirt.engine.core.common.businessentities.VdsStatistics)1 GlusterVolumeTaskStatusForHost (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeTaskStatusForHost)1 Guid (org.ovirt.engine.core.compat.Guid)1