/** * Record an incident for a given job. This method is intended to record client incidents, i.e. incidents crafted by * the programmer. * * @see #record(org.opencastproject.job.api.Job, org.opencastproject.job.api.Incident.Severity, int, java.util.Map, * java.util.List) * @see org.opencastproject.job.api.Incident */ public void record(Job job, Severity severity, int code) { record(job, severity, code, NO_PARAMS, NO_DETAILS); }
@Override public Boolean apply(IncidentTree r) { return findFailure(r); } };
/** * Record a failure incident for a given job. * * @see #record(org.opencastproject.job.api.Job, org.opencastproject.job.api.Incident.Severity, int, java.util.Map, * java.util.List) * @see org.opencastproject.job.api.Incident */ public void recordFailure(Job job, int code, Throwable t, List<Tuple<String, String>> details) { recordFailure(job, code, t, NO_PARAMS, details); }
/** OSGi DI. */ public void setIncidentService(IncidentService incidentService) { // Manually resolve the cyclic dependency between the incident service and the service registry ((OsgiIncidentService) incidentService).setServiceRegistry(this); this.incidents = new Incidents(this, incidentService); }
/** * Record an incident for a given job caused by an uncatched exception. This method is intended to record incidents by * the job system itself, e.g. the job dispatcher. Please note that an incident will <em>only</em> be recorded if none * of severity {@link org.opencastproject.job.api.Incident.Severity#FAILURE} has already been recorded by the job or * one of its child jobs. If no job with the given job id exists nothing happens. */ public void unhandledException(long jobId, Severity severity, Throwable t) { try { unhandledException(sr.getJob(jobId), severity, t); } catch (NotFoundException ignore) { } catch (ServiceRegistryException e) { logException(e); } }
/** * Record an incident for a given job caused by an uncatched exception. This method is intended to record incidents by * the job system itself, e.g. the job dispatcher. */ private void unhandledException(Job job, String code, Severity severity, Throwable t) { if (!alreadyRecordedFailureIncident(job.getId())) { try { is.storeIncident( job, new Date(), code, severity, Collections.singletonMap("exception", ExceptionUtils.getMessage(t)), Arrays.asList(tuple("job-type", job.getJobType()), tuple("job-operation", job.getOperation()), tuple("stack-trace", ExceptionUtils.getStackTrace(t)))); } catch (IncidentServiceException e) { logException(e); } } }
/** * Record an incident for a given job caused by an uncatched exception. This method is intended to record incidents by * the job system itself, e.g. the job dispatcher. */ public void unhandledException(Job job, Severity severity, Throwable t) { unhandledException(job, SYSTEM_UNHANDLED_EXCEPTION, severity, t); }
public void recordMigrationIncident(Job job, String error) { try { is.storeIncident(job, new Date(), SYSTEM_MIGRATED_ERROR, Severity.FAILURE, Collections.singletonMap("error", error), NO_DETAILS); } catch (IncidentServiceException e) { logException(e); } }
public ServiceRegistryInMemoryImpl(JobProducer service, float maxLoad, SecurityService securityService, UserDirectoryService userDirectoryService, OrganizationDirectoryService organizationDirectoryService, IncidentService incidentService) throws ServiceRegistryException { //Note: total memory here isn't really the correct value, but we just need something (preferably non-zero) registerHost(LOCALHOST, LOCALHOST, Runtime.getRuntime().totalMemory(), Runtime.getRuntime().availableProcessors(), maxLoad); if (service != null) registerService(service, maxLoad); this.securityService = securityService; this.userDirectoryService = userDirectoryService; this.organizationDirectoryService = organizationDirectoryService; this.incidents = new Incidents(this, incidentService); this.dispatcher.scheduleWithFixedDelay(new JobDispatcher(), DEFAULT_DISPATCHER_TIMEOUT, DEFAULT_DISPATCHER_TIMEOUT, TimeUnit.MILLISECONDS); }
public void recordJobCreationIncident(Job job, Throwable t) { unhandledException(job, SYSTEM_JOB_CREATION_EXCEPTION, Severity.FAILURE, t); }
/** * Record an incident for a given job. This method is intended to record client incidents, i.e. incidents crafted by * the programmer. * * @param code * A code number. This incident factory method enforces an incident code schema of <code>job_type.code</code> * , e.g. <code>org.opencastproject.service.1511</code> . So instead of aligning * <code>job.getJobType()</code> and the incident's code prefix manually this is done automatically for you * by this method. See {@link org.opencastproject.job.api.Incident#getCode()}. * @see org.opencastproject.job.api.Incident */ public void record(Job job, Severity severity, int code, Map<String, String> params, List<Tuple<String, String>> details) { try { is.storeIncident(job, new Date(), job.getJobType() + "." + code, severity, params, details); } catch (IncidentServiceException e) { logException(e); } }
/** * Record a failure incident for a given job. * * @see #record(org.opencastproject.job.api.Job, org.opencastproject.job.api.Incident.Severity, int, java.util.Map, * java.util.List) * @see org.opencastproject.job.api.Incident */ public void recordFailure(Job job, int code, Map<String, String> params, List<Tuple<String, String>> details) { record(job, Severity.FAILURE, code, params, details); }
private void handleFailedProcessing(final Throwable t) throws Exception { if (t instanceof JobCanceledException) { logger.info(t.getMessage()); } else { Job jobAfterProcessing = getServiceRegistry().getJob(jobId); jobAfterProcessing.setStatus(Status.FAILED); jobAfterProcessing = getServiceRegistry().updateJob(jobAfterProcessing); getServiceRegistry().incident().unhandledException(jobAfterProcessing, Severity.FAILURE, t); logger.error("Error handling operation '{}': {}", jobAfterProcessing.getOperation(), getStackTrace(t)); if (t instanceof ServiceRegistryException) throw (ServiceRegistryException) t; } }
public boolean alreadyRecordedFailureIncident(long jobId) { try { return findFailure(is.getIncidentsOfJob(jobId, true)); } catch (Exception e) { return false; } }
/** * Record a failure incident for a given job. * * @see #record(org.opencastproject.job.api.Job, org.opencastproject.job.api.Incident.Severity, int, java.util.Map, * java.util.List) * @see org.opencastproject.job.api.Incident */ public void recordFailure(Job job, int code, List<Tuple<String, String>> details) { record(job, Severity.FAILURE, code, NO_PARAMS, details); }
/** * Record a failure incident for a given job. * * @see #record(org.opencastproject.job.api.Job, org.opencastproject.job.api.Incident.Severity, int, java.util.Map, * java.util.List) * @see org.opencastproject.job.api.Incident */ public void recordFailure(Job job, int code) { record(job, Severity.FAILURE, code, NO_PARAMS, NO_DETAILS); }
/** * Record a failure incident for a given job. * * @see #record(org.opencastproject.job.api.Job, org.opencastproject.job.api.Incident.Severity, int, java.util.Map, * java.util.List) * @see org.opencastproject.job.api.Incident */ public void recordFailure(Job job, int code, Map<String, String> params) { record(job, Severity.FAILURE, code, params, NO_DETAILS); }
/** * Record a failure incident for a given job. * * @see #record(org.opencastproject.job.api.Job, org.opencastproject.job.api.Incident.Severity, int, java.util.Map, * java.util.List) * @see org.opencastproject.job.api.Incident */ public void recordFailure(Job job, int code, Throwable t, Map<String, String> params, List<Tuple<String, String>> details) { List<Tuple<String, String>> detailList = new ArrayList<>(details); detailList.add(tuple("stack-trace", ExceptionUtils.getStackTrace(t))); record(job, Severity.FAILURE, code, params, detailList); }
@Override public WorkflowOperationResult start(WorkflowInstance wi, JobContext ctx) throws WorkflowOperationException { final WorkflowOperationInstance woi = wi.getCurrentOperation(); final int code = option(woi.getConfiguration(OPT_CODE)).bind(Strings.toInt).getOrElse(1); final Severity severity = option(woi.getConfiguration(OPT_SEVERITY)).bind(parseEnum(Severity.FAILURE)).getOrElse(Severity.INFO); final List<Tuple<String, String>> details = Arrays.stream(ArrayUtils.nullToEmpty( StringUtils.split(woi.getConfiguration(OPT_DETAILS), ";"))) .map((opt) -> opt.split("=")) .filter((t) -> t.length == 2) .map((x) -> Tuple.tuple(x[0], x[1])) .collect(Collectors.toList()); final Map<String, String> params = Arrays.stream(ArrayUtils.nullToEmpty( StringUtils.split(woi.getConfiguration(OPT_PARAMS), ";"))) .map((opt) -> opt.split("=")) .filter((t) -> t.length == 2) .collect(Collectors.toMap(x -> x[0], x -> x[1])); log.info("Create nop job"); final Job job = nopService.nop(); log.info("Log a dummy incident with code %d", code); serviceRegistry.incident().record(job, severity, code, params, details); if (!waitForStatus(job).isSuccess()) { throw new WorkflowOperationException("Job did not complete successfully"); } else { return createResult(WorkflowOperationResult.Action.CONTINUE); } }