Search in sources :

Example 21 with Statistic

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

Example 22 with Statistic

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

Example 23 with Statistic

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

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

Example 25 with Statistic

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

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