use of org.ovirt.engine.core.common.businessentities.VmStatistics in project ovirt-engine by oVirt.
the class VmMigrationProgressMonitoring method onNext.
@Override
public void onNext(Map<String, Object> map) {
try {
map.remove(VdsProperties.notify_time);
map.entrySet().forEach(vmInfo -> {
Guid vmId = new Guid(vmInfo.getKey());
Map<?, ?> properties = (Map<?, ?>) vmInfo.getValue();
int progress = Integer.valueOf(properties.get(VdsProperties.vm_migration_progress).toString());
VmStatistics vmStatistics = resourceManager.getVmManager(vmId).getStatistics();
vmStatistics.setMigrationProgressPercent(progress);
Integer actualDowntime = (Integer) properties.get(VdsProperties.MIGRATION_DOWNTIME);
if (actualDowntime != null) {
resourceManager.getEventListener().actualDowntimeReported(vmId, actualDowntime);
}
});
} finally {
subscription.request(1);
}
}
use of org.ovirt.engine.core.common.businessentities.VmStatistics in project ovirt-engine by oVirt.
the class VdsBrokerObjectsBuilder method buildVMStatisticsData.
public static VmStatistics buildVMStatisticsData(Map<String, Object> struct) {
VmStatistics vmStatistics = new VmStatistics();
updateVMStatisticsData(vmStatistics, struct);
return vmStatistics;
}
use of org.ovirt.engine.core.common.businessentities.VmStatistics in project ovirt-engine by oVirt.
the class VmAnalyzerTest method initMocks.
public void initMocks(VmTestPairs vmData, boolean run) {
stubDaos();
when(vdsManager.getVdsId()).thenReturn(VmTestPairs.SRC_HOST_ID);
when(vdsManager.getClusterId()).thenReturn(VmTestPairs.CLUSTER_ID);
when(vdsManager.getCopyVds()).thenReturn(vdsManagerVds);
when(vmManager.isColdReboot()).thenReturn(false);
when(vmManager.isAutoStart()).thenReturn(vmData.dbVm() != null ? vmData.dbVm().isAutoStartup() : false);
when(vmManager.getStatistics()).thenReturn(new VmStatistics());
when(resourceManager.getVdsManager(any())).thenReturn(vdsManager);
// -- default behaviors --
// dst host is up
mockDstHostStatus(VDSStatus.Up);
// -- end of behaviors --
vmAnalyzer = spy(new VmAnalyzer(vmData.dbVm() != null ? vmData.dbVm().getDynamicData() : null, vmData.vdsmVm(), false, vdsManager, auditLogDirector, resourceManager, vdsDynamicDao, null));
doNothing().when(vmAnalyzer).resetVmInterfaceStatistics();
doReturn(vmManager).when(vmAnalyzer).getVmManager();
VDSReturnValue vdsReturnValue = new VDSReturnValue();
vdsReturnValue.setSucceeded(true);
doReturn(vdsReturnValue).when(vmAnalyzer).runVdsCommand(any(), any());
if (run) {
vmAnalyzer.analyze();
}
}
use of org.ovirt.engine.core.common.businessentities.VmStatistics in project ovirt-engine by oVirt.
the class VdsBrokerObjectsBuilderTest method getVmStatistics.
private static VmStatistics getVmStatistics() {
VmStatistics vmStatistics = new VmStatistics();
vmStatistics.setId(VM_ID);
return vmStatistics;
}
use of org.ovirt.engine.core.common.businessentities.VmStatistics in project ovirt-engine by oVirt.
the class BackendVmsResourceTest method testListIncludeStatistics.
@Test
public void testListIncludeStatistics() throws Exception {
try {
accepts.add("application/xml; detail=statistics");
UriInfo uriInfo = setUpUriExpectations(null);
org.ovirt.engine.core.common.businessentities.VM vm = new org.ovirt.engine.core.common.businessentities.VM();
VmStatistics vmStatistics = new VmStatistics();
vmStatistics.setCpuSys(0D);
vmStatistics.setCpuUser(0D);
vmStatistics.setElapsedTime(0D);
vmStatistics.setUsageCpuPercent(0);
vmStatistics.setUsageMemPercent(0);
vmStatistics.setUsageNetworkPercent(0);
vm.setStatisticsData(vmStatistics);
vm.setMigrationProgressPercent(50);
for (int i = 0; i < GUIDS.length - 1; i++) {
setUpGetEntityExpectations(QueryType.GetVmByVmId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[i] }, vm);
}
setUpGetGraphicsMultipleExpectations(3);
setUpQueryExpectations("");
collection.setUriInfo(uriInfo);
List<Vm> vms = getCollection();
assertTrue(vms.get(0).isSetStatistics());
verifyCollection(vms);
} finally {
accepts.clear();
}
}
Aggregations