Search in sources :

Example 1 with VdsStatistics

use of org.ovirt.engine.core.common.businessentities.VdsStatistics in project ovirt-engine by oVirt.

the class BackendHostResourceTest method setUpStatisticalExpectations.

protected VDS setUpStatisticalExpectations() throws Exception {
    VdsStatistics stats = mock(VdsStatistics.class);
    VDS entity = mock(VDS.class);
    setUpStatisticalEntityExpectations(entity, stats);
    setUpGetEntityWithNoCertificateInfoExpectations(1, false, entity);
    return entity;
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) VdsStatistics(org.ovirt.engine.core.common.businessentities.VdsStatistics)

Example 2 with VdsStatistics

use of org.ovirt.engine.core.common.businessentities.VdsStatistics in project ovirt-engine by oVirt.

the class AddVdsCommand method addVdsStatisticsToDb.

private void addVdsStatisticsToDb() {
    VdsStatistics vdsStatistics = new VdsStatistics();
    vdsStatistics.setId(getParameters().getVdsStaticData().getId());
    vdsStatisticsDao.save(vdsStatistics);
    getCompensationContext().snapshotNewEntity(vdsStatistics);
}
Also used : VdsStatistics(org.ovirt.engine.core.common.businessentities.VdsStatistics)

Example 3 with VdsStatistics

use of org.ovirt.engine.core.common.businessentities.VdsStatistics in project ovirt-engine by oVirt.

the class HostStatisticalQuery method getStatistics.

public List<Statistic> getStatistics(VDS entity) {
    VdsStatistics s = entity.getStatisticsData();
    // if user queries host statistics before host installation completed, null values are possible (therefore added checks).
    long memTotal = entity.getPhysicalMemMb() == null ? 0 : entity.getPhysicalMemMb() * Mb;
    long memUsed = (s == null || s.getUsageMemPercent() == null) ? 0 : memTotal * s.getUsageMemPercent() / 100;
    List<Statistic> statistics = asList(setDatum(clone(MEM_TOTAL), memTotal), setDatum(clone(MEM_USED), memUsed), setDatum(clone(MEM_FREE), memTotal - memUsed), setDatum(clone(MEM_SHARED), (s == null || s.getMemShared() == null) ? 0 : s.getMemShared() * Mb), setDatum(clone(MEM_BUFFERS), 0), setDatum(clone(MEM_CACHED), 0), setDatum(clone(SWAP_TOTAL), (s == null || s.getSwapTotal() == null) ? 0 : s.getSwapTotal() * Mb), setDatum(clone(SWAP_FREE), (s == null || s.getSwapFree() == null) ? 0 : s.getSwapFree() * Mb), setDatum(clone(SWAP_USED), getSwapUsed(s) * Mb), setDatum(clone(SWAP_CACHED), 0), setDatum(clone(CPU_KSM), (s == null || s.getKsmCpuPercent() == null) ? 0 : s.getKsmCpuPercent()), setDatum(clone(CPU_USER), (s == null || s.getCpuUser() == null) ? 0 : s.getCpuUser()), setDatum(clone(CPU_SYS), (s == null || s.getCpuSys() == null) ? 0 : s.getCpuSys()), setDatum(clone(CPU_IDLE), (s == null || s.getCpuIdle() == null) ? 0 : s.getCpuIdle()), setDatum(clone(CPU_LOAD), (s == null || s.getCpuLoad() == null) ? 0 : s.getCpuLoad() / 100), setDatum(clone(BOOT_TIME), (s == null || s.getBootTime() == null) ? 0 : s.getBootTime()));
    if (s != null && s.getHugePages() != null) {
        s.getHugePages().stream().filter(page -> page.getAmount() != null).map(this::createHugePagesFree).forEach(statistics::add);
    }
    return statistics;
}
Also used : Statistic(org.ovirt.engine.api.model.Statistic) VdsStatistics(org.ovirt.engine.core.common.businessentities.VdsStatistics)

Example 4 with VdsStatistics

use of org.ovirt.engine.core.common.businessentities.VdsStatistics in project ovirt-engine by oVirt.

the class VdsStatisticsDaoTest method generateNewEntity.

@Override
protected VdsStatistics generateNewEntity() {
    VdsStatistics newStatistics = new VdsStatistics();
    newStatistics.setId(FixturesTool.VDS_JUST_STATIC_ID);
    return newStatistics;
}
Also used : VdsStatistics(org.ovirt.engine.core.common.businessentities.VdsStatistics)

Example 5 with VdsStatistics

use of org.ovirt.engine.core.common.businessentities.VdsStatistics in project ovirt-engine by oVirt.

the class JsonObjectSerializationEntitiesTest method randomVdsStatistics.

private static VdsStatistics randomVdsStatistics() {
    RandomUtils random = RandomUtils.instance();
    VdsStatistics vdsStatistics = new VdsStatistics();
    vdsStatistics.setCpuIdle(random.nextDouble());
    vdsStatistics.setCpuLoad(random.nextDouble());
    vdsStatistics.setCpuSys(random.nextDouble());
    vdsStatistics.setCpuUser(random.nextDouble());
    vdsStatistics.setMemAvailable(random.nextLong());
    vdsStatistics.setMemFree(random.nextLong());
    vdsStatistics.setMemShared(random.nextLong());
    vdsStatistics.setUsageCpuPercent(random.nextInt());
    vdsStatistics.setUsageMemPercent(random.nextInt());
    vdsStatistics.setUsageNetworkPercent(random.nextInt());
    vdsStatistics.setCpuOverCommitTimeStamp(new Date(random.nextLong()));
    return vdsStatistics;
}
Also used : RandomUtils(org.ovirt.engine.core.utils.RandomUtils) VdsStatistics(org.ovirt.engine.core.common.businessentities.VdsStatistics) Date(java.util.Date)

Aggregations

VdsStatistics (org.ovirt.engine.core.common.businessentities.VdsStatistics)6 Date (java.util.Date)1 LinkedList (java.util.LinkedList)1 Statistic (org.ovirt.engine.api.model.Statistic)1 VDS (org.ovirt.engine.core.common.businessentities.VDS)1 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)1 VdsNetworkStatistics (org.ovirt.engine.core.common.businessentities.network.VdsNetworkStatistics)1 RandomUtils (org.ovirt.engine.core.utils.RandomUtils)1