use of org.ovirt.engine.core.common.businessentities.VmBlockJob in project ovirt-engine by oVirt.
the class VmJobDaoImpl method createFullParametersMapper.
@Override
protected MapSqlParameterSource createFullParametersMapper(VmJob entity) {
MapSqlParameterSource mapper = createIdParameterMapper(entity.getId());
mapper.addValue("vm_id", entity.getVmId());
mapper.addValue("job_state", entity.getJobState().getValue());
mapper.addValue("job_type", entity.getJobType().getValue());
if (entity.getJobType() == VmJobType.BLOCK) {
VmBlockJob blockJob = (VmBlockJob) entity;
mapper.addValue("block_job_type", blockJob.getBlockJobType().getValue());
mapper.addValue("bandwidth", blockJob.getBandwidth());
mapper.addValue("cursor_cur", blockJob.getCursorCur());
mapper.addValue("cursor_end", blockJob.getCursorEnd());
mapper.addValue("image_group_id", blockJob.getImageGroupId());
} else {
mapper.addValue("block_job_type", null);
mapper.addValue("bandwidth", null);
mapper.addValue("cursor_cur", null);
mapper.addValue("cursor_end", null);
mapper.addValue("image_group_id", null);
}
return mapper;
}
use of org.ovirt.engine.core.common.businessentities.VmBlockJob in project ovirt-engine by oVirt.
the class VdsBrokerObjectsBuilder method buildVmJobData.
private static VmJob buildVmJobData(Guid vmId, Map<String, Object> struct) {
VmJob ret;
VmJobType jobType = VmJobType.getByName(assignStringValue(struct, VdsProperties.vmJobType));
if (jobType == null) {
jobType = VmJobType.UNKNOWN;
}
switch(jobType) {
case BLOCK:
VmBlockJob blockJob = new VmBlockJob();
blockJob.setBlockJobType(VmBlockJobType.getByName(assignStringValue(struct, VdsProperties.vmBlockJobType)));
blockJob.setCursorCur(assignLongValue(struct, VdsProperties.vmJobCursorCur));
blockJob.setCursorEnd(assignLongValue(struct, VdsProperties.vmJobCursorEnd));
blockJob.setBandwidth(assignLongValue(struct, VdsProperties.vmJobBandwidth));
blockJob.setImageGroupId(new Guid(assignStringValue(struct, VdsProperties.vmJobImageUUID)));
ret = blockJob;
break;
default:
ret = new VmJob();
break;
}
ret.setVmId(vmId);
ret.setId(new Guid(assignStringValue(struct, VdsProperties.vmJobId)));
ret.setJobState(VmJobState.NORMAL);
ret.setJobType(jobType);
return ret;
}
use of org.ovirt.engine.core.common.businessentities.VmBlockJob in project ovirt-engine by oVirt.
the class VmJobDaoTest method testInsertVmBlockJob.
@Test
public void testInsertVmBlockJob() {
// Create a job in memory
VmBlockJob job = new VmBlockJob();
job.setId(Guid.newGuid());
job.setVmId(FixturesTool.VM_RHEL5_POOL_50);
job.setJobState(VmJobState.NORMAL);
// Update block job fields
job.setBlockJobType(VmBlockJobType.COMMIT);
job.setBandwidth(16L);
job.setCursorCur(11L);
job.setCursorEnd(1981L);
job.setImageGroupId(FixturesTool.IMAGE_GROUP_ID);
assertInsert(job);
}
use of org.ovirt.engine.core.common.businessentities.VmBlockJob in project ovirt-engine by oVirt.
the class VmJobDaoTest method testUpdate.
@Test
public void testUpdate() {
// Get a block job
VmBlockJob job = (VmBlockJob) dao.getAll().stream().filter(j -> j.getId().equals(FixturesTool.EXISTING_VM_BLOCK_JOB)).findFirst().orElse(null);
// Make some changes
job.setBandwidth(1981L);
job.setJobState(VmJobState.UNKNOWN);
dao.update(job);
// Get the job again
VmBlockJob updatedJob = (VmBlockJob) dao.getAll().stream().filter(j -> j.getId().equals(FixturesTool.EXISTING_VM_BLOCK_JOB)).findFirst().orElse(null);
assertEquals(job, updatedJob);
}
use of org.ovirt.engine.core.common.businessentities.VmBlockJob in project ovirt-engine by oVirt.
the class MergeCommand method persistBlockJobPlaceholder.
private void persistBlockJobPlaceholder(Guid jobId) {
VmBlockJob blockJob = new VmBlockJob();
blockJob.setVmId(getParameters().getVmId());
blockJob.setId(jobId);
blockJob.setJobType(VmJobType.BLOCK);
blockJob.setJobState(VmJobState.UNKNOWN);
blockJob.setImageGroupId(getParameters().getImageGroupId());
vmJobsMonitoring.addJob(blockJob);
}
Aggregations