Search in sources :

Example 11 with Job

use of org.ovirt.engine.core.common.job.Job in project ovirt-engine by oVirt.

the class AddExternalStepCommandTest method makeExternalTestJob.

private Job makeExternalTestJob(Guid jobId) {
    Job job = new Job();
    job.setId(jobId);
    job.setDescription("Sample Job");
    job.setExternal(true);
    return job;
}
Also used : Job(org.ovirt.engine.core.common.job.Job)

Example 12 with Job

use of org.ovirt.engine.core.common.job.Job in project ovirt-engine by oVirt.

the class AddJobCommand method createJob.

protected void createJob(ActionType actionType, boolean isExternal) {
    Job job = ExecutionHandler.createJob(actionType, this);
    job.setDescription(getParameters().getDescription());
    job.setAutoCleared(getParameters().isAutoCleared());
    Guid id = job.getId();
    job.setExternal(isExternal);
    jobRepository.saveJob(job);
    if (jobDao.get(id) != null) {
        setActionReturnValue(id);
        setSucceeded(true);
    } else {
        setSucceeded(false);
    }
}
Also used : Guid(org.ovirt.engine.core.compat.Guid) Job(org.ovirt.engine.core.common.job.Job)

Example 13 with Job

use of org.ovirt.engine.core.common.job.Job in project ovirt-engine by oVirt.

the class JobRepositoryTest method getJobWithSteps.

@Test
public void getJobWithSteps() {
    Job jobWithSteps = jobRepository.getJobWithSteps(job.getId());
    assertNotNull(jobWithSteps);
    assertNotNull(jobWithSteps.getSteps());
    assertTrue(!jobWithSteps.getSteps().isEmpty());
    assertEquals(JOB_SUBJECT_ENTITIES_MAP, jobWithSteps.getJobSubjectEntities());
}
Also used : Job(org.ovirt.engine.core.common.job.Job) Test(org.junit.Test)

Example 14 with Job

use of org.ovirt.engine.core.common.job.Job in project ovirt-engine by oVirt.

the class ExecutionHandler method prepareCommandForMonitoring.

/**
 * Prepares the monitoring objects for the command by the default behavior:
 * <ul>
 * <li> {@link ExecutionContext} determines how the command should be monitored. By default, non-internal commands
 * will be associated with {@code Job} to represent the command execution. Internal commands will not be monitored
 * by default, therefore the {@code ExecutionContext} is created as non-monitored context.
 * <li> {@link Job} is created for monitored actions
 * </ul>
 *
 * @param command
 *            The created instance of the command (can't be <code>null</code>).
 * @param actionType
 *            The action type of the command
 * @param runAsInternal
 *            Indicates if the command should be run as internal action or not
 */
public void prepareCommandForMonitoring(CommandBase<?> command, ActionType actionType, boolean runAsInternal) {
    ExecutionContext context = command.getExecutionContext();
    if (context == null) {
        context = new ExecutionContext();
    }
    try {
        boolean isMonitored = shouldMonitorCommand(actionType, runAsInternal);
        // A monitored job is created for monitored external flows
        if (isMonitored || context.isJobRequired()) {
            Job job = getJob(command, actionType);
            context.setExecutionMethod(ExecutionMethod.AsJob);
            context.setJob(job);
            command.setExecutionContext(context);
            command.setJobId(job.getId());
            context.setMonitored(true);
        }
    } catch (Exception e) {
        log.error("Failed to prepare command of type '{}' for monitoring due to error '{}'", actionType.name(), e.getMessage());
        log.debug("Exception", e);
    }
}
Also used : Job(org.ovirt.engine.core.common.job.Job)

Example 15 with Job

use of org.ovirt.engine.core.common.job.Job in project ovirt-engine by oVirt.

the class ExecutionHandler method createJob.

/**
 * Creates and returns an instance of {@link Job} entity.
 *
 * @param actionType
 *            The action type the job entity represents.
 * @param command
 *            The {@code CommandBase} instance which the job entity describes.
 * @return An initialized {@code Job} instance.
 */
public static Job createJob(ActionType actionType, CommandBase<?> command) {
    Job job = new Job();
    job.setId(Guid.newGuid());
    job.setActionType(actionType);
    job.setDescription(ExecutionMessageDirector.resolveJobMessage(actionType, command.getJobMessageProperties()));
    job.setJobSubjectEntities(getSubjectEntities(command.getPermissionCheckSubjects()));
    job.setOwnerId(command.getUserId());
    job.setEngineSessionSeqId(command.getSessionSeqId());
    job.setStatus(JobExecutionStatus.STARTED);
    job.setStartTime(new Date());
    job.setCorrelationId(command.getCorrelationId());
    return job;
}
Also used : Job(org.ovirt.engine.core.common.job.Job) Date(java.util.Date)

Aggregations

Job (org.ovirt.engine.core.common.job.Job)35 Step (org.ovirt.engine.core.common.job.Step)7 Date (java.util.Date)6 Guid (org.ovirt.engine.core.compat.Guid)6 JobExecutionStatus (org.ovirt.engine.core.common.job.JobExecutionStatus)4 ArrayList (java.util.ArrayList)3 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)3 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)3 Inject (com.google.inject.Inject)2 Collection (java.util.Collection)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 Test (org.junit.Test)2 VdcObjectType (org.ovirt.engine.core.common.VdcObjectType)2 GetJobsByOffsetQueryParameters (org.ovirt.engine.core.common.queries.GetJobsByOffsetQueryParameters)2 Event (org.ovirt.engine.ui.uicompat.Event)2 EventArgs (org.ovirt.engine.ui.uicompat.EventArgs)2 IEventListener (org.ovirt.engine.ui.uicompat.IEventListener)2 TaskModelProvider (org.ovirt.engine.ui.webadmin.uicommon.model.TaskModelProvider)2