Search in sources :

Example 1 with VmBlockJob

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;
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) VmBlockJob(org.ovirt.engine.core.common.businessentities.VmBlockJob)

Example 2 with VmBlockJob

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;
}
Also used : VmJobType(org.ovirt.engine.core.common.businessentities.VmJobType) VmJob(org.ovirt.engine.core.common.businessentities.VmJob) VmBlockJob(org.ovirt.engine.core.common.businessentities.VmBlockJob) Guid(org.ovirt.engine.core.compat.Guid)

Example 3 with VmBlockJob

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);
}
Also used : VmBlockJob(org.ovirt.engine.core.common.businessentities.VmBlockJob) Test(org.junit.Test)

Example 4 with VmBlockJob

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);
}
Also used : VmJobState(org.ovirt.engine.core.common.businessentities.VmJobState) CoreMatchers.hasItem(org.hamcrest.CoreMatchers.hasItem) Guid(org.ovirt.engine.core.compat.Guid) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Assert.assertThat(org.junit.Assert.assertThat) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) VmBlockJob(org.ovirt.engine.core.common.businessentities.VmBlockJob) VmJob(org.ovirt.engine.core.common.businessentities.VmJob) Assert.fail(org.junit.Assert.fail) VmBlockJobType(org.ovirt.engine.core.common.businessentities.VmBlockJobType) Assert.assertEquals(org.junit.Assert.assertEquals) VmJobType(org.ovirt.engine.core.common.businessentities.VmJobType) VmBlockJob(org.ovirt.engine.core.common.businessentities.VmBlockJob) Test(org.junit.Test)

Example 5 with VmBlockJob

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);
}
Also used : VmBlockJob(org.ovirt.engine.core.common.businessentities.VmBlockJob)

Aggregations

VmBlockJob (org.ovirt.engine.core.common.businessentities.VmBlockJob)5 Test (org.junit.Test)2 VmJob (org.ovirt.engine.core.common.businessentities.VmJob)2 VmJobType (org.ovirt.engine.core.common.businessentities.VmJobType)2 Guid (org.ovirt.engine.core.compat.Guid)2 List (java.util.List)1 Collectors.toList (java.util.stream.Collectors.toList)1 CoreMatchers.hasItem (org.hamcrest.CoreMatchers.hasItem)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertThat (org.junit.Assert.assertThat)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 Assert.fail (org.junit.Assert.fail)1 VmBlockJobType (org.ovirt.engine.core.common.businessentities.VmBlockJobType)1 VmJobState (org.ovirt.engine.core.common.businessentities.VmJobState)1 MapSqlParameterSource (org.springframework.jdbc.core.namedparam.MapSqlParameterSource)1