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); } }
/** * 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 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); } } }