Search in sources :

Example 1 with IncidentTreeImpl

use of org.opencastproject.job.api.IncidentTreeImpl in project opencast by opencast.

the class IncidentsTest method testFindFailure2.

@Test
public void testFindFailure2() {
    final IncidentTree r = new IncidentTreeImpl(Immutables.list(mkIncident(Severity.INFO), mkIncident(Severity.INFO), mkIncident(Severity.INFO)), Immutables.<IncidentTree>list(new IncidentTreeImpl(Immutables.list(mkIncident(Severity.INFO), mkIncident(Severity.WARNING)), Immutables.<IncidentTree>list(new IncidentTreeImpl(Immutables.list(mkIncident(Severity.WARNING), mkIncident(Severity.INFO)), Immutables.<IncidentTree>nil())))));
    assertFalse(Incidents.findFailure(r));
}
Also used : IncidentTreeImpl(org.opencastproject.job.api.IncidentTreeImpl) IncidentTree(org.opencastproject.job.api.IncidentTree) Test(org.junit.Test)

Example 2 with IncidentTreeImpl

use of org.opencastproject.job.api.IncidentTreeImpl in project opencast by opencast.

the class AbstractIncidentService method getIncidentsOfJob.

@Override
public IncidentTree getIncidentsOfJob(long jobId, boolean cascade) throws NotFoundException, IncidentServiceException {
    List<Incident> incidents = getIncidentsOfJob(jobId);
    List<IncidentTree> childIncidents = new ArrayList<IncidentTree>();
    try {
        Job job = getServiceRegistry().getJob(jobId);
        if (cascade && !"START_WORKFLOW".equals(job.getOperation())) {
            childIncidents = getChildIncidents(jobId);
        } else if (cascade && "START_WORKFLOW".equals(job.getOperation())) {
            for (WorkflowOperationInstance operation : getWorkflowService().getWorkflowById(jobId).getOperations()) {
                if (operation.getState().equals(OperationState.INSTANTIATED))
                    continue;
                IncidentTree operationResult = getIncidentsOfJob(operation.getId(), true);
                if (hasIncidents(Collections.list(operationResult)))
                    childIncidents.add(operationResult);
            }
        }
        return new IncidentTreeImpl(incidents, childIncidents);
    } catch (NotFoundException ignore) {
        // Workflow deleted
        return new IncidentTreeImpl(incidents, childIncidents);
    } catch (Exception e) {
        logger.error("Error loading child jobs of {}: {}", jobId);
        throw new IncidentServiceException(e);
    }
}
Also used : WorkflowOperationInstance(org.opencastproject.workflow.api.WorkflowOperationInstance) IncidentTreeImpl(org.opencastproject.job.api.IncidentTreeImpl) IncidentServiceException(org.opencastproject.serviceregistry.api.IncidentServiceException) ArrayList(java.util.ArrayList) NotFoundException(org.opencastproject.util.NotFoundException) Incident(org.opencastproject.job.api.Incident) Job(org.opencastproject.job.api.Job) IncidentServiceException(org.opencastproject.serviceregistry.api.IncidentServiceException) ServiceRegistryException(org.opencastproject.serviceregistry.api.ServiceRegistryException) NotFoundException(org.opencastproject.util.NotFoundException) IncidentTree(org.opencastproject.job.api.IncidentTree)

Example 3 with IncidentTreeImpl

use of org.opencastproject.job.api.IncidentTreeImpl in project opencast by opencast.

the class IncidentsTest method testFindFailure3.

@Test
public void testFindFailure3() {
    final IncidentTree r = new IncidentTreeImpl(Immutables.list(mkIncident(Severity.FAILURE), mkIncident(Severity.INFO), mkIncident(Severity.INFO)), Immutables.<IncidentTree>list(new IncidentTreeImpl(Immutables.list(mkIncident(Severity.INFO), mkIncident(Severity.WARNING)), Immutables.<IncidentTree>list(new IncidentTreeImpl(Immutables.list(mkIncident(Severity.WARNING), mkIncident(Severity.INFO)), Immutables.<IncidentTree>nil())))));
    assertTrue(Incidents.findFailure(r));
}
Also used : IncidentTreeImpl(org.opencastproject.job.api.IncidentTreeImpl) IncidentTree(org.opencastproject.job.api.IncidentTree) Test(org.junit.Test)

Example 4 with IncidentTreeImpl

use of org.opencastproject.job.api.IncidentTreeImpl in project opencast by opencast.

the class IncidentsTest method testFindFailure1.

@Test
public void testFindFailure1() {
    final IncidentTree r = new IncidentTreeImpl(Immutables.list(mkIncident(Severity.INFO), mkIncident(Severity.INFO), mkIncident(Severity.INFO)), Immutables.<IncidentTree>list(new IncidentTreeImpl(Immutables.list(mkIncident(Severity.INFO), mkIncident(Severity.WARNING)), Immutables.<IncidentTree>list(new IncidentTreeImpl(Immutables.list(mkIncident(Severity.WARNING), mkIncident(Severity.FAILURE)), Immutables.<IncidentTree>nil())))));
    assertTrue(Incidents.findFailure(r));
}
Also used : IncidentTreeImpl(org.opencastproject.job.api.IncidentTreeImpl) IncidentTree(org.opencastproject.job.api.IncidentTree) Test(org.junit.Test)

Example 5 with IncidentTreeImpl

use of org.opencastproject.job.api.IncidentTreeImpl in project opencast by opencast.

the class AbstractIncidentService method getChildIncidents.

private List<IncidentTree> getChildIncidents(long jobId) throws NotFoundException, ServiceRegistryException, IncidentServiceException {
    List<Job> childJobs = getServiceRegistry().getChildJobs(jobId);
    List<IncidentTree> incidentResults = new ArrayList<IncidentTree>();
    for (Job childJob : childJobs) {
        if (childJob.getParentJobId() != jobId)
            continue;
        List<Incident> incidentsForJob = getIncidentsOfJob(childJob.getId());
        IncidentTree incidentTree = new IncidentTreeImpl(incidentsForJob, getChildIncidents(childJob.getId()));
        if (hasIncidents(Collections.list(incidentTree)))
            incidentResults.add(incidentTree);
    }
    return incidentResults;
}
Also used : IncidentTreeImpl(org.opencastproject.job.api.IncidentTreeImpl) ArrayList(java.util.ArrayList) Incident(org.opencastproject.job.api.Incident) Job(org.opencastproject.job.api.Job) IncidentTree(org.opencastproject.job.api.IncidentTree)

Aggregations

IncidentTree (org.opencastproject.job.api.IncidentTree)5 IncidentTreeImpl (org.opencastproject.job.api.IncidentTreeImpl)5 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 Incident (org.opencastproject.job.api.Incident)2 Job (org.opencastproject.job.api.Job)2 IncidentServiceException (org.opencastproject.serviceregistry.api.IncidentServiceException)1 ServiceRegistryException (org.opencastproject.serviceregistry.api.ServiceRegistryException)1 NotFoundException (org.opencastproject.util.NotFoundException)1 WorkflowOperationInstance (org.opencastproject.workflow.api.WorkflowOperationInstance)1